if-else if

24 views
Skip to first unread message

sahebe...@gmail.com

unread,
Jan 11, 2018, 7:16:36 AM1/11/18
to AMPL Modeling Language
Hi all,

What is wrong with this code??

set snb1;
if (card(DD1)>1) then let snb1:= DD1 union r_poll1;
else if (card(DD1)==0) and (card(r_poll1)==0) then let snb1:=snbb1;
else if (card(DD1)==0) and (card(r_poll1)==1) then let snb1:=snbb1;
else if (card(DD1)==1) and (card(r_poll1)==0) then let snb1:=snbb1;
else if (card(DD1)==1) and (card(r_poll1)==1) and (card(DD1 diff r_poll1)==0) then let snb1:=snbb1;
else if (card(DD1)==1) and (card(r_poll1)==1) and (card(DD1 diff r_poll1)!=0) then let snb1:= DD1 union r_poll1;
display snb1;

WBR

ptiwari

unread,
Jan 11, 2018, 3:13:02 PM1/11/18
to AMPL Modeling Language
Your code looks good. Are you getting any error?

Thanks,
Paras

sahebe...@gmail.com

unread,
Jan 13, 2018, 8:28:06 AM1/13/18
to AMPL Modeling Language
I do not know why the next code does not run!

ptiwari

unread,
Jan 13, 2018, 3:42:18 PM1/13/18
to AMPL Modeling Language
What error are you getting? How are you trying to run? Where did you define DD1 and other entities in the expression?

Thanks,
Paras
Reply all
Reply to author
Forward
0 new messages