RE: [AMPL 6114] only reset model?

474 views
Skip to first unread message

Robert Fourer

unread,
Sep 2, 2012, 5:22:47 PM9/2/12
to am...@googlegroups.com

There is no generic AMPL command for keeping only the parameter definitions.  However you can purge all the variables and then reset the data -- for example:

 

   purge Inv, Make, Sell;

   reset data;

 

The purge removes all objectives and constraints that use the variables, along with all the variables.  This is not suitable for using inside a loop, however; for that a "problem" command is needed.

 

Bob Fourer

4...@ampl.com

 

 

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

On Behalf Of frankcw
Sent: Saturday, September 01, 2012 3:37 PM
To: am...@googlegroups.com
Subject: [AMPL 6114] only reset model?

 

Hello,

 

I have a simple question. 

 

When writing a script file, I know I can reset everything (model and data and every parameters in the script file) or only reset data. Is there a way of resetting model and data, but keep parameters of script files?

 

I know we can define different problems. But writing many variables and constraint is not good in my case.

 

Thanks a lot,

Frank

 

Robert Fourer

unread,
Sep 5, 2012, 9:03:47 AM9/5/12
to am...@googlegroups.com

Usually when many models are solved with the same data, the models are very similar in structure.  As a result it is possible to define one general model; then after each solve, the next model can be created by only changing some parameter values.  Of course the exact way of doing this differs according to the details of the model, but if the models are similar then it is not hard to figure out.

 

If you need to use the same data to solve a series of models that are very different in structure, then I do not think there is any solution in AMPL other than what I previously suggested.  Perhaps it would help to post an example of several of your models, however.

On Behalf Of frankcw
Sent: Monday, September 03, 2012 8:51 AM
To: am...@googlegroups.com
Cc: 4...@ampl.com
Subject: Re: [AMPL 6122] only reset model?

 

Thanks for the information.

 

However, if there are many variables and constraints, I guess defining separate problem has almost the same effect and requires same time input. 

 

What I come along is to write result as .dat file and then reset everything (mainly reset model), read .dat file as parameters and then use the parameters for next model. 

Do you think I am able to have better solution?

 

Thanks again,

Frank

 

 

Reply all
Reply to author
Forward
0 new messages