How to write the following simple equations

13 views
Skip to first unread message

arr...@gmail.com

unread,
Apr 25, 2016, 7:53:29 PM4/25/16
to AMPL Modeling Language
Hi folks, 
           I have the following naive question. I have a set of variables defined as 

var x{S} integer; 

          The equations are as follows: x[S[1]] = x[S[2]]=x[S[3]] ......  

          S[1] means the first element of the set S.  Currently S is defined as an unordered set. I'm fine with S being an ordered set.  

          Thanks in advance!

Feng

arr...@gmail.com

unread,
Apr 26, 2016, 8:31:12 AM4/26/16
to AMPL Modeling Language, arr...@gmail.com
I figured this out. 

Define S as an ordered set. then

myconst{i in S: ord(i)>1} x[first(S)] = x[i];
Reply all
Reply to author
Forward
0 new messages