Reputation: 2725
I have built a pretty complex MIP in Python PuLP
. Obviously a bit too complex for me. When I run it it gives the following Warning:
UserWarning: Overwriting previously set objective. warnings.warn("Overwriting previously set objective.")
The problem performs some calculations but does not come to the expected solution.
The LpStatus[prob.status]
returns Optimal
The prob.objective
returns None
When I print the prob.variables()
with
for v in prob.variables():
print(v.name, "=", v.varValue)
I get __dummy = None
in between the other variables.
Can anyone explain what the __dummy = None
means in this context? Where could I look for a solution? I was pretty sure that I have only one objective function.
Upvotes: 3
Views: 4067
Reputation: 2725
Alright, I found the solution. I indeed overwrote the objective function without noticing it.
Here is the piece of code that caused the warning:
for i in range(len(items)):
for l in range(L):
prob += delta[0-l] == 0
the delta variable is a list of lists. The first index was missing, the program therefore compared a list with a zero. Since this is not possible, the equation always returns false (maybe coded as zero) which was then interpreted as an objective function.
This solved the issue:
for i in range(len(items)):
for l in range(L):
prob += delta[i][0-l] == 0
Now it adds equations instead of values to the prob.
I hope this helps anyone encountering a similar problem.
Upvotes: 10