how can I fix 149 uncontrolled set entered as constant

Problems with syntax of GAMS
Post Reply
alpzhan7
User
User
Posts: 4
Joined: 1 month ago

how can I fix 149 uncontrolled set entered as constant

Post by alpzhan7 » 1 month ago

hello

I have this situation in GAMS:

1 sets
2
3 i A B C quarries /1*3/
4 j number of factory /1*4/ ;
5
6 parameters
7
8 amount(j) the amount of iron that can be processed in a day in factory
9 /
10 1 40
11 2 60
12 3 20
13 4 80
14 /
15
16 w(i) daily amount of iron obtained from the quarries
17 /
18 1 100
19 2 40
20 3 60
21 / ;
22
23 table c(i,j) cost of transportation
24
25 1 2 3 4
26 1 7 8 7 12
27 2 8 7 9 13
28 3 10 6 7 12
29 ;
30
31 variable
32 z
33 x(i,j);
34
35 Positive variable
36 x;
37
38 Equations
39 Obj
40 Cons1(j)
41 Cons2(i);
42
43 Obj.. z=e=sum((i,j), c(i,j)*x(i,j));
44 Cons1(j).. sum(i, x(i,j)) =e= w(i);
**** $149
**** 149 Uncontrolled set entered as constant
45 Cons2(i).. sum(j, x(i,j)) =e= amount(j);
**** $149
**** 149 Uncontrolled set entered as constant


I searched,but I did not find solution. How can I fix it? and Can you fix it?

abhosekar
Moderator
Moderator
Posts: 176
Joined: 8 months ago

Re: how can I fix 149 uncontrolled set entered as constant

Post by abhosekar » 1 month ago

Looking at the constraint where you get the error.

Cons1(j).. sum(i, x(i,j)) =e= w(i);

The constraint is defined over j so j is known. The summation is defined over i so i is known (only on the left hand side). On the right hand side, GAMS does not know what is i and therefore, you get the error.

You have to check your constraint again. Both of the following are correct in terms of syntax

1. cons1(j).. sum(i, x(i,j)) =e= w(j);
2. cons1(i).. sum(j, x(i,j)) =e= w(i);

Hope it is clear now.

- Atharv

alpzhan7
User
User
Posts: 4
Joined: 1 month ago

Re: how can I fix 149 uncontrolled set entered as constant

Post by alpzhan7 » 1 month ago

But w(j) is not defineted

abhosekar
Moderator
Moderator
Posts: 176
Joined: 8 months ago

Re: how can I fix 149 uncontrolled set entered as constant

Post by abhosekar » 1 month ago

This is precisely why I told you to rethink your constraint. The way you have written the constraint does not make sense. What is w(i) in connection with that constraint? The constraint does not know i.
This is why I gave you two examples of what is acceptable.

Cons1(j).. sum(i, x(i,j)) =e= w(i);

Think about this in general terms. Do you want to write this constraint for each i or for each j?
To me, it looks like you want summation of certain things to be equal to w(i) in this case you should write your constraint for i by doing cons1(i).
But if you do just that, you will get an error for x(i, j) saying j is not under control.

Please understand your constraint first and then write it in GAMS.

- Atharv

Post Reply