Function GMP::Instance::Generate(MP, name)

GMP::Instance::Generate

The function GMP::Instance::Generate generates a mathematical program instance from a symbolic mathematical program.

GMP::Instance::Generate(
     MP,             ! (input) a symbolic mathematical program
     [name]          ! (optional) a string expression
     )

Arguments

MP

A symbolic mathematical program in the set AllMathematicalPrograms. The mathematical program should have model type LP, MIP, QP, MIQP, QCP, MIQCP, NLP, MINLP, RMIP or RMINLP.

name

A string that holds the name for the mathematical program to be generated.

Return Value

A new element in the set AllGeneratedMathematicalPrograms with the name as specified by the name argument.

Note

  • If the second argument is not specified, or if it is the empty string, the name of the symbolic mathematical program is used to create a new element in the set AllGeneratedMathematicalPrograms.

  • If an element with name specified by the name argument is already present in the set AllGeneratedMathematicalPrograms the corresponding generated mathematical program will be replaced (or updated in case the same symbolic mathematical program is involved or the second argument is not specified). In that case all existing solver sessions created for the generated mathematical program will be deleted.

  • It is possible to generate indexed mathematical program instances. See the example in Indexed Mathematical Program Instances of the Language Reference.

  • A callback procedure should be installed using the appropriate GMP procedure, (e.g., GMP::Instance::SetCallbackIterations) instead of using a suffix of the mathematical program (e.g., suffix CallbackIterations).

  • If an error occurs during the execution of GMP::Instance::Generate, e.g., if one of the constraints appears to be empty and infeasible, then the program status of the mathematical program will be set to Infeasible and the solver status to PreprocessorError.

Example

Assume that ‘MP’ is a symbolic mathematical program which we want to solve twice thereby changing the constraint set:

ConstraintSet := { 'C1', 'C2' };
myGMP1 := GMP::Instance::Generate( MP );
GMP::Instance::Solve( myGMP1 );

ConstraintSet := { 'C3', 'C4' };
myGMP2 := GMP::Instance::Generate( MP );

After executing these statements, ‘myGMP1’ and ‘myGMP2’ will point to the same generated math program, namely the one using the constraints ‘C3’ and ‘C4’. The set AllGeneratedMathematicalPrograms will contain only one element, namely ‘MP’. At this point it makes no difference to use

GMP::Instance::Solve( myGMP1 );

or

GMP::Instance::Solve( myGMP2 );

By using the name argument we can create two different GMP’s from the same symbolic mathematical program:

ConstraintSet := { 'C1', 'C2' };
myGMP1 := GMP::Instance::Generate( MP, "FirstGMP" );
GMP::Instance::Solve( myGMP1 );

ConstraintSet := { 'C3', 'C4' };
myGMP2 := GMP::Instance::Generate( MP, "SecondGMP" );
GMP::Instance::Solve( myGMP2 );

This time the set AllGeneratedMathematicalPrograms will contain two elements, namely ‘FirstGMP’ and ‘SecondGMP’.