Page 1 of 1

declare equation over dynamic multidimensional set

Posted: Sat Apr 11, 2020 6:47 pm
by astra
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

Re: declare equation over dynamic multidimensional set

Posted: Sun Apr 12, 2020 2:53 pm
by Renger
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

Re: declare equation over dynamic multidimensional set

Posted: Sun Apr 12, 2020 11:29 pm
by astra
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

Re: declare equation over dynamic multidimensional set

Posted: Wed Apr 15, 2020 8:34 pm
by astra
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

Re: declare equation over dynamic multidimensional set

Posted: Thu Apr 16, 2020 8:10 am
by Renger
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

Re: declare equation over dynamic multidimensional set

Posted: Thu Apr 16, 2020 9:03 am
by astra
Thank you so much, Renger! The model indeed solves now!

Best wishes,
Anna