RE: [AMPL 9325] loading and solving 2 problems in AMPL

41 views
Skip to first unread message

Robert Fourer

unread,
Oct 21, 2014, 12:10:59 AM10/21/14
to am...@googlegroups.com

See the discussion of named problems in chapter 14, beginning with section 14.4 at

 

   http://ampl.com/BOOK/CHAPTERS/17-solvers.pdf#page=30

 

Bob Fourer

am...@googlegroups.com

 

 

From: am...@googlegroups.com [mailto:am...@googlegroups.com] On Behalf Of huynhiem
Sent: Friday, October 17, 2014 5:18 AM
To: am...@googlegroups.com
Subject: [AMPL 9325] loading and solving 2 problems in AMPL

 

Hi all, 

 

I have 2 problems: a master and a slave. I first solve the master problem and use the values of the master problem's variables as the parameters for the slave problem. Then solve the slave problem, then use the values of the slave problem's variables as the parameters for the master problem, and so on. In AMPL script, it would look like below. Is there a way to name the problems when loading into memory and is there a way to tell "solve" command what problem to address? Thank you very much. Neo

 

----------------------------

model master_problem_model.mod;

data master_problem_data.dat;

 

model slave_problem_model.mod;

data slave_problem_data.dat;

 

repeat {

           solve (the master problem);

 

           # update LB, lower bound

 

           # copy master problem's variables' values to slave problem's parameters

 

           solve (the slave problem);

 

           # update UB, lower bound

 

           # copy slave problem's variables' values to master problem's parameters

 

} until LB=UB;

----------------------------

 

 

--
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 post to this group, send email to am...@googlegroups.com.
Visit this group at http://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.

Asad Ali

unread,
Oct 22, 2014, 8:03:06 AM10/22/14
to am...@googlegroups.com, 4...@ampl.com
Hi,

This can be done in the .run file. You can give any name to the problems (models) and tell AMPL to solve them. Lets say you have two models master and slave. you will write script in run file like this:

problem master: Y (your decision variable goes here), edge (name of your objective function goes here),source_select_2 (here you will write names of all constraints seperated by comma) (put a semi colon at the end);

Then write:

solve master;

wherever you want. the same goes for the slave problem
Reply all
Reply to author
Forward
0 new messages