Hi
I have a model in which profit should come 692.83 but I am getting 0. I am facing following issues in this model:
1) If I am initialising S[1,1] == 310 in the model as constraint then only model is working and it is able to find the optimal solutions and decision variables are also working fine but
without providing any initial solution as constraint, I am getting profit = 0 2) If Constraint 3 is formulated as Constraint 4 then also model is not working otherwise it is giving wrong solutions. However,
Constraint 3 and Constraint 4 are conceptually same. I am curious to know which is correct approach for formulation.
3) If I have defined my decision variables as dvar+ still if I am not giving profit >= 0 as a constraint in the model then I am getting profit as negative. Ideally, profit >= 0 should not come in constraint because it is an objective function.
I am attaching my .opl and .dat file. Please help me to resolve these issues
////.opl file
// Declaration of Data
int np = ...;
float B = ...;
int rawmaterial = ...;
range raw = 1..rawmaterial;
int R[raw] = ...;
range process = 1 .. np;
float l[process] = ...;
float m[process] = ...;
float h[process] = ...;
float il[process] = ...;
float im[process] = ...;
float ih[process] = ...;
float cl[process] = ...;
float cm[process] = ...;
float ch[process] = ...;
float raw_material [process][raw] = ...;
int productnumber = ...;
range PRODUCT = 1..productnumber;
{int} PRO[PRODUCT] = ...;
range ORDER = 1..4;
float saleprice[PRODUCT]= ...;
float Demand[PRODUCT][ORDER]=...;
int nbNNZdemand[o in ORDER]=sum(r in PRODUCT) (Demand[r,o]!=0);
float EP[t in PRODUCT]=max(p in PRO[t]) (h[p]);
// Declaration of Decision Variables
dvar float+ S[t in PRODUCT,o in ORDER];
dvar float+ Sale[o in ORDER];
dvar boolean Y[t in PRODUCT,o in ORDER];
dvar boolean Y1[t in PRODUCT,o in ORDER];
dvar boolean V[process];
dvar boolean Z[process];
dvar float+ X[p in process] in 0..h[p];
dvar float+ L[j in process] in 0..1;
dvar float+ M[j in process] in 0..1;
dvar float+ H[j in process] in 0..1;
dexpr float each_product[i in PRODUCT] = sum(j in PRO[i])X[j];
dexpr float raw_Constrant[t in raw] = sum(j in process)raw_material[j][t]*X[j];
dexpr float invst_Constrant = sum(j in process)(il[j]*L[j]+im[j]*M[j]+ih[j]*H[j]);
dexpr float PC = sum(j in process)(cl[j]*L[j]+cm[j]*M[j]+ch[j]*H[j]);
dexpr float profit = sum(o in ORDER) (Sale[o])- sum(j in process)(cl[j]*L[j]+cm[j]*M[j]+ch[j]*H[j]);
maximize profit;
subject to {
forall (j in process){
X[j] == l[j]*L[j] + m[j]*M[j] + h[j]*H[j];
L[j]<= V[j];
H[j]<=1-V[j];
L[j] + M[j] + H[j] == Z[j];
X[j] <= 100000*Z[j];
}
forall (t in raw){
raw_Constrant[t] <= R[t];
}
invst_Constrant <= B;
// Unique process constraint
forall(I in PRODUCT){
sum(j in PRO[I]) Z[j] <= 1;
}
forall(t in PRODUCT){
sum(s in PRO[t])X[s] >= sum(o in ORDER)S[t,o];
}
//S[1,1]==310;
//Demand Constraints
forall(o in ORDER,t in PRODUCT:Demand[t][o]>0){
S[t][o]>= Demand[t][o]=> Y[t][o]==1;
S[t][o]<= Demand[t][o]-0.0001 => Y[t][o]==0 ;
}
// Constraint 3
forall(o in ORDER,t in PRODUCT:Demand[t][o]==0){
Y[t][o]==0;
}
// Constraint 4
// forall(o in ORDER,t in PRODUCT:){
// Demand[t][o]==0 => Y[t][o]==0;
// }
forall(o in ORDER){
sum(t in PRODUCT)Y[t,o] == nbNNZdemand[o] => Sale[o]==sum(t in PRODUCT) (saleprice[t]*S[t,o]);
}
profit >= 0;
}
// Display
execute{
for(var p in process)
if(X[p]>0)
writeln(p,'-',X[p]);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
.dat
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
np = 54;
productnumber = 24;
rawmaterial = 2;
B = 1000;
R = [500,500];
SheetConnection CAPACITY("capacity.xlsx");
l from SheetRead(CAPACITY,"sheet1!A1:A54");
m from SheetRead(CAPACITY,"sheet1!B1:B54");
h from SheetRead(CAPACITY,"sheet1!C1:C54");
SheetConnection RAW("consumeraw.xlsx");
raw_material from SheetRead(RAW,"sheet1!A1:B54");
SheetConnection INVST("investment.xlsx");
il from SheetRead(INVST,"sheet1!A1:A54");
im from SheetRead(INVST,"sheet1!B1:B54");
ih from SheetRead(INVST,"sheet1!C1:C54");
SheetConnection PROD("production.xlsx");
cl from SheetRead(PROD,"sheet1!A1:A54");
cm from SheetRead(PROD,"sheet1!B1:B54");
ch from SheetRead(PROD,"sheet1!C1:C54");
PRO = [{ 1 2 3 } { 4 5 } { 6 7 } { 8 } { 9 } { 10 11 12 13 14 15} { 16 17 } { 18 } { 19 20 } { 21 22} { 23 24 25} { 26} { 27} { 28 29 30} { 31 32 33} { 34} { 35 36 37} { 38 39 40} { 41 42} { 43 44 45} { 46 47 48 49} { 50 51} { 52 } { 53 54}];
SheetConnection oF("DemandFile.xlsx");
Demand from SheetRead(oF,"sheet1!B2:E25");
saleprice from SheetRead(oF,"sheet1!F2:F25");
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
I am attaching all the files------------------------------
sandeep singh chauhan
------------------------------
#DecisionOptimization