Hi everyone,
This is Ratheesh here working on GAMS for my project work at my
university and I have modeled a problem and I am getting some errors
which I am unable to correct. This is my model. Could you please send
me the solution.
set i items /1*47/;
set j supermarkets/1,2/;
Table p(i,j) price of product i at market j
1 2
1 0.44 0.44
2 1.29 1.29
3 1.89 1.80
4 4.81 3.00
5 2.00 2.00
6 3.25 3.59
7 1.85 1.70
8 2.23 2.25
9 2.25 2.50
10 2.99 2.18
11 0.99 0.87
12 7.99 7.49
13 0.87 0.80
14 1.49 1.20
15 0.99 0.98
16 3.99 2.98
17 1.00 1.39
18 1.09 1.09
19 4.25 4.00
20 1.50 1.79
21 3.99 4.25
22 2.69 1.88
23 3.69 2.68
24 2.49 2.47
25 4.30 4.36
26 1.39 1.30
27 2.79 2.70
28 4.17 4.09
29 0.86 0.79
30 1.89 1.39
31 0.95 0.89
32 1.45 0.89
33 8.29 11.99
34 1.29 1.29
35 3.00 2.19
36 0.69 0.67
37 0.99 0.99
38 2.49 2.49
39 1.69 1.49
40 1.00 1.00
41 0.99 0.99
42 3.99 3.99
43 1.00 1.00
44 2.25 3.50
45 3.99 3.99
46 2.99 2.79
47 3.99 3.99;
Parameters
cb(i) carbohydrate content in food item i
/1 27.41
2 62.77
3 82.27
4 157.88
5 245.45
6 209.82
7 340.00
8 309.09
9 251.09
10 0
11 0
12 0
13 278.97
14 251.62
15 420.81
16 0
17 0
18 0
19 0
20 0
21 18.18
22 42.73
23 231.72
24 0.00
25 0.00
26 6.32
27 9.48
28 18.95
29 272.73
30 63.64
31 270.65
32 123.39
33 1299.55
34 16.20
35 431.82
36 42.45
37 18.18
38 46.25
39 79.09
40 4.60
41 25.91
42 0
43 0
44 0
45 0
46 317.06
47 0/;
Parameters
pr(i) Proteins content in food item i gm
/1 1.31
2 11.82
3 3.27
4 6.75
5 13.64
6 12.73
7 30.91
8 9.27
9 4.73
10 0
11 0
12 0
13 8.00
14 54.70
15 48.09
16 0
17 0
18 0
19 0
20 0
21 27.27
22 31.82
23 141.85
24 4.55
25 448.73
26 71.06
27 106.60
28 213.19
29 118.18
30 16.36
31 108.21
32 39.87
33 108.18
34 9.90
35 45.45
36 5.00
37 4.55
38 18.50
39 17.45
40 0.86
41 4.59
42 0
43 0
44 0
45 0
46 35.23
47 0/;
Parameters
er(i) Energy kcal
/1 21.60
2 236.36
3 313.64
4 600.00
5 981.82
6 836.36
7 1509.09
8 1181.82
9 945.45
10 0
11 0
12 0
13 266.00
14 1345.62
15 3.49
16 0
17 0
18 0
19 0
20 0
21 1554.55
22 554.55
23 2643.17
24 3259.09
25 3981.82
26 885.48
27 1328.22
28 2656.44
29 1604.55
30 281.82
31 0.00
32 738.00
33 5909.09
34 103.50
35 1750.00
36 181.82
37 81.82
38 231.25
39 340.91
40 20.00
41 109.09
42 0
43 0
44 0
45 0
46 1.53
47 0/;
Parameters
ft(i) Total Fat gm
/1 0.40
2 0.77
3 0.73
4 1.50
5 2.73
6 3.82
7 21.82
8 4.91
9 3.09
10 0
11 0
12 0
13 3.00
14 21.88
15 180.35
16 0
17 0
18 0
19 0
20 0
21 154.55
22 30.00
23 143.17
24 368.18
25 228.36
26 59.78
27 89.68
28 179.35
29 4.55
30 0.91
31 9.40
32 11.66
33 9.55
34 1.80
35 2.27
36 0.45
37 0.91
38 0.00
39 1.36
40 0.17
41 0.86
42 0
43 0
44 0
45 0
46 23.49
47 0/;
Parameters
vita(i) Vitamin A mcgm
/1 3.60
2 13.64
3 0.00
4 0.00
5 0.00
6 0.00
7 0.00
8 690.91
9 54.55
10 0
11 0
12 0
13 0.00
14 0.00
15 0.00
16 0
17 0
18 0
19 0
20 0
21 0.00
22 245.45
23 1233.48
24 3109.09
25 800.00
26 789.60
27 1184.40
28 2368.80
29 0.00
30 318.18
31 0.00
32 4.50
33 0.00
34 2110.50
35 0.00
36 0.00
37 0.00
38 0.00
39 0.00
40 0.00
41 0.00
42 0
43 0
44 0
45 0
46 0.00
47 0/;
Parameters
vitc(i) Vitamin C mg
/1 10.44
2 20.91
3 49.09
4 452.50
5 490.91
6 818.18
7 181.82
8 503.64
9 83.64
10 0
11 0
12 0
13 0.00
14 0.00
15 0.00
16 0
17 0
18 0
19 0
20 0
21 0.00
22 0.00
23 0.00
24 0.00
25 0.00
26 0.00
27 0.00
28 0.00
29 0.00
30 145.45
31 7.07
32 5.85
33 0.00
34 126.00
35 454.55
36 33.64
37 59.09
38 425.50
39 499.09
40 80.40
41 10.00
42 0
43 0
44 0
45 0
46 0.00
47 0/;
Parameters
vitk(i) Vitamin K mcgm
/1 0.00
2 0
3 100.00
4 0.00
5 0.00
6 0.00
7 0.00
8 0.00
9 0.00
10 0
11 0
12 0
13 3.10
14 0.00
15 0.00
16 0
17 0
18 0
19 0
20 0
21 0.00
22 0.00
23 0.00
24 0.00
25 0.00
26 0.00
27 0.00
28 0.00
29 0.00
30 0.00
31 0.00
32 18.00
33 0.00
34 2173.50
35 0.00
36 1.82
37 0.00
38 0.00
39 0.00
40 0.00
41 0.00
42 0
43 0
44 0
45 0
46 0.00
47 0/;
Parameters
sod(i) Sodium mg
/1 0.00
2 0
3 13.73
4 0.00
5 490.91
6 0.00
7 0.00
8 0.00
9 0.00
10 0
11 0
12 0
13 681.00
14 2882.69
15 4568.84
16 0
17 0
18 0
19 0
20 0
21 0.00
22 0.00
23 0.00
24 0.00
25 1218.18
26 0.00
27 0.00
28 0.00
29 0.00
30 0.00
31 260.87
32 31.50
33 0.00
34 0.00
35 136.36
36 0.00
37 0.00
38 0.00
39 0.00
40 0.00
41 0.00
42 0
43 0
44 0
45 0
46 2113.71
47 0/;
Parameters
cal(i) Calcium mg
/1 6.00
2 27.27
3 45.45
4 162.50
5 0.00
6 781.82
7 181.82
8 181.82
9 109.09
10 0
11 0
12 0
13 151.00
14 0.00
15 0.00
16 0
17 0
18 0
19 0
20 0
21 0.00
22 1100.00
23 4977.97
24 0.00
25 0.00
26 282.00
27 423.00
28 846.00
29 0.00
30 336.36
31 385.87
32 220.50
33 136.36
34 445.50
35 272.73
36 104.55
37 0.00
38 203.50
39 545.45
40 10.00
41 40.91
42 0
43 0
44 0
45 0
46 0.00
47 0/;
Parameters
irn(i) Iron mg
/1 0.31
2 0.55
3 1.64
4 3.50
5 0.00
6 1.64
7 5.45
8 2.36
9 2.18
10 0
11 0
12 0
13 3.74
14 0.00
15 0.00
16 0
17 0
18 0
19 0
20 0
21 0.00
22 0.00
23 0.00
24 0.00
25 21.09
26 6.77
27 10.15
28 20.30
29 34.09
30 0.00
31 45.16
32 13.01
33 67.73
34 12.15
35 40.91
36 0.95
37 0.00
38 4.07
39 6.41
40 0.34
41 1.09
42 0
43 0
44 0
45 0
46 0.00
47 0/;
variables z;
integer variables x(i);
binary variables t(i,j),tck;
Equations
obj,eq1,eq2,eq3,eq4 ,eq5 ,eq6 ,eq7 ,eq8 ,eq9 ,eq10 ,eq11 ,eq12 ,eq13 ,eq14 ,eq15 ,eq16 ,eq17 ,eq18(i),eq19(i),eq20(i),eq21(i),eq22(i),eq23(i),eq24(i),eq25(i),eq26(i),eq27(i),eq28(i),eq29(i),eq30(i),eq31(i),eq32(i),eq33(i),eq34(i),eq35(i),eq36(i),eq37(i),eq38(i),eq39(i),eq40(i),eq41(i),eq42(i),eq43(i),eq44(i),eq45(i),eq46(i),eq47(i),eq48(i),eq49(i),eq50(i),eq51(i),eq52(i),eq53(i),eq54(i),eq55(i),eq56(i);
- Carbohydrate
eq1 … sum((i,j),t(i,j)*x(i)*cb(i))=g=4550;
eq2 … sum((i,j),t(i,j)*x(i)*cb(i))=l=12285; - Protein
eq3 … sum((i,j),t(i,j)*x(i)*pr(i))=g=1960;
eq4 … sum((i,j),t(i,j)*x(i)*pr(i))=l=3955; - Fat
eq5 … sum((i,j),t(i,j)*x(i)*ft(i))=g=2485;
eq6 … sum((i,j),t(i,j)*x(i)*ft(i))=l=2625;
*Vit A
eq7 … sum((i,j),t(i,j)*x(i)*vita(i))=g=26250;
eq8 … sum((i,j),t(i,j)*x(i)*vita(i))=l=31500;
eq9 … sum((i,j),t(i,j)*x(i)*vitc(i))=g=2100;
eq10 … sum((i,j),t(i,j)*x(i)*vitc(i))=l=3150;
eq11 … sum((i,j),t(i,j)*x(i)*vitk(i))=g=4200;
eq12 … sum((i,j),t(i,j)*x(i)*sod(i))=g=52500;
eq13 … sum((i,j),t(i,j)*x(i)*sod(i))=l=84000;
eq14 … sum((i,j),t(i,j)*x(i)*cal(i))=g=14000;
eq15 … sum((i,j),t(i,j)*x(i)*cal(i))=l=35000;
eq16 … sum((i,j),t(i,j)*x(i)*irn(i))=g=210;
eq17 … sum((i,j),t(i,j)*x(i)*irn(i))=l=630;
*Constaint which ensures that any item should be bought from only one
of the market and not both
eq18(i) … sum(j,t(i,j))=l=1;
*constraint which ensures that if an item is bought then its least
quantity is bought
*eq19(i) … x(i)=g=t(i,j);
-
Constraint 2
eq20(i) … sum(j,t(‘10’,j)+t(‘11’,j))=g=sum(j,t(‘12’,j)); -
Constraint 3
eq21(i) … x(‘13’)+x(‘14’)=l=3;
eq22(i) … sum(j,t(‘13’,j)+t(‘14’,j))=g=1;
eq23(i) … x(‘13’)+x(‘14’)=g=2; -
C3onstraint 4
eq24(i) … sum(j,t(‘15’,j)+t(‘47’,j))=g=1; -
Constraint 6
eq25(i) … sum(j,t(‘21’,j)*x(‘21’))=g=sum(j,t(‘13’,j)*x(‘13’)
+t(‘14’,j)*x(‘14’)); -
Constraint 7
eq26(i) … sum(j,t(‘35’,j))=g=sum(j,t(‘34’,j)); -
Constraint 8
eq27(i) … sum(j,t(‘36’,j)*x(‘36’))=g=15;
eq28(i) … sum(j,t(‘37’,j)*x(‘37’))=g=15; -
Constraint 9
eq29(i) … sum(j,t(‘29’,j)+t(‘30’,j)+t(‘31’,j)+t(‘32’,j))=e=2; -
Constraint 10
eq30(i) … sum(j,t(‘38’,j)+t(‘39’,j))=l=1; -
Constraint 12
eq31(i) … sum(j,t(‘42’,j)+t(‘43’,j)+t(‘44’,j)+t(‘45’,j))=g=2;
eq32(i) … sum(j,t(‘42’,j)+t(‘43’,j)+t(‘44’,j)+t(‘45’,j))=l=3; -
Constraint 13
eq33(i) … sum(j,t(‘42’,j)+t(‘45’,j))=g=1; -
Constraint 14
eq34(i) … sum(j,t(‘42’,j)+t(‘43’,j))=l=1; -
Constraint 15
eq35(i) … sum(j,t(‘1’,j)+t(‘2’,j)+t(‘3’,j)+t(‘4’,j)+t(‘5’,j))=l=4;
eq36(i) … sum(j,t(‘1’,j)+t(‘2’,j)+t(‘3’,j)+t(‘4’,j)+t(‘5’,j))=g=3; -
Constraint 16
eq37(i) … sum(j,t(‘1’,j)+t(‘4’,j))=l=1; -
Constraint 17
*eq38(i) … sum(j,t(‘4’,j) -
Constraint 18
eq39(i) … sum(j,t(‘2’,j)+t(‘9’,j))=e=1; -
Constraint 19
eq40(i) … sum(j,t(‘35’,j)+t(‘36’,j)+t(‘37’,j)+t(‘38’,j)
+t(‘39’,j))=l=sum(j,t(‘24’,j))+4;
eq41(i) … sum(j,t(‘24’,j))=l=sum(j,t(‘35’,j));
eq42(i) … sum(j,t(‘24’,j))=l=sum(j,t(‘36’,j));
eq43(i) … sum(j,t(‘24’,j))=l=sum(j,t(‘37’,j));
eq44(i) … sum(j,t(‘24’,j))=l=sum(j,t(‘38’,j)); -
Constraint 20
eq45(i) … sum(j,t(‘3’,j)+t(‘6’,j))=g=1; -
Constraint 21
eq46(i) … sum(j,t(‘6’,j)+t(‘7’,j)+t(‘8’,j)+t(‘9’,j))=g=1; -
Constraint 22 23
eq47(i) … sum(j,t(‘47’,j))+tck=e=1;
eq48(i) … x(‘23’)=e=2+tck; -
Constraint 24
eq49(i) … sum(j,t(‘15’,j)+t(‘16’,j)+t(‘17’,j)+t(‘18’,j)+t(‘19’,j)
+t(‘20’,j))=g=4; -
Constraint 26
eq50(i) … sum(j,t(‘34’,j)+t(‘35’,j)+t(‘36’,j)+t(‘37’,j)+t(‘38’,j)
+t(‘39’,j)+t(‘40’,j)+t(‘41’,j))=g=5; -
C0onstraint 29
eq51(i) … sum(j,t(‘21’,j))=e=1;
eq52(i) … sum(j,t(‘22’,j))=e=1;
eq53(i) … sum(j,t(‘23’,j))=e=1;
eq54(i) … sum(j,t(‘25’,j))=e=1; -
Constraint 30
eq55(i) … x(‘15’)=l=1; -
Constraint 31
eq56(i) … sum(j,t(‘10’,j)+t(‘11’,j)+t(‘12’,j))=g=1; -
Constraint
*eq(i) … -
Constraint
*eq(i) …
obj … z=e=sum((i,j),x(i)*p(i,j));
Model NutProb/all/;
Solve NutProb using mip minimizing z;
Errors- 56-endogenous error
71-symbolic eqn.
Would appreciate it if you could help with oit as soon as possible.
Sincerely,
Ratheesh Jagadish
\