I am trying to formulate an MIP model in which a transportation can be performed by available trains or new ship investments. My current code includes three tables: Monthly costs for trains, monthly costs for ships and initial investment costs for ships.
It raises the following error n149 at the "cost.. z =e=" line: Uncontrolled set entered as constant. Also errors with codes 257 and 141 are raised at the 56th and 57th rows, respectively.
Sets
i supply nodes /Plant1, Plant2, Plant3, Plant4/
j demand nodes /City1, City2, City3, City4, City5, Dummy/;
Parameters
a(i) supply capacities
/Plant1 290
Plant2 220
Plant3 180
Plant4 280/
b(j) demands
/City1 180
City2 200
City3 160
City4 140
City5 250
Dummy 40/;
Table c1(i,j) transport costs for trains
City1 City2 City3 City4 City5 Dummy
Plant1 8.5 7 8 6.5 9 0
Plant2 7.5 8 7 10 8.5 0
Plant3 11 6 6.5 8 7 0
Plant4 9 7 12 6 7.5 0 ;
Table c2(i,j) transport costs for ships
City1 City2 City3 City4 City5 Dummy
Plant1 5.5 6 99999 3.5 4 0
Plant2 3 4.5 4 6.5 6 0
Plant3 99999 99999 3 4 4.5 0
Plant4 5 4.5 7 3 99999 0 ;
Table in(i,j) investment costs for ships
City1 City2 City3 City4 City5 Dummy
Plant1 40 90 99999 40 80 0
Plant2 60 40 80 20 40 0
Plant3 99999 99999 80 60 100 0
Plant4 100 60 60 80 99999 0 ;
Positive Variables
x(i,j) flow between supply node i and demand node j;
Variables
y(i,j) whether a ship is bought for the trasfer from i to j
z total cost;
Binary Variables y;
Equations
cost objective function
supply(i) supply constraint
demand(j) demand constraint;
cost.. z =e= sum((i,j), c1(i,j)*x(i,j)*12*10*(1-y(i,j)) + c2(i,j)*x(i,j)*12*10*y(i,j)) + in(i,j)*y(i,j);
supply(i).. sum(j, x(i,j)) =l= a(i);
demand(j).. sum(i, x(i,j)) =g= b(j);
Model homework1c /all/;
homework1c.OPTFILE=1;
Solve homework1c using MIP minimizing z;
Display x.l, x.M, y.l;
I would appreciate any suggestions to fix them, thanks in advance.
I see two issues:
i
and j
in + in(i,j)*y(i,j)
at the end of your cost
equation is not controlled. Was this term supposed to be part of the sum
over i
and j
?MIP
(which should be linear) but multiply the variable x
with variable y
. So, you need to solve a MINLP
or reformulate your cost
equation.