The following procedure comes close to what you are describing. Before solving, you can give a command of either of the following forms:
write byourmodname;
write gyourmodname;
Then after solving, the solution file, which is usually read and then deleted, will be saved with the name yourmodname.sol. (Of course you can replace "yourmodname" with any name you like.) The only difference is that b will give a binary .sol file, while g will give an equivalent text file.
At a subsequent AMPL session, you can reload this saved solution. First you must reload the model and all data, so that you have defined the same problem as when you solved previously. Then instead of "solve;" you can give the command
solution yourmodname.sol;
after which the state of AMPL will be the same as it was after solving previously.
Bob Fourer
From: am...@googlegroups.com [mailto:am...@googlegroups.com]
On Behalf Of Nicola Carapellese
Sent: Thursday, June 20, 2013 9:10 AM
To: am...@googlegroups.com
Subject: [AMPL 7191] How to save the complete state of an optimization outcome?
Is there a simple way to save to a file the complete state of an optimization outcome, in a way such that I can reload it in AMPL?
The "g" has to come at the beginning:
write gc:\ampl\mymodel;
solve;
This produces c:\ampl\mymodel.sol.
On Behalf Of Kunlei Lian
Sent: Friday, June 21, 2013 4:54 PM
To: am...@googlegroups.com
Cc: 4...@ampl.com
Subject: Re: [AMPL 7201] How to save the complete state of an optimization outcome?
--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ampl+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ampl/3be40469-3205-4ef1-9439-6b31ee2fd061%40googlegroups.com.
On Mon, Apr 6, 2020 at 5:55 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
Hi Marina,
By default, AMPL sends the current values of the variables to the solver. Then the solver can use these values as a warm start, if it is able to do so. In particular, if you solve, then change some parameter values (such as objective coefficients), then solve again, the optimal values from the first solve will be sent to the solver as a potential warm start for the second solve. This feature is controlled by option reset_initial_guesses, which is 0 by default but can be set to 1 to turn off sending the current variable values to the solver.
For linear programs, the same mechanism applies to basis statuses (like "basic" and "at lower bound"). So if a continuous LP is being solved in the above examples, then optimal basis statuses from the first solve will also be sent to the solver as a potential warm start for the second solve. This feature is controlled by option send_statuses, which is 1 by default but can be set to 0 to turn off sending the current basis statuses to the solver.
--
Robert Fourer
am...@googlegroups.com
Hello Group,
I'm using a variable instance name
Example:
param InstanceName symbolic;
model model.mod
for { }{
...
let InstanceName:= "MontevideoCompleto_" & rho & "R_" & budget & "B_" & tech; #InstanceName looks like this: MontevideoCompleto_HR_HB_3
data (InstanceName); #It takes the rigth name MontevideoCompleto_HR_HB_3 as file of data.
solve;
...
}
This "for" scope works fine, but when It adds the sentence write b(InstanceName) or write (bInstanceName) the name of solution file is (InstanceName).sol instead of MontevideoCompleto_HR_HB_3.sol
Is there any way that solution file name be MontevideoCompleto_HR_HB_3.sol ? (the content of the parameter InstanceName).
Thanks in advance and best regards.
On Wed, Apr 8, 2020 at 3:21 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
As long as the change has no effect on the structure of the problem, you can load the new instance. It doesn't matter whether the change is made through the model or the data file.
Note however that it is the structure of the problem that is sent to the solver, after processing by AMPL's presolve phase, that must not change. So you want to be sure that the change is such that presolve eliminates exactly the same variables and constraints in the original problem and in the new one. (You can always check this by setting "option show_stats 1;".) If presolve's actions will cause difficulty, you can turn it off with "option presolve 0;".
--
Robert Fourer
am...@googlegroups.com