how to divide one dynamic set into two subsets

scalars k /0/
sets v /1*1000/
t(v)
s(v);

repeat k=k+1;

if k is odd, i need to record t(v)=1,3,5,7 as index
if k is even, i need to record s(v)=2,4,6,8 as index

until k=10;

any1 who can help me with this case? how can I program it in gams?
i am very confused with gams’ syntax

Sincerely


\

To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

Hi Songming Zhu

I’m not entirely clear on your question, but I understand it to be asking how to divide one (static) set v into two dynamic subsets, t and s

(on your loop, why “until k=10”?).



You can set the elements of the dynamic sets with the conditional assignment “= YES $ (condition)” syntax.

You can establish a condition to get alternating elements by using the modulo operator on the ordinal value of the index v.


\

  • scalars k /0/ // unneeded

sets v /1*100/

t(v)

s(v);



t(v) = YES $ mod(ORD(v),2);

s(v) = YES $ (not t(v));

DISPLAY t,s;



I hope this helps

Paul



From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of Songming Zhu
Sent: Wednesday, August 27, 2014 9:53 AM
To: gamsworld@googlegroups.com
Subject: Re: how to divide one dynamic set into two subsets



scalars k /0/

sets v /1*1000/

t(v)

s(v);



repeat k=k+1;



if k is odd, i need to record t(v)=1,3,5,7 as index

if k is even, i need to record s(v)=2,4,6,8 as index



until k=10;



any1 who can help me with this case? how can I program it in gams?

i am very confused with gams’ syntax



Sincerely






\

To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

Reply-to: gamsworld@googlegroups.com

thank you so much for your reply. It works.

now the condition changes:
k=k+1;

if a variable’s value fea.l<10e-5, i need to record t(v), the discrete set index when fea.l<10e-5

s(v)=not t(v)

until k=10;

how can I do?

I think my method below is incorrect.

t(v)=yes$((fea.l<10e-5)and(ord(v)=k));

s(v)=yes$((not t(v))and(ord(v)=k))

在 2014年8月27日星期三UTC-4上午10时38分42秒,Leiby, Paul Newsome写道:

Hi Songming Zhu

I’m not entirely clear on your question, but I understand it to be asking how to divide one (static) set v into two dynamic subsets, t and s

(on your loop, why “until k=10”?).



You can set the elements of the dynamic sets with the conditional assignment “= YES $ (condition)” syntax.

You can establish a condition to get alternating elements by using the modulo operator on the ordinal value of the index v.


\

  • scalars k /0/ // unneeded

sets v /1*100/

t(v)

s(v);



t(v) = YES $ mod(ORD(v),2);

s(v) = YES $ (not t(v));

DISPLAY t,s;



I hope this helps

Paul



From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of Songming Zhu
Sent: Wednesday, August 27, 2014 9:53 AM
To: gams...@googlegroups.com
Subject: Re: how to divide one dynamic set into two subsets



scalars k /0/

sets v /1*1000/

t(v)

s(v);



repeat k=k+1;



if k is odd, i need to record t(v)=1,3,5,7 as index

if k is even, i need to record s(v)=2,4,6,8 as index



until k=10;



any1 who can help me with this case? how can I program it in gams?

i am very confused with gams’ syntax



Sincerely






\

To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+...@googlegroups.com.
To post to this group, send email to gams...@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.