nested For

9 views
Skip to first unread message

Alessandro Oscar Gilardino Arias

unread,
Oct 19, 2016, 11:04:27 PM10/19/16
to AMPL Modeling Language
Dear all, I would like to know if you can explain me the difference between the following two statements:


In the first one I would like to do something like: For {i in set1, j in set2} {.....statement.....};

subject to constraint1 {i in set1, j in set2}:


In the second I want something like a nested for function, something like: For{i in set1} { For {j in set2} {.......statement........}};

I am trying to do the following:

subject to constraint2 {i in set1} : {j in set2} : 

but I get a sintax error. 


Also, both constraint are the same?

Regards

Robert Fourer

unread,
Oct 20, 2016, 6:25:49 PM10/20/16
to am...@googlegroups.com
There is nothing like a nested loop in an AMPL "subject to" statement. You have to write a single indexing set, such as in your first example,

subject to constraint1 {i in set1, j in set2}: ...

when specifying a collection of constraints.

Bob Fourer
am...@googlegroups.com

=======

Alessandro Oscar Gilardino Arias

unread,
Oct 20, 2016, 6:36:20 PM10/20/16
to am...@googlegroups.com
thanks a lot!

Alessandro Gilardino Arias
Red Peruana de Ciclo de Vida
Departamento de Ingenieria
Pontificia Universidad Catolica del Peru

--
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+unsubscribe@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.

Reply all
Reply to author
Forward
0 new messages