Multiplication and Addition with alias numbers and the error 148 & 133

Problems with syntax of GAMS
Post Reply
gamser
User
User
Posts: 3
Joined: 6 years ago

Multiplication and Addition with alias numbers and the error 148 & 133

Post by gamser »

Hey guys.

unfortunately my gams modelling is not running perfectly and I hope that sb of you knows an advice. The problem is the following:

I have defined two alias at the beginning in my sets. The alias-function works perfectly in the sum function but some problems occur if i want to use the alias funciton as well in multiplications. The result is the error 148 and 133.


The example:

Sets
p Set of possible wall positions / 0*35 /
t Set of periods / 1*5 /
r Set of rows along one corridor / 1*2 /
z Set of room lengths according to patients beds / 1*4 /
alias(p, q);
alias(z, z1, z2);

Parameter
lroom(z) Length of room size z
/
1 8
2 8
3 14
4 14 /
lroommax Maximum of all room lenghts /14/
lroommin Minimum of all room lenghts /8/
Ppos(r) Rightmost position for wall in row r
/
1 35
2 35/
vg(q,p) Position q ungleich position p;
vg(q,p)=1$(ord(q) <> ord(p));

Furhtermore the Demand is definded and the variables as well:

binary variable
s(z,r,p,t) 1 if a wall is the left end of a room;

These are the equations:

GSK.. UBcost =e= sum[(z1,z2,t), n(z1,z2,t)$(ord(z1) <> ord(z2))];

NB25(z1,t).. sum[z2, n(z1,z2,t)] =e= z1 * a(z1,t);
NB26(z2,t).. sum[z1, n(z1,z2,t)] =e= z2 * sum[(r,p), s(z2,r,p,t)];
NB27(r,t,p).. sum[z, s(z,r,"0",t)] =e= 1;
NB28(r,p,t,q)$((ord(p) <> card(p)) AND ord(q) gt ord(p)).. sum(z, (q * s(z,r,p,t)) - (p * s(z,r,p,t)) ) + [(p + lroommax ) * (1- sum (z, s(z,r,p,t)))] =g= sum[z, lroom(z) * s(z,r,p,t)];
NB29(z,r,p,t).. s(z,r,p,t) =e= 0;
NB30(r,p,t)$(ord(t) > 1).. sum[z, s(z,r,p,t-1)] =e= sum[z, s(z,r,p,t)];


The only errors which still occur are the numbers 148 and 133 in the case of the multiplication and the addition within the equations. The relevant output of the solve windows is followed:

68 GSK.. UBcost =e
= sum[(z1,z2,t), n(z1,z2,t)$(ord(z1) <> ord(z2))];
69
70 NB25(z1,t).. sum[z2, n
(z1,z2,t)] =e= z1 * a(z1,t);
**** $148
71 NB26(z2,t).. sum[z1, n
(z1,z2,t)] =e= z2 * sum[(r,p), s(z2,r,p,t)];
**** $148
72 NB27(r,t,p).. sum[z, s(
z,r,"0",t)] =e= 1;
73 NB28(r,p,t,q)$((ord(p) <> card(p)) AND ord(q) gt ord(p)).. sum(z, (q
* s(z,r,p,t)) - (p * s(z,r,p,t)) ) + [(p + lroommax ) * (1- sum (z, s(z,r
**** $148 $148 $148 $133
,p,t)))] =g= sum[z, lroom(z) * s(z,r,p,t)];
74 NB29(z,r,p,t)..

Does anybody know, how to fix the problem with the 148 error and the 133 error in the multiplication and addition sector?

Thanks for the help so far :-)
User avatar
Gideon Kruseman
User
User
Posts: 24
Joined: 6 years ago

Re: Multiplication and Addition with alias numbers and the error 148 & 133

Post by Gideon Kruseman »

Error 148 means that the the item has been declared with a different number of sets than you are using at that point. You have to be consistent.
Gideon Kruseman
ex-ante and foresight lead @CIMMYT, big data focal point @CIMMYT, coordinator CoP socio-economic data @CGIAR_BigData
gamser
User
User
Posts: 3
Joined: 6 years ago

Re: Multiplication and Addition with alias numbers and the error 148 & 133

Post by gamser »

Thanks for the answer so far!

I know what the error 148 means but I don´t know how to fix it just in the case of the multiplication and the Addition. The declaration of the variables works so far. The only upcoming Problem is in the mathematical Terms. For a better understanding you can find the data in the Appendix.

I hope that anybody knows an answer
Attachments
Mehrperiodige Layoutplanung FWLP_TW_TEST.gms
(4.27 KiB) Downloaded 326 times
gamser
User
User
Posts: 3
Joined: 6 years ago

Re: Multiplication and Addition with alias numbers and the error 148 & 133

Post by gamser »

I fixed the problems with the error 148! The only thing that is still missing is the Error 133 in the addition between p(t) and lroommax.

Does anyboy know an advice. Do they have to have the same unit?
User avatar
dirkse
Moderator
Moderator
Posts: 214
Joined: 7 years ago
Location: Fairfax, VA

Re: Multiplication and Addition with alias numbers and the error 148 & 133

Post by dirkse »

It looks like there is an asterisk (i.e. a '*') in the first column of one of the lines defining your equations. In other columns, a '*' can mean multiplication, but in the first column, it indicates that this line is a comment.

-Steve
Post Reply