Reputation: 844
My decision variable, which is to be minimized is this:
DV2 = { "P1" : {"V1" : 38.11, "V2" : 21.47, "V3" : 27.98, "V4" : 24.95, "V5" :25.22},
"P2" : {"V1" : 31.10355934, "V2" : 34.20506007, "V3" : 30.46890595, "V4" : 33.74346353, "V5" : 29.47098217},
"P3" : {"V1" : 29.13518894, "V2" : 38.89035574, "V3" : 30.97508704, "V4" : 33.50849106, "V5" : 34.94861333}
}
It is similar to the transportation problem except, the objective function will be: 0.71*cost*DV2 + 0.29*risk*DV2, where cost is :
cost= { "P1" : {"V1" : 0.2, "V2" : 0.22, "V3" : 0.2, "V4" : 0.2, "V5" :0.17},
"P2" : {"V1" : 0.2, "V2" : 0.21, "V3" : 0.19, "V4" : 0.19, "V5" : 0.19},
"P3" : {"V1" : 0.19, "V2" : 0.19, "V3" : 0.2, "V4" : 0.19, "V5" : 0.2}
}
And risk is:
risk= { "P1" : {"V1" : 0.5, "V2" : 0.52, "V3" : 0.25, "V4" : 0.25, "V5" :0.57},
"P2" : {"V1" : 0.5, "V2" : 0.51, "V3" : 0.9, "V4" : 0.9, "V5" : 0.9},
"P3" : {"V1" : 0.6, "V2" : 0.6, "V3" : 0.7, "V4" : 0.8, "V5" : 0.9}
}
lowBound will be:
min1= { "P1" : {"V1" : 500, "V2" : 500, "V3" : 500, "V4" : 0, "V5" :500},
"P2" : {"V1" : 500, "V2" : 0, "V3" : 500, "V4" : 500, "V5" : 0},
"P3" : {"V1" : 500, "V2" : 500, "V3" : 500, "V4" : 500, "V5" : 500}
}
upBound will be:
max1= { "P1" : {"V1" : 5000, "V2" : 5000, "V3" : 5000, "V4" : 0, "V5" :5000},
"P2" : {"V1" : 5000, "V2" : 0, "V3" : 5000, "V4" : 5000, "V5" : 0},
"P3" : {"V1" : 5000, "V2" : 5000, "V3" : 5000, "V4" : 5000, "V5" : 5000}
}
Will be very grateful if somebody could show me how to formulize the objective function in this scenario, since lowBound and upBound are supposed to take real numbers only(this is the error I'm getting).
Upvotes: 1
Views: 983
Reputation: 16797
For scalar bounds:
L = 1.0
U = 2.0
x = LpVariable.dicts("x",J,L,U,LpContinuous)
For indexed bounds use constraints:
L = {"a": 0.2, "b" : 0.3}
U = {"a": 1.2, "b" : 1.3}
for j in J:
prob += x[j] >= L[j]
prob += x[j] <= U[j]
The LP/MIP solver will internally make bounds from singleton constraints in the presolve phase.
Upvotes: 1