Dear Sebastian,
Thanks for your reply.
I am sorry if the question was not clear. Actually, my main question is about the modelling of the first constraint where S(k,t-1) should be defined.
As per your question, yes, I expect both models deliver the same solution but, the results are different. I used to code the inventory problems in GAMS and they worked fine but in this case, I think it comes back to the definition of the initial inventory based on its related index, s(k,t-1) in the CPLEX Studio.
I was wondering if, is my first constraint code correct? (please, note that I see the sailco example to benchmark).
/***
// Decision variables
dvar float+ x[products][horizons];
dvar float+ s[products][Periods];
forall(k in products, t in horizons)
c1:
s[k][t-1] + x[k][t] == d[k][t] + s[k][t];
***/
Regards
------------------------------
Abbas Omidi
------------------------------
Original Message:
Sent: Thu November 26, 2020 09:34 AM
From: Sebastian Fink
Subject: Modeling issue with OPL-CPLEX
Hi,
I'm not sure if you posted an incomplete OPL model or you are missing
(1) the objective function,
(2) the bigM constraint that links x_kt and y_kt, and
(3) the constraint that bounds sum_(k in K) (e_k * s_kt) <= C
compared to the model in the embedded picture.
Regarding your question - did you expect both models to deliver the same solution (I'd assume so, but it doesn't look like it)? If so, are you sure the optimal solution to your problem is unique?
When trying to debug models it's usually a good idea to start small and easy with both, the model and the data, and work your way towards the full model and dataset step by step.
Good luck.
------------------------------
Sebastian Fink
Original Message:
Sent: Mon November 16, 2020 10:53 AM
From: Abbas Omidi
Subject: Modeling issue with OPL-CPLEX
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 variablesdvar float+ x[products][horizons];dvar float+ s[products][Periods];dvar int+ y[products][horizons] in 0..1;// Constraintssubject 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 variablesp/h 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 201 34 73 68 0 75 25 177 0 0 74 126 0 59 98 96 184 0 15 80 02 2 19 49 34 173 0 110 0 0 90 141 0 117 0 26 41 70 34 71 503 34 10 59 162 0 72 0 63 116 0 98 73 13 93 0 124 0 58 54 664 12 0 82 122 0 30 122 0 23 28 0 12 36 89 32 151 0 66 35 905 0 18 71 68 79 146 0 20 10 95 14 11 87 0 76 155 0 0 25 12======================================* S variablesp/h 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 201 20 0 0 56 0 0 0 95 34 0 0 91 0 0 0 0 92 0 0 58 02 46 0 0 0 0 95 0 51 17 0 0 64 0 100 0 0 0 0 0 0 03 36 0 0 0 78 0 31 0 0 83 0 0 0 0 49 0 84 0 0 0 04 53 22 0 0 69 0 0 57 0 0 15 0 0 0 0 0 100 0 0 0 05 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 t201 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.0002 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.0003 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.0004 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.0005 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 t191 20.000 56.000 95.000 34.000 91.000 92.000 58.0002 46.000 95.000 51.000 17.000 64.000 100.0003 36.000 78.000 31.000 83.000 49.000 84.0004 53.000 22.000 69.000 57.000 15.000 100.0005 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