controling equations with subsets

Problems with syntax of GAMS
Post Reply
fensterflieger
User
User
Posts: 2
Joined: 1 month ago

controling equations with subsets

Post by fensterflieger » 1 month ago

Dear all,

I have the following two sets

Code: Select all

technology
subset_of_tech(technology)
and the following two parameters/variables:

Code: Select all

var(technology)
par(technology)
If I now want a constraint equation to hold over subset_of_technology, which of the following two ways is possible?:

Code: Select all

constraint(subset_of_tech).. var(technology) =g= par(technology)
or

Code: Select all

constraint(subset_of_tech).. var(subset_of_tech) =g= par(subset_of_tech)

Unfortunately I couldn't find any information on this or just used the wrong search string .... If anyone could help me out, I'd be really grateful!

Best,
F.

Manassaldi
User
User
Posts: 65
Joined: 1 year ago
Location: Rosario - Argentina

Re: controling equations with subsets

Post by Manassaldi » 1 month ago

Hi, I hope this can help you.
Bye

constraint(technology)$subset_of_tech(technology).. var(technology) =g= par(technology);

fensterflieger
User
User
Posts: 2
Joined: 1 month ago

Re: controling equations with subsets

Post by fensterflieger » 1 month ago

This is great help, thank you a lot!

A little follow up question:

My set "technology" actually consists of two indices:

Code: Select all

technology(i,j)
Assuming that there is another set, say h, can I then use the following notation:

Code: Select all

constraint(technology,h)$subset_of_tech(technology).. var(technology,h) =g= par(technology,h);
In other words, does this result in

Code: Select all

constraint(i,j,h)
?

Best,
F.

Manassaldi
User
User
Posts: 65
Joined: 1 year ago
Location: Rosario - Argentina

Re: controling equations with subsets

Post by Manassaldi » 3 weeks ago

Hi, you must always reference to the original set (i, j)

for example:

set
i /i1*i10/
j /j1*j15/
h /h1*h40/
technology(i,j)
subset_of_tech(i,j)
;
technology(i,j)= some set definition
subset_of_tech(i,j)= some set definition

constraint(i,j,h)$(technology(i,j) and subset_of_tech(technology)).. var(i,j,h) =g= par(i,j,h);

equation "constraint" applies to all pairs of values of (i, j) that belong to the subset "technology" and "subset_of_tech" and for all set h.
This happens because the "and" between the two subsets was used

Bye!

Post Reply