# conditions on Sets AMPL

 0 hey, i was wondering if i can add a condition on a set on ampl on the .mod file for example set set1={1,2,3,4,5}; set set2={1,2,3,4,5,6,7};  i want to make a set3 that contains for example only the (i,j) such i=j from set1 and set2 ,Is it possible? Or do i need to do "the "within set1, set2 "and then define it in the data.dat file? thanks in advance asked 13 Jun '16, 01:56 jmslaterc 15●4 accept rate: 0% 1 set set3={set1,set2}; expands to: set set3 := (1,1) (1,5) (2,2) (2,6) (3,3) (3,7) (4,4) (5,1) (5,5) (1,2) (1,6) (2,3) (2,7) (3,4) (4,1) (4,5) (5,2) (5,6) (1,3) (1,7) (2,4) (3,1) (3,5) (4,2) (4,6) (5,3) (5,7) (1,4) (2,1) (2,5) (3,2) (3,6) (4,3) (4,7) (5,4); ord(e, set) gives the position of element e in (an ordered) set. So, sorry for being slow on the uptake... but what exactly are you asking for? Sth. like set set3=1 .. max(card(set1),card(set2)); ? (13 Jun '16, 14:20) fbahr ♦ thanks,i made a bad question i guess, what i want is create a set3 that contains for example only the (i,j) such i=j from set1 and set2 ,Is it possible? Or do i need to do "the "within set1, set2 "and then define it in the data.dat file? , thanks (13 Jun '16, 16:29) jmslaterc
Be the first one to answer this question!
 toggle preview community wiki

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "Title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported

Tags:

×29
×4
×4