Skip to main content

Here I find a problem: when I use GMP::Instance::CreatePresolved to solve a MathematicalProgram , the solution I get belongs to the Presolved MathematicalProgram rather than the orignal MathematicalProgram. My code is as follows:

MyGMP := GMP::Instance::generate(MarketDA);
MyGMP_Pre := GMP::Instance::CreatePresolved(MyGMP,"GMP1");
MySolver := GMP::Instance::CreateSolverSession(MyGMP_Pre , "Solver1" , 'CPLEX 12.3');
GMP::SolverSession::Execute(MySolver);
GMP::Solution::RetrieveFromSolverSession(MySolver , 1 );
GMP::Solution::SendToModel(MyGMP,1);

There is an error report on the last line shows the solution 1 is not exist. Is it possible to send the solution 1 to “MyGMP” model ?

Hi ​@denghaiying. MySolver is a solver session for MyGMP_Pre and not for MyGMP. Therefore you should use:

GMP::Solution::SendToModel(MyGMP_Pre ,1);

AIMMS will automatically make the solution complete for the original model (MyGMP).


Now I want to add some constraints to “MyGMP” model and use the solution of “MyGMP_Pre” as a start. How can I get it?  


Are you solving an LP or MIP?

If you use

GMP::Instance::Solve(MyGMP);

then AIMMS will pass the solution of the previous solve to the solver.

Why are you using the function GMP::Instance::CreatePresolved? For linear models it normally does not have any advantage, and it is more efficient to solve the original model directly.


It’s a MIP MathematicalProgram. And I find when using  GMP::Instance::CreatePresolved, the model size will be smaller and can be solved more efficiently. So I intend to use GMP::Instance::CreatePresolved for  the original model and then use the solution as a start by GMP::Solution::SetMIPStartFlag. Thus, the solution belongs to the presolved model should be passed to the original model. Is there anyway to achieve solution transfer between different models?


After

MyGMP := GMP::Instance::generate(MarketDA);
MyGMP_Pre := GMP::Instance::CreatePresolved(MyGMP,"GMP1");
MySolver := GMP::Instance::CreateSolverSession(MyGMP_Pre , "Solver1" , 'CPLEX 12.3');
GMP::SolverSession::Execute(MySolver);
GMP::Solution::RetrieveFromSolverSession(MySolver , 1 );
GMP::Solution::SendToModel(MyGMP_Pre ,1);

you can use

GMP::Solution::RetrieveFromModel( MyGMP, 1 );
GMP::Solution::SetMIPStartFlag( MyGMP, 1, 1 );
GMP::Instance::Solve(MyGMP);

In the CPLEX status file you can see whether the MIP start is accepted (or not). Because you are adding constraints, the solution of the first model might not be feasible for the second model. Note that providing a (feasible) MIP start does not always have a positive impact on the solving time.


Reply


Didn't find what you were looking for? Try searching on our documentation pages:

AIMMS Developer & PRO | AIMMS How-To | AIMMS SC Navigator