define problem in a loop

37 views
Skip to first unread message

Luca Mencarelli

unread,
Apr 19, 2018, 12:52:26 PM4/19/18
to AMPL Modeling Language
Dear all,

I am implementing an optimization procedure in AMPL and basically I need
to solve a sequence of problems in a loop. The problems actually depend on
a parameter which is the loop index. Moreover I would like to solve the
problems in parallel. How can I do?

Thanks in advance. Best regards,
Luca
--
"Nothing at all takes place in the universe in which some rule of maximum
or minimum does not appear." Leonhard Euler (1707-1783)
---------------------------------------------------------
Luca Mencarelli
LIX (UMR 7161), Ecole Polytechnique
91128 Palaiseau CEDEX, France
Office: 2072 (Bâtiment Alan Turing, second floor)
E-mail address: menca...@lix.polytechnique.fr
Twitter: @l_mencarelli



AMPL Google Group

unread,
Apr 19, 2018, 4:30:00 PM4/19/18
to Ampl Modeling Language
AMPL doesn't has parallel for loop. You can solve sequence of your problem using AMPL script. You need to put AMPL command inside the loop. You can find some examples at https://ampl.com/BOOK/CHAPTERS/16-script.pdf . If you need to alternate between models, AMPL has the named problem feature. You could read about it at https://ampl.com/BOOK/CHAPTERS/17-solvers.pdf (page: 304).

--
Paras Tiwari
am...@googlegroups.com
{#HS:564796392-5649#}
--
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 https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.



AMPL Google Group

unread,
Apr 20, 2018, 7:46:21 PM4/20/18
to Ampl Modeling Language
You can't use an AMPL parameter as a loop index. However, you can assign the value of the loop index to a parameter at the beginning of the loop; then as the loop index changes, the parameter will also change. There is an example in Figure 14-1 of the AMPL book, at https://ampl.com/BOOK/CHAPTERS/17-solvers.pdf#page=10.

For parallel execution of AMPL solves, you may want to take a look at Parampl <http://www.parampl.com/>; which is made available by Artur Olszak of the Institute of Computer Science, Warsaw University of Technology.

--
Robert Fourer
am...@googlegroups.com
{#HS:564796392-5649#}
On Thu, Apr 19, 2018 at 8:29 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
AMPL doesn't has parallel for loop. You can solve sequence of your problem using AMPL script. You need to put AMPL command inside the loop. You can find some examples at https://ampl.com/BOOK/CHAPTERS/16-script.pdf . If you need to alternate between models, AMPL has the named problem feature. You could read about it at https://ampl.com/BOOK/CHAPTERS/17-solvers.pdf (page: 304).

--
Paras Tiwari
am...@googlegroups.com


On Thu, Apr 19, 2018 at 4:52 PM UTC, Ampl Modeling Language <am...@googlegroups.com> wrote:
Reply all
Reply to author
Forward
0 new messages