In the simplest form solving a Mathematical Program identifier is done by using the intrinsic solve statement of AIMMS:
solve MathProgram ;
For the majority of the AIMMS modelers, this suffices for their needs. Whenever you want to have more advanced control over what happens, you have to start working with Generated Mathematical Programs (GMP). With GMP’s, you have full control over the constraint matrix: you can edit coefficients and add new constraints and variables.
The initial transition from using only standard Mathematical Program identifiers to using GMP functions is very easy and boils down to introducing an additional element parameter and changing the original solve statement into two statements: one for generating the GMP and one for solving the GMP. The element parameter you need is the following:
ELEMENT PARAMETER: identifier : genMathProgram range : AllGeneratedMathematicalPrograms
The original one-line solve statement now needs to be converted to the following two lines:
genMathProgram := gmp::Instance::Generate(MathProgram) ; gmp::Instance::Solve(genMathProgram ) ;
The first line generates the GMP and the second line solves this GMP. With these two minor additions, you have moved to using GMP’s. For more information about what you can do with the GMP’s, you can take a look at the Chapter “Implementing Advanced Algorithms for
Mathematical Programs” in the Language Reference and the GMP section in the Function Reference.
Additional information: The exact workings of gmp::Instance::Solve statement can actually be emulated in a couple of lower-level GMP statements. If you look at the Language Reference, you will see that you can emulate its behavior with the following calls:
! Create a solver session for genMP, which will create an element ! in the set AllSolverSessions, and assign the newly created element ! to the element parameter session. session := GMP::Instance::CreateSolverSession(genMP); ! Copy the initial solution from the variables in AIMMS to ! solution number 1 of the generated mathematical program. GMP::Solution::RetrieveFromModel(genMP,1); ! Send the solution stored in solution 1 to the solver session GMP::Solution::SendToSolverSession(session, 1); ! Call the solver session to actually solve the problem. GMP::SolverSession::Execute(session); ! Copy the solution from the solver session into solution 1. GMP::Solution::RetrieveFromSolverSession(session, 1); ! Store this solution in the AIMMS variables and constraints. GMP::Solution::SendToModel(genMP, 1);