gams error

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

gams error

Post by alpzhan7 » 2 months ago

sets
i unsweetened coke /1*5/
j sweetened coke /1*5/;

parameter
demand (j) demand for coke
/ 1 1000
2 1500
3 1250
4 1600
5 1350/;

parameter
rmCaffeine (i) Caffeine ratio of type I raw material
/ 1 24
2 12
3 16
4 20
5 28/;

parameter
rmAcesulfamePotassium (i) Acesulfame Potassium ratio of type I raw material
/ 1 2
2 4
3 6
4 8
5 10/;


parameter
rmCost (i) Purchase price of raw material type I
/ 1 2
2 3
3 4
4 5
5 6/;

parameter
Caffein (j) Caffeine grade of type j cola
/ 1 70
2 80
3 60
4 75
5 74/;

parameter
AcesulfamePotassium (j) Acesulfame Potassium grade of type j cola
/ 1 20
2 25
3 15
4 12
5 8/;

parameter
Salescost (j) Sale price of type j cola.
/ 1 3
2 6
3 9
4 12
5 15/;


positive variable x(i,j);
* i. unsweetened coke j. sweetened coke
positive variable r(j);
* j. marketing coke
variable z;
* total profit
scalar f/20/;
*$1 ad increases demand by 20 units

equations
profit function
supply(j) the constraint established on meeting the demand
Caffein(j) caffeine restriction
AcesulfamePotassium(j) acesulfame potassium restriction;

profit.. z=e=sum((i,j), Salescost(j)*x(i,j))-sum(i,j), ((rmCost(i)*x(i,j)-r(j))));
supply(j).. sum((i), (x(i,j))) :=1= (demand(j)+(f*r(j)));
Caffein(j).. sum((i), (Caffein(j)*x(i,j))) :=1= sum((i), (rmCaffein(i)*x(i,j)));
AcesulfamePotassium(j).. sum((i), (AcesulfamePotassium(j)*x(i,j))) =1= sum((i), (rmAcesulfamePotassium(i)*x(i,j)));

model newcoke /all/;
solve newcoke using lp maximizing z;
Display Z.L , X.L;

How can I fix errors?? help me please

abhosekar
Moderator
Moderator
Posts: 190
Joined: 10 months ago

Re: gams error

Post by abhosekar » 2 months ago

Please use code blocks to post your codes. Further, please follow the error message to resolve your errors. The error messages are usually informative.

There are many issues with your code.

1. You are defining Caffein as a parameter as well as equation which is not allowed. You have to rename one of the two.
2. same error with AcesulfamePotassium
3. You are using =1= instead of =l=

Please follow GAMS tutorials. Usually making up your own syntax does not work.

- Atharv

Post Reply