declare equation over dynamic multidimensional set Topic is solved

Problems with syntax of GAMS
Post Reply
astra
User
User
Posts: 4
Joined: 2 months ago

declare equation over dynamic multidimensional set

Post by astra » 2 months ago

Hello,

I want to limit my choice set to certain index combinations and am therefore trying to declare equations over a dynamic multidimensional set.

My model ran until I tried limiting the set so my feeling is my syntax is wrong. Could you please hep me on how to get the syntax right? As my model is pretty lengthy and all equations are only to be calculated for the members of the dynamic set I am only giving you the code for one equation. I hope it's sufficient.

Code: Select all

sets
i  Zone (district)                        /suburb1, city, suburb2/,
m  mode                                   /car, UAM/
;
alias (i,j,k,l,ii,jj,kk,ll);
alias (m,mm,mmm);
set
ijm(i,j,m)   /(suburb1,city,suburb2).(suburb1,city,suburb2).car, suburb1.(suburb1,city).UAM, city. (suburb1,city,suburb2). UAM, suburb2.(city,suburb2).UAM/
ijkm(i,j,k,m) /(suburb1,city,suburb2).(suburb1,city,suburb2).(suburb1,city,suburb2).car, suburb1.(suburb1,city).(suburb1,city,suburb2).UAM, city. (suburb1,city,suburb2).(suburb1,city,suburb2).UAM, suburb2.(city,suburb2).(suburb1,city,suburb2).UAM /;

variable
q(i,j,m)                Land demand low skilled Household Type ij (m^2);

equations
Eq_Land_demand_q(i,j,m)   land demand -> q,


Eq_Land_demand_q(ijm(i,j,m))..        q(ijm) =e= phi*(FullInc(i,j,m))/r(i) ;


option mcp=path;
option iterlim=900000;

model UrbanCGE
/
   Eq_Land_demand_q.q;
   
   solve UrbanCGE using mcp;
 

Thanks for taking your time to look at this!

Best,
Anna

User avatar
Renger
Posts: 566
Joined: 3 years ago

Re: declare equation over dynamic multidimensional set

Post by Renger » 2 months ago

Hi Anna

You are on the right track:

Code: Select all

Eq_Land_demand_q(i,j,m)$ijm(i,j,m)..        q(i,j,m) =e= (FullInc(i,j,m))/r(i) ;
Cheers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist

astra
User
User
Posts: 4
Joined: 2 months ago

Re: declare equation over dynamic multidimensional set

Post by astra » 2 months ago

Hi Renger,

thank you very much for your reply and the help! I very much appreciate your support! Unfortunately the model still doesn't run and encounters execution errors. I attached my code. It would be great if you could take a look at it.

Thank you so much!

Best wishes,
Anna
Last edited by astra 2 months ago, edited 1 time in total.

astra
User
User
Posts: 4
Joined: 2 months ago

Re: declare equation over dynamic multidimensional set

Post by astra » 2 months ago

Hi,

so I continued looking into this and still didn't get the model running. Using the notation Renger suggested the simulation runs as long as I include all sets. As soon as I exclude certain index combinations it stops running.

My feeling is that it tries calculating values tat have not been assigned because they're no longer part of the set. Is there any way to find that spot? I only get the message execution error. The listing file tells me:
**** Unmatched variable not free or fixed
Dwork(suburb1,suburb2,UAM)

**** Unmatched variable not free or fixed
Dwork(suburb2,suburb1,UAM)

**** Unmatched variable not free or fixed
inU(suburb1,suburb2,UAM)

**** Unmatched variable not free or fixed
inU(suburb2,suburb1,UAM)

**** Unmatched variable not free or fixed
Prob(suburb1,suburb2,UAM)

**** Unmatched variable not free or fixed
Prob(suburb2,suburb1,UAM)
which is exactly for those indices that have been excluded from the set. As this problem arises for those variables included in sums it might be due to the syntax I'm using in the summation. Could somebody maybe help me there? The way I currently do it is the following:

Code: Select all

Eq_Z_market(k)..                   X(k) =g=   sum( (i,j,m)$(ijm(i,j,m)), Prob(i,j,m)*Z(i,j,k,m)*N )+ Export(k) ;

Eq_Labor_market(j)..             sum( (i,m)$(ijm(i,j,m)), (Prob(i,j,m)*N*(Hwork*Dwork(i,j,m))) ) =g= laborfirm(j);
The other code is what I put in the original post.

Thank you for any hints!

Best,
Anna

User avatar
Renger
Posts: 566
Joined: 3 years ago

Re: declare equation over dynamic multidimensional set

Post by Renger » 2 months ago

Hi Anna
I haven't much time but here is a quick fix:

Code: Select all

DWork.FX(i,j,m)$(not ijm(i,j,m)) = 0;
INU.FX(i,j,m)$(not ijm(i,j,m)) = 0;
PROB.FX(i,j,m)$(not ijm(i,j,m)) = 0;
VOT.FX(i,j,m)$(not ijm(i,j,m)) = 0;
This will drop the equations for these variables and the model solves.
Cheers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist

astra
User
User
Posts: 4
Joined: 2 months ago

Re: declare equation over dynamic multidimensional set

Post by astra » 2 months ago

Thank you so much, Renger! The model indeed solves now!

Best wishes,
Anna

Post Reply