Saving and loading AMPL gurobi solution

91 views
Skip to first unread message

Daniela Silva

unread,
Sep 21, 2022, 10:46:47 AM9/21/22
to AMPL Modeling Language
Hello,

I am trying to save and then upload a Gurobi solution. 

I have tried the following parameters in gurobi

resultfile' = 'gurobi.sol', 
'wantsol' = 4

but when I load the gurobi.sol file, it returns an error 

Error executing "solution" command:
early end of file reading gurobi.sol

I have also tried using 

write bsolution; write gsolution;

but when I load the solution.sol file and execute the solve command, gurobi does not recognize it as a solution and does some iterations. 

I would appreciate any help on this.
Thank you

AMPL Google Group

unread,
Sep 22, 2022, 11:51:33 AM9/22/22
to AMPL Modeling Language
resultfile = gurobi.sol creates a solution file in a special format that is used by some Gurobi interfaces, but is not used by the AMPL-Gurobi interface. Thus, this kind of .sol file cannot be read by AMPL's solution command.

Either write bsolution or write gsolution creates a file solution.sol that does work with AMPL's solution command. To use this command, you do need to be sure that you have set up the same model and data as were current when solution.sol was written.

You say that, "when I load the solution.sol file and execute the solve command, gurobi does not recognize it as a solution and does some iterations." Do you mean that Gurobi does not recognize it as an optimal solution? That is to be expected. Even if you send an optimal solution to Gurobi, Gurobi will need to do some work to prove that it is optimal. For problems that have only continuous variables, sometimes the amount of work can be kept small, but for problems that contain any integer variables, the amount of work can be substantial.

If you have a different situation, can you provide some more explanation? Also, it would be very useful to know more about your reason for saving the solution and then later loading the solution and calling Gurobi again.


--
Robert Fourer
am...@googlegroups.com
{#HS:2015982266-112045#}
Reply all
Reply to author
Forward
0 new messages