How to write AMPL for this constraint?

15 views
Skip to first unread message

Vinh K

unread,
May 17, 2018, 10:37:57 AM5/17/18
to AMPL Modeling Language








param V > 0, integer;

var b{1..V,1..V} binary;

subject to constraint5 {i in 3..V:i mod 2=1}: b[i,i-1] = sum{j in 2..V:j mod 2=0 and j != (i-1)} b[i-1,j];

 

 

 

But I do not know how to have {1} as a union to {2, 4,..} exclude {i-1}. I need to add 1 as the only odd value. As you can see from my AMPL declaration, I do not have {1} as a union because I could not find a tutorial for it. I used V instead of N.


Please help. Thank you


AMPL Google Group

unread,
May 17, 2018, 2:08:42 PM5/17/18
to Ampl Modeling Language
You can use 'by' instead of mod and use union operation. So, your constraint will be:

subject to constraint5 {i in 3..V by 2}: b[i,i-1] = sum{j in {1} union { 2..V by 2}:j != (i-1)} b[i-1,j];

--
Paras Tiwari
am...@googlegroups.com
{#HS:582814635-7950#}
On Thu, May 17, 2018 at 2:38 PM UTC, Ampl Modeling Language <am...@googlegroups.com> wrote:

Capture.PNG

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



Vinh K

unread,
May 17, 2018, 2:15:06 PM5/17/18
to AMPL Modeling Language
Thanks Paras Tiwari. I have been trying to figure this out for weeks. I could not find any documentation on 'by'. With your help it is looking good.
Reply all
Reply to author
Forward
0 new messages