how to represent this variables?

19 views
Skip to first unread message

ruilin...@gmail.com

unread,
May 19, 2016, 8:58:48 PM5/19/16
to AMPL Modeling Language
if you already defined that :var gemma[i in I, j in J, x in X, y in Y];
how to represent the variable gemma[i,j,m,n] where m in set X, n in set Y, but m is not necessarily equal to x, n not equal to y?

Robert Fourer

unread,
May 21, 2016, 10:18:51 PM5/21/16
to am...@googlegroups.com

In a constraint indexed like

   subject to con1 gemma {i in I, j in J, x in X, y in Y}: ...

you can write, as part of the constraint expression,

   ... sum {m in X, n in Y} gemma[i,j,m,n] ...

Here m in not necessarily equal to x, and n is not necessarily equal to y.  Thus at least it is an example of the situation you describe.

Bob Fourer
am...@googlegroups.com


--
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.

ruilin...@gmail.com

unread,
May 23, 2016, 12:01:21 PM5/23/16
to AMPL Modeling Language, 4...@ampl.com
thanks for your answer.

I still have question that do I have to write 

'subject to con1 gemma {i in I, j in J, x in X, y in Y,m in X, n in Y}'

at the beginning of the constraint?

在 2016年5月21日星期六 UTC-4下午10:18:51,Robert Fourer写道:

Robert Fourer

unread,
May 25, 2016, 12:41:23 AM5/25/16
to am...@googlegroups.com
It would be correct to write

subject to con1 {i in I, j in J, x in X, y in Y, m in X, n in Y}: ...

if you want to create a constraint for *every* combination of i in I, j in J, x in X, y in Y, m in X, and n in Y. However if you only want to create a constraint for every combination of i in I, j in J, x in X, and y in Y, and are going to sum over m in X and n in Y inside the constraint, then you should only write

subject to con1 {i in I, j in J, x in X, y in Y}: ...

Note that I accidentally wrote "subject to con1 gemma ..." in my previous post, but that should have been just "subject to con1 ...". Of course you do not need to call the constraint con1; it's just an arbitrary name that I picked.

Bob Fourer
am...@googlegroups.com

=======

ouyang ruilin

unread,
May 25, 2016, 11:06:09 AM5/25/16
to am...@googlegroups.com
Thank you so much for your help! It works.

--
You received this message because you are subscribed to a topic in the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ampl/ar8_V_JHP88/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ampl+uns...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages