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.