access elements of a set to subset another set for writing equations

35 views
Skip to first unread message

Bharath K

unread,
Feb 10, 2015, 3:00:47 PM2/10/15
to gams...@googlegroups.com

set G /1,4,17,18/;
set g(G);

set T;
set t(T);
param k(T);
param n(T);

equation eq1(G);

eq1(g).. sum(t$(k(t) = ord(g)) n(t) >= 10 works. But this creates 4 equations …
sum(t$(k(t) = 1), n(t)) >= 10
sum(t$(k(t) = 2), n(t)) >= 10
sum(t$(k(t) = 3), n(t)) >= 10
sum(t$(k(t) = 4), n(t)) >= 10

since ord(g) refers to position of an item in a set but I want the value of that element. How do I do that? I want 
something like ... 
eq1(g).. sum over t such that k(t)=g) n(t) >= 10  which does not work

I want eq1(g) to spawn 4 equations …
sum(t$(k(t) = 1), n(t)) >= 10
sum(t$(k(t) = 4), n(t)) >= 10
sum(t$(k(t) = 17), n(t)) >= 10
sum(t$(k(t) = 18), n(t)) >= 10

Thanks
Bharath

Renger van Nieuwkoop

unread,
Feb 11, 2015, 3:02:14 AM2/11/15
to gams...@googlegroups.com

Hi Bharath

You could use g.val(g) which gives, if the set elements are numbers, the value of the element g

Cheers

Renger

--
You received this message because you are subscribed to the Google Groups "gamsworld" group.
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.

Bharath K

unread,
Feb 11, 2015, 10:17:54 AM2/11/15
to gams...@googlegroups.com

When I rewrite the equation as follow it gives errors. Is there a syntax guidance on usage?

eq1(g).. sum(t$(k(t) = g.val(g)), n(t)) =g= 10 

Errors:
8 ')' expected
10 ',' expected
37 '=l=' or '=e=' or '=g=' operator expected
148 Dimension different - The symbol is referenced with more/less indices as declared

Thanks!
Bharath

Renger van Nieuwkoop

unread,
Feb 11, 2015, 10:50:32 AM2/11/15
to gams...@googlegroups.com

Check your parentheses for the $ statement…

Bharath

unread,
Feb 12, 2015, 2:16:35 AM2/12/15
to gams...@googlegroups.com

The issue got resolved when i used g.val instead of g.val(g) 

Thanks! 
Bharath
You received this message because you are subscribed to a topic in the Google Groups "gamsworld" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gamsworld/H7p7SZqlEfU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gamsworld+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages