Reputation: 825
I have this equation
-0.19430381*clo + 0.02507341*vam + 0.13574366*sla + 0.01667444*so = 10
I need to find the minimum values of clo, vam, sla and so that will solve this equation. I have used PuLP to find the values.
# declare your variables
clo = LpVariable("clo", 65, 80)
vam = LpVariable("vam", 63, 90)
sla = LpVariable("sla", 70, 80)
so = LpVariable("so", 75, 85)
# defines the problem
prob = LpProblem("problem", LpMinimize)
The objective function and constraints are written as
# defines the objective function to minimize
prob += -0.19430381*clo + 0.02507341*vam + 0.13574366*sla + 0.01667444*so-10
#define Constraints
prob+= clo>=65
prob+= clo<=80
prob+= vam>=63
prob+= vam<=90
prob+= sla>=71
prob+= sla<=80
prob+= so>=75
prob+= so<=85
When I solve using default solver, it is taking the upper bound value of 80 for clo while it is taking lower bound value for all other variables. The objective function value is negative.
print (pulp.value(prob.objective))
-13.21204077
I want this objective function value to be 0. In such scenarios I need to find the value of all the parameters. The value of the parameters can be in float too.
Upvotes: 1
Views: 2332
Reputation: 5429
The problem as described is infeasible.
You'd like to achieve the following equality constraint:
-0.19430381*clo + 0.02507341*vam + 0.13574366*sla + 0.01667444*so == 10
Subject to the following upper and lower bounds of the variables:
clo = LpVariable("clo", 65, 80)
vam = LpVariable("vam", 63, 90)
sla = LpVariable("sla", 70, 80)
so = LpVariable("so", 75, 85)
Looking at the equality constraint if we want to make the right-hand-side as large as possible subject to the constraint bounds we would pick vam, sla, so
as large as possible, and clo
as small as possible (as it has negative coefficient on left-hand-side).
Setting: clo=65; vam=90; sla=80; so=85
we get the result of the left-hand-side of the equality constraint as: 1.9036794499999987
. Any other combination of values (within upper/lower bounds) will result in a smaller left-hand side - so the equality constraint cannot be satisfied, it will never equal the required right-hand-side of 10.
Upvotes: 4