Syntax error

Problems with syntax of GAMS
Post Reply
nasim
User
User
Posts: 8
Joined: 2 years ago

Syntax error

Post by nasim » 2 years ago

Hello
I m writing a simple farm profit maximization model. I wrote the simple form and I got the answer which means that the model works, but when I used set notation to define variables I got many Syntax errors. Below is the model. would you please help me? I cannot understand where is the problem.


option sysout=off;

sets
i "option" /p,b,s,d/
j "products" /c,l,m/
k "type of product" /1,2,3,4,5,6,7,8,9,10,11,12,13,14/;

Alias (i,ii,iii)

variables
z total farm profit
x(i,j,k) amount of produced bought sold or distributed of each type of crop livestock or manure;

parameters
y(k) profit of each crop type/

"1" 937.45
"2" 9712.7
"3" 1011.43
"4" 10156.57
"5" 1085.41
"6" 10600.44
"7" 1140.89
"8" 10933.34
"9" 1002.13
"10" 118.03
"11" 484.42
"12" 365.39
"13" 532.91
"14" 0
/

equations

OBJ
land1
land2
machin1
machin2
machin3
machin4
livestock1
livestock2
feeding1
feeding2
feeding3
feeding4
rotation1
rotation2
rotation3
rotation4
rotation5
disposal1
disposal2
disposal3
spreading1
spreading2
spreading3;

OBJ..z=E= sum(k, x(p,c,k)* y(k)) + 1849*x(p,l,1)+ 53854*x(p,l,2)- 258.5*x(b,c,1) - 258.5*x(b,c,2) - 205.7*x(b,c,9) +15.70*x(s,m,3) -3.374*x(d,m,1) - 6.90*x(d,m,2);
land1.. sum(k$ x(p,c,k) lt14 ,x(p,c,k))=L=400;
land2.. x(p,c,14)=L=23;
.
.
.
the errors show problem with the firm line of OBJ function!!

Thank you so much

User avatar
Renger
Posts: 383
Joined: 3 years ago

Re: Syntax error

Post by Renger » 2 years ago

Hi
If you write x(p,c,k), you probably mean x("p", "c",k). If you want to use specific set elements in an expression, you should use it like shown.
Cheers
Renger
____________________________________
Enjoy modeling even more: The lazy economist

Post Reply