Store a feasible solution before completion

170 views
Skip to first unread message

arr...@gmail.com

unread,
Feb 7, 2014, 7:15:49 PM2/7/14
to am...@googlegroups.com
Hi all, 
        The way I run AMPL is to submit it to a computational grid (Not the interactive interface). It returns the result files after completion. However, due to some unknown reason, my job was terminated after 10 hours with 3% gap remained. This happens a lot recently. The server is not reliable. So I want to save the best solution so far so that, even my AMPL job gets killed, I still be able to see the best feasible solution looks like. 
        Can this be done in AMPL? 

Thanks,



fbahr

unread,
Feb 8, 2014, 4:36:46 AM2/8/14
to am...@googlegroups.com, arr...@gmail.com
Probably just stating the rather obvious... anyhow:

how about
1. solve model w/o objective function [to obtain a feasible solution]
2. prep.: add objective function, set time limit
3. repeat while solver_status != 'solved' {
       warmstart with previously found solution
       store solution
     };
?

--fbahr

Robert Fourer

unread,
Feb 9, 2014, 7:18:06 PM2/9/14
to am...@googlegroups.com

Some MIP solvers will save feasible solutions in files that can be read by AMPL.  This only works if the run is terminated by a recognizable interrupt (equivalent to a "ctrl-C") or other termination condition, and not by a crash or arbitrary "kill" operation; so it's worth a try but may or may not be helpful.

 

In CPLEX you can specify

 

   option cplex_options 'poolstub savesol';

 

or add this option to your existing cplex_options string.  (I use savesol just as an example; you can specify any name you like.)  Then CPLEX will write the successively better integer solutions that it finds as savesol1.sol, savesol2.sol, etc.  These files are produced upon termination.  Then if the last one is, say, savesol7.sol, and if you can copy it back to a local computer, you can read it in a subsequent AMPL session with the command

 

   solution savesol7.sol;

 

Only the solution is in this file, so before you give this command you must set up the whole AMPL model again just as it was when you tried to solve it.  In your case that would mean running the same script that you submitted to the computational grid, but with "solution savesol7.sol;" replacing the "solve;" command.

 

In Gurobi the analogous feature is specified in the gurobi_options string with the option ams_stub (ams stands for "alternate MIP solutions").

 

Bob Fourer

am...@googlegroups.com

 

 

From: am...@googlegroups.com [mailto:am...@googlegroups.com]

On Behalf Of arr...@gmail.com
Sent: Friday, February 7, 2014 6:16 PM
To: am...@googlegroups.com
Subject: [AMPL 7980] Store a feasible solution before completion

arr...@gmail.com

unread,
Feb 10, 2014, 10:44:21 AM2/10/14
to am...@googlegroups.com, 4...@ampl.com
Thank you Bob. I'm going to try this. But I'm wondering when CPLEX starts storing feasible solutions. What if CPLEX found thousands of feasible solution before terminated?   Could that be possible? 

arr...@gmail.com

unread,
Feb 10, 2014, 10:47:00 AM2/10/14
to am...@googlegroups.com, arr...@gmail.com
Thank you Florian! That's a good idea, but I'm concerned that if the MIP has many feasible solutions, then the warm start things will slow down the solution process. 

Robert Fourer

unread,
Feb 11, 2014, 12:38:04 PM2/11/14
to am...@googlegroups.com

Using the "poolstub" option creates what CPLEX calls its solution pool.  There are many other options with "pool" in the name that regulate the solution pool's contents; see

   www.ampl.com/netlib/ampl/solvers/cplex/README.cplex

In particular "poolcapacity n" causes only the last n solutions to be kept.  For a MIP each new solution must have a better objective than the previous one, and this tends to keep the number of solutions found to a reasonable level.

On Behalf Of arr...@gmail.com
Sent: Monday, February 10, 2014 9:44 AM
To: am...@googlegroups.com
Cc: 4...@ampl.com
Subject: Re: [AMPL 7998] Store a feasible solution before completion

arr...@gmail.com

unread,
Feb 17, 2014, 12:25:25 PM2/17/14
to am...@googlegroups.com, 4...@ampl.com
Thank you Bob. The AMPL instance running on our servers crashed in a strange way that no solutions are stored. I was told that the servers crashed after an outage following a snow storm in Atlanta. Probably the whole system collapsed so that no solution files were preserved.  I will try it later.  


On Tuesday, February 11, 2014 11:38:04 AM UTC-6, AMPL Optimization wrote:

Using the "poolstub" option creates what CPLEX calls its solution pool.  There are many other options with "pool" in the name that regulate the solution pool's contents; see

   www.ampl.com/netlib/ampl/solvers/cplex/README.cplex

In particular "poolcapacity n" causes only the last n solutions to be kept.  For a MIP each new solution must have a better objective than the previous one, and this tends to keep the number of solutions found to a reasonable level.

Bob Fourer

am...@googlegroups.com

Baburam Rijal

unread,
Oct 19, 2017, 10:53:50 AM10/19/17
to AMPL Modeling Language
Could you suggest how you store the gap?
Reply all
Reply to author
Forward
0 new messages