Equations Defined over the Domain of Dynamic Sets Topic is solved

Problems with syntax of GAMS
Post Reply
sullian
User
User
Posts: 4
Joined: 4 years ago

Equations Defined over the Domain of Dynamic Sets

Post by sullian »

Hello. I am doing the optimization of transmission planning. I am confused about the definition and declaration of the dynamic set over an equation. I simplify the question as follows:

Code: Select all

sets
   nd             node (bus)                    /n1*n6/
   cl(nd,nd)      candidate lines               /n1.n2,n2.n3/
   y              /y1/;
alias (nd,nf,ni)
variable
xl(y,nf,ni)
TotalInvCost ;

equations
Objective
InvContLine(y,nd,nd);
Objective ..    TotalInvCost           =e= sum((y,cl), xl(y,cl));
InvContLine(y,cl(nd,nd))..    xl(y,cl)    =g=   1;
model a /all/;
solve  a using lp min TotalInvCost;
I tried different syntax for the domain set over the equation "InvContLine" to test. There are three results shown :
1. optimal
syntax 1:

Code: Select all

InvContLine(y,cl(nf,ni))..    xl(y,cl)    =g=   1;

syntax 2:

Code: Select all

InvContLine(y,cl(nf,ni))..    xl(y,nf,ni)    =g=   1;
syntax 3:

Code: Select all

InvContLine(y,cl)..             xl(y,cl)    =g=   1;

2. wrong
syntax 4:

Code: Select all

InvContLine(y,cl)..    xl(y,nf,ni)    =g=   1;

3. unbounded
syntax 5:

Code: Select all

InvContLine(y,cl(nd,nd))..    xl(y,cl)    =g=   1;
Now, my question is:
1. Compare syntax 2 and syntax 4, what's the difference? Why is the syntax 4 wrong?
1. Comparing syntax 5 and syntax 1, I notice that in the equation list, Constraint "InvContLine" shows none, which is the reason of unbounded result. However, what's the difference of cl(nd,nd) and cl(nf,ni) in the definition over equations. Is there any restriction on the use of Alias?
User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: Equations Defined over the Domain of Dynamic Sets

Post by Renger »

Hi

In equation 5 you defined your equation over c(nd,nd): these are only the diagonal elements (which are not part of the mapping). Use c(nd,nf) and the equation appears. This is probably due to the confusion resulting from the definition of a parameter, set, variable over a double index of the same set. If you write

Code: Select all

parameters
 	myparam(nd,nd);
Gams allows all combination. In an assignment this is not the case anymore and you have to use an alias

Code: Select all

* Only the diagonal elements are assigned
myparam(nd,nd) = random(0,1);
* All the elements are assigned a random value
alias(nd, and);
myparam(nd,and) = random(0,1);
Equation 4 is not accepted as the symbols of the sets on the left hand do not match the ones on the right side. I think this is just a syntax rule. Gams could have implemented that this would be treated the same, but there might be good reasons why they didn't.

Cheers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
sullian
User
User
Posts: 4
Joined: 4 years ago

Re: Equations Defined over the Domain of Dynamic Sets

Post by sullian »

Thanks so much, Renger. You really help dispel my confusion!
Post Reply