Dear community team,
I'm trying to solve a basic inventory optimization problem (MILP) with OPL-CPLEX12.9. The problem is as follows:
Where, S, X and Y is positive, positive and binary variables respectively.
I have coded the problem in the following form:
/***
* The snippet code
***/
// Sets
{int} products = ...;
{int} horizons = ...;
range Periods = 0..card(horizons);
*
*
*
// Decision variables
dvar float+ x[products][horizons];
dvar float+ s[products][Periods];
dvar int+ y[products][horizons] in 0..1;
// Constraints
subject to {
forall(k in products, t in horizons)
c1:
s[k][t-1] + x[k][t] == d[k][t] + s[k][t];
forall(k in products)
c2:
s[k][0] == a[k];
When the problem is solved the results are:
* X variables
p/h 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1 34 73 68 0 75 25 177 0 0 74 126 0 59 98 96 184 0 15 80 0
2 2 19 49 34 173 0 110 0 0 90 141 0 117 0 26 41 70 34 71 50
3 34 10 59 162 0 72 0 63 116 0 98 73 13 93 0 124 0 58 54 66
4 12 0 82 122 0 30 122 0 23 28 0 12 36 89 32 151 0 66 35 90
5 0 18 71 68 79 146 0 20 10 95 14 11 87 0 76 155 0 0 25 12
======================================
* S variables
p/h 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1 20 0 0 56 0 0 0 95 34 0 0 91 0 0 0 0 92 0 0 58 0
2 46 0 0 0 0 95 0 51 17 0 0 64 0 100 0 0 0 0 0 0 0
3 36 0 0 0 78 0 31 0 0 83 0 0 0 0 49 0 84 0 0 0 0
4 53 22 0 0 69 0 0 57 0 0 15 0 0 0 0 0 100 0 0 0 0
5 64 18 0 0 0 0 62 0 0 0 0 0 0 74 0 0 77 54 0 0 0
Before that, I solved the problem using GAMS/CPLEX12.9 and the results were:
---- 73 VARIABLE x.L
t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20
1 54.000 73.000 68.000 75.000 25.000 177.000 74.000 126.000 59.000 98.000 96.000 184.000 15.000 80.000
2 48.000 19.000 49.000 34.000 173.000 110.000 90.000 141.000 117.000 26.000 41.000 70.000 34.000 71.000 50.000
3 70.000 10.000 59.000 162.000 72.000 63.000 116.000 98.000 73.000 13.000 93.000 124.000 58.000 54.000 66.000
4 65.000 82.000 122.000 30.000 122.000 23.000 28.000 12.000 36.000 89.000 32.000 151.000 66.000 35.000 90.000
5 46.000 36.000 71.000 68.000 79.000 146.000 20.000 10.000 95.000 14.000 11.000 87.000 76.000 155.000 25.000 12.000
---- 73 VARIABLE s.L
t0 t1 t3 t4 t5 t6 t7 t8 t9 t10 t11 t13 t14 t16 t17 t19
1 20.000 56.000 95.000 34.000 91.000 92.000 58.000
2 46.000 95.000 51.000 17.000 64.000 100.000
3 36.000 78.000 31.000 83.000 49.000 84.000
4 53.000 22.000 69.000 57.000 15.000 100.000
5 64.000 62.000 74.000 77.000 54.000
Would you say please, is above code correct? if no, where I'm wrong?
------------------------------
Best regards
Abbas Omidi
------------------------------
#DecisionOptimization