Reputation: 9865
When I am running a very simple problem, I occasionally get this error from the ipopt
solver: No such file or directory: '/var/folders/4f/z25gj3_d29b45_2nx87p8rvr0000gn/T/tmpwMeEAK.pyomo.sol'
. This time I see it, I really want to figure out why this is the case.
Here is my model with very basic constraints and objective function:
cm=ConcreteModel()
a = Var([1,2], [0,1,2,3], domain=Reals)
b = Var([1,2], [0,1,2,3], domain=Reals)
c = Var([0,1,2,3], domain=Reals)
cm.q = a
cm.p = b
cm.u = c
cm.end_a_1 = Constraint(expr=(a[1,3] == 1.0))
cm.end_b_2 = Constraint(expr=(b[2,3] == 0.0))
cm.end_a_2 = Constraint(expr=(a[2,3] == 1.0))
cm.start_a_2 = Constraint(expr=(a[2,0] == 0.0))
cm.start_a_1 = Constraint(expr=(a[1,0] == 1.0))
cm.start_b_2 = Constraint(expr=(b[2,0] == -11.0))
cm.start_b_1 = Constraint(expr=(b[1,0] == -11.0))
cm.end_b_1 = Constraint(expr=(b[1,3] == 0.0))
cm.constr_a_1_1 = Constraint(expr=a[1,2] == a[1,1] + a[2,1])
cm.constr_a_1_0 = Constraint(expr=a[1,1] == a[1,0] + a[2,0])
cm.constr_b_1_0 = Constraint(expr=(b[1,1] == (b[1,0] + -(b[2,0]))))
cm.constr_b_1_1 = Constraint(expr=(b[1,2] == (b[1,1] + -(b[2,1]))))
cm.constr_b_1_2 = Constraint(expr=(b[1,3] == (b[1,2] + -(b[2,2]))))
cm.constr_b_2_2 = Constraint(expr=(b[2,3] == (b[2,2] + -(b[1,2]))))
cm.constr_b_2_1 = Constraint(expr=(b[2,2] == (b[2,1] + -(b[1,1]))))
cm.constr_b_2_0 = Constraint(expr=(b[2,1] == (b[2,0] + -(b[1,0]))))
cm.constr_a_2_2 = Constraint(expr=(a[2,3] == (a[2,2] + a[1,2])))
cm.constr_a_2_0 = Constraint(expr=(a[2,1] == (a[2,0] + a[1,0])))
cm.constr_a_2_1 = Constraint(expr=(a[2,2] == (a[2,1] + a[1,1])))
cm.constr_a_1_2 = Constraint(expr=(a[1,3] == (a[1,2] + a[2,2])))
oe=c[0]
o = Objective(expr=oe)
cm.objective=o
cm_results = SolverFactory('ipopt').solve(cm)
And of course when I solve the above problem I get a traceback with:
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyomo/opt/plugins/sol.pyc in __call__(self, filename, res, soln, suffixes)
44 """
45 try:
---> 46 with open(filename,"r") as f:
47 return self._load(f, res, soln, suffixes)
48 except ValueError as e:
IOError: [Errno 2] No such file or directory: '/var/folders/4f/z25gj3_d29b45_2nx87p8rvr0000gn/T/tmpwMeEAK.pyomo.sol'
Now, what is really weird about this, is when I take out the last three constraints (i.e. commented out):
# cm.constr_a_2_0 = Constraint(expr=(a[2,1] == (a[2,0] + a[1,0])))
# cm.constr_a_2_1 = Constraint(expr=(a[2,2] == (a[2,1] + a[1,1])))
# cm.constr_a_1_2 = Constraint(expr=(a[1,3] == (a[1,2] + a[2,2])))
Then there are no problems with the solver.
What is causing this error? And why does it get solved when those last few constraints are removed?
Upvotes: 0
Views: 1713
Reputation: 1436
This kind of exit from Ipopt is indicative of an internal error during the solve (probably does not have to do with feasibility). The latest release of Pyomo (5.2) has been updated to handle this case better. If you add tee=True
to the solve()
call, it will stream the Ipopt output and you should get more information.
Also, one should always check the solve status before using the solution. When I'm being lazy, I typically do something like:
ipopt = SolverFactory("ipopt")
result = ipopt.solve(model)
assert str(result.solver.status) == "ok"
assert str(result.solver.termination_condition) == "optimal"
You can modify this to handle different exit conditions.
Upvotes: 2
Reputation: 33532
I did not use that lib for a long time, but a short remark:
Your error indicates (in my interpretation), that no solution was found (the .sol
suffix is used for solutions). To be more precise: the solver thinks that there is no feasible solution (and no valid output file will be generated). Without checking your problem, adding / removing constraints can have this effect in general in regards to feasibility.
The basic question in regards to usage is: why is this pretty normal status so obfuscated? To me it seems, that you are using the lib wrongly. You should not read out the solution before checking there is one! You are doing this implicitly with cm_results = SolverFactory('ipopt').solve(cm)
.
But as i did not use it for a long time (because of better alternatives in the convex-world; but yeah, good interfaces of ipopt are rare), i can't show you code. But i remember there were some examples within the official blog or at least some user-forum / mailing-list about status-checking before output-reading!
Apart from that: i think there is also a log-file you can read out to strenghten my thoughts (probably something like: "problem is infeasible" in there; basically there are 3 files involded each time: input, output, log).
Upvotes: 2