mathoptimizationmathematical-optimizationmodelinggams-math

Minimizing the workflow and distance between department and stations


I wrote code for a project. But line 96 has too many errors. The aim of my project is to minimize material flow and distance between departments and stations in a factory. Obviously, the aim is to reduce the time loss in the material flow by changing the factory layout. But the most critical point is that departments and stations only switch places among themselves. i.e. department 1 and department 4 can be swapped, or station 3 and station 10. but Department 3 and Station 5 cannot be swapped. Please help me!

SETS
    i departments /1*6/
    j stations /1*10/
    m departments2 /1*6/
    n stations2 /1*10/ ;

PARAMETERS
    Table
    Workflow(i, j) Workflow matrix
     1   2   3   4   5   6   7   8   9   10
1    1   1   3   3   3   3   0   4   5   3
2    4   6   5   7   6   6   8   9   7   6
3    1   0   5   4   1   0   0   6   6   5
4    5   8   5   6   7   0   0   1   1   6
5    3   0   4   0   0   0   0   5   6   5
6    3   4   3   0   5   0   4   10  9   4;

PARAMETERS
    Table
    Distance(m, n) Distance matrix
       1   2    3   4   5   6   7   8   9   10
1     35   47  61  74  81  97  111 125 137  55
2     68   86  90  98  104 103  79  78  90  67
3    312  323 335 344 358 367 377 393 414 318
4     72   83  95  106 118 128 136 151 173 57
5    116   0   97   0   0   0   0   39  28  193
6     83   87  69  0   52  0   18  17  12  171;

VARIABLES
    y(m, n) Binary variables
    a(j, n) Binary variables
    b(i, m) Binary variables
    z Objective function;

BINARY VARIABLES
    Q(i, j, m, n);

EQUATIONS
    c1(n)
    c2(j)
    c3(i, j, m, n)
    c4(i, j, m, n)
    c5(i, j, m, n)
    c6(i)
    c7(m)
    c8(i, j, m, n)
    t1(n)
    t2(n)
    t3(n)
    t4(n)
    t5(n)
    t6(n)
    t7(n)
    t8(n)
    t9(n)
    t10(n)
    k1(m)
    k2(m)
    k3(m)
    k4(m)
    k5(m)
    k6(m);
    
c1(n).. sum(j, a(j, n)) =e= 1;
c2(j).. sum(n, a(j, n)) =e= 1;
c6(i).. sum(m, b(i, m)) =e= 1;
c7(m).. sum(i, b(i, m)) =e= 1;

c3(i, j, m, n).. Q(i, j, m, n) =l= a(j, n);
c8(i, j, m, n).. Q(i, j, m, n) =l= b(i, m);

c4(i, j, m, n).. Q(i, j, m, n) =l= y(m, n);
c5(i, j, m, n).. Q(i, j, m, n) =g= a(j, n) + y(m, n) + b(i, m) - 1;

t1(n).. sum((i, j, m), Q(i, j, m, n)) =e= 1;
t2(n).. sum((i, j, m), Q(i, j, m, n)) =e= 1;
t3(n).. sum((i, j, m), Q(i, j, m, n)) =e= 1;
t4(n).. sum((i, j, m), Q(i, j, m, n)) =e= 1;
t5(n).. sum((i, j, m), Q(i, j, m, n)) =e= 1;
t6(n).. sum((i, j, m), Q(i, j, m, n)) =e= 1;
t7(n).. sum((i, j, m), Q(i, j, m, n)) =e= 1;
t8(n).. sum((i, j, m), Q(i, j, m, n)) =e= 1;
t9(n).. sum((i, j, m), Q(i, j, m, n)) =e= 1;
t10(n).. sum((i, j, m), Q(i, j, m, n)) =e= 1;


k1(m).. sum((n, i,j), Q(i, j, m, n)) =e= 1;
k2(m).. sum((n, i,j), Q(i, j, m, n)) =e= 1;
k3(m).. sum((n, i,j), Q(i, j, m, n)) =e= 1;
k4(m).. sum((n, i,j), Q(i, j, m, n)) =e= 1;
k5(m).. sum((n, i,j), Q(i, j, m, n)) =e= 1;
k6(m).. sum((n, i,j), Q(i, j, m, n)) =e= 1;



min.. z =e= sum((i, j, m, n), workflow(i, j) * Distance(m, n) * Q(i, j, m, n));


Model Layout /all/;
Solve Layout using RMIP minimizing z;

There are so many errors and didnt work.


Solution

  • On a general note, I'd suggest to look at the first error only, as subsequent ones often go away after fixing previous ones. Your first error is:

      96  min.. z =e= sum((i, j, m, n), workflow(i, j) * Distance(m, n) * Q(i, j, m, n));
    ****    $168
    **** 168  Assignment not allowed to this identifier
    

    The problem is, that min is a keyword which you cannot assign to. This can easily be fixed if you change it to something like this:

    equation obj;
    obj.. z =e= sum((i, j, m, n), workflow(i, j) * Distance(m, n) * Q(i, j, m, n));
    

    That change actually resolves all your compilation errors.

    The model still is infeasible, so you might need to check your model formulation and data.