MODEL:
! Find all the alternate optimal solutions (2 in this case)
to a linear program;
! Keywords: Alternative optima, Corner points, Enumeration, Extreme point,
K-Best solutions, Multi-criteria, Multiple optima, Simplex method;
! The linear program;
SUBMODEL MYLP:
[R_OBJ] !MAX = 6*X1 + 4*X2 ; MIN = X3; ! Constant objective gives
all feasible corner points;
X1 + 4*X2 <= 40 ;
3*X1 + 2*X2 <= 30 ;
3*X1 + X2 <= 24 ;
ENDSUBMODEL
PROCEDURE REPORT:
! Give a brief report on current solution;
@WRITE( @NEWLINE( 1));
@WRITE( ' Soln ', ITER, ', Objective = ', R_OBJ,
', X1, X2 = ', X1, ' ', X2,
);
ENDPROCEDURE
CALC:
! Suppress all output except errors;
@SET( 'TERSEO', 2);
! Solve the original model;
@SOLVE( MYLP);
! Suppress final infeasible error;
@SET( 'TERSEO', 3);
! While we continue to have an optimal solution,
solve for next alternate optimal solution;
ITER = 0;
@WHILE( @STATUS() #EQ# 0:
! Write current soln summary;
ITER = ITER + 1;
REPORT;
! Get next alternate optimal soln;
@NEXTALTOPT();
);
! Fall through here when no further alternate
optimal solutions exist;
@IFC( @STATUS() #EQ# 1:
@WRITE( @NEWLINE( 2),
' All Done! No further alt solns found.');
@ELSE
@WRITE( @NEWLINE( 2),
' *** Error solving MODEL ***');
);
ENDCALC
END
|