I install Baron solver on windows and I use pyomo in Spyder. I move baron.exe to current directory
when I run my code, this error appears:
Solver log file: 'C:\Users\~\AppData\Local\Temp\tmpumg5hxvr.baron.log'
Solver solution file: 'C:\Users\~\AppData\Local\Temp\tmpbmx1pfpt.baron.soln'
Solver problem files: ('C:\\Users\\~\\AppData\\Local\\Temp\\tmpygo80gcy.pyomo.bar',)
C:\Users\~\baron.exe: can't open C:\Users\~\AppData\Local\Temp\tmpygo80gcy.pyomo.bar.nl
ERROR: Solver (baron) returned non-zero return code (1)
ERROR: See the solver log above for diagnostic information.
Traceback
ApplicationError: Solver (baron) did not exit normally
But There is not the log file: C:\Users\~\AppData\Local\Temp\tmpumg5hxvr.baron.log
How can I fix this problem?
Thanks for your helps in advance.
I met the same problem today. I solved the problem by changing the solver name 'baron' to 'Baron'
Related
I am running m.solve() in a try .. except construct to elegantly handle any exceptions raised by the solver due to maximum iterations or convergence to an infeasibility but want to interrogate APPINFO and APPSTATUS to determine if a solution was found. I was surprised to see that I always seem to get APPINFO=0 and APPSTATUS=1 even though the the solver reports that a solutions was not found.
What am I missing in my interpretation of the document on APPINFO and APPSTATUS?
Piece of code to reproduce error.
from gekko import GEKKO
m=GEKKO(remote=False)
m.x=m.Var()
m.y=m.Var()
m.total=m.Intermediate(m.x+m.y)
m.Equation(m.total>20) #if included, no feasible solution exists
m.Equation(m.x<9)
m.Equation(m.y<9)
m.Maximize(m.total)
m.options.SOLVER=3
try:
m.solve()
except Exception as e:
print('Exception',e)
print('APPINFO', m.options.APPINFO)
print('APPSTATUS', m.options.APPSTATUS)
Use debug=False to not raise an exception when Gekko fails to solve. When there is an exception, the results are not loaded back into m.options.
from gekko import GEKKO
m=GEKKO(remote=False)
m.x=m.Var()
m.y=m.Var()
m.total=m.Intermediate(m.x+m.y)
m.Equation(m.total>20) #if included, no feasible solution exists
m.Equation(m.x<9)
m.Equation(m.y<9)
m.Maximize(m.total)
m.options.SOLVER=3
m.solve(debug=False)
print('APPINFO', m.options.APPINFO)
print('APPSTATUS', m.options.APPSTATUS)
This produces the correct error response:
---------------------------------------------------
Solver : IPOPT (v3.12)
Solution time : 0.0156 sec
Objective : -18.023281704731964
Unsuccessful with error code 0
---------------------------------------------------
Creating file: infeasibilities.txt
Use command apm_get(server,app,'infeasibilities.txt') to retrieve file
#error: Solution Not Found
APPINFO 2
APPSTATUS 0
I am trying to get my first Pyomo model running on my Ubuntu VM (Azure). I have Python3 and the COIN-OR solvers installed on this machine. No matter what solver I try, I get the same result.
Edit: changing the solver to couenne (it's a nonlinear problem) the Jupyter output looks like this. When I open the log files in the tmp directory, there is nothing in the couenne.log file and the pyomo files are the problem formulation. So I assume that Pyomo isn't communicating with the Couenne solver at all?
Solver log file: '/tmp/tmpezw0sov2_couenne.log'
Solver solution file: '/tmp/tmpq6afa7e8.pyomo.sol'
Solver problem files: ('/tmp/tmpq6afa7e8.pyomo.nl',)
ERROR: Solver (asl) returned non-zero return code (-1)
ERROR: See the solver log above for diagnostic information.
---------------------------------------------------------------------------
ApplicationError Traceback (most recent call last)
<ipython-input-6-486e3a9173f4> in <module>()
20 #instance = model.create_instance()
21 opt = SolverFactory('couenne', executable = solverpath_exe)
---> 22 opt.solve(model,tee=True,keepfiles=True)
23 #solver=SolverFactory(solvername,executable=solverpath_exe)
/home/ralphasher/.local/lib/python3.6/site-packages/pyomo/opt/base/solvers.py in solve(self, *args, **kwds)
598 logger.error("Solver log:\n" + str(_status.log))
599 raise pyutilib.common.ApplicationError(
--> 600 "Solver (%s) did not exit normally" % self.name)
601 solve_completion_time = time.time()
602 if self._report_timing:
ApplicationError: Solver (asl) did not exit normally
The "catch-all" exception is raised because the solver runs as a separate, non-Python process, so Python really can't tell what exactly went wrong with it, it just sees that the process has quit abnormally.
As such, solver log is the thing to go to as this is where the solver itself writes its status updates, so the specific error, whatever it is, should be reflected there.
If solver log is empty, this most probably means that the solver has failed to start at all (if solver process is run with stream redirection, the log file is opened -- thus created -- before the solver command is exec'd, so this is a common symptom when there's a problem with a program's startup). Since pyomo is the thing that starts the solver, getting the details of what exactly happens at the time of solver's start is where the answer lies.
According to pyomo solve command — Pyomo 5.6.6 documentation, you can use --info or --verbose command line options to increase the verbosity of the pyomo log.
If that still doesn't produce anything revealing, time to bring out the big guns:
run pyomo under pdb (pyomo is just a script so you can pass it to python -m pdb like any other; make sure to use the same python executable as in the script's shebang) and step through the code in pyomo machinery to see what exactly it does with the solver process (what info it passes, how it invokes it)
you'll be able to see defects in this process if there are (e.g. no info is actually passed) or repeat the same operations by hand to see the result firsthand; and/or
run the command under strace -f (to also monitor the solver's child process) and see if there are any obvious errors like an error to exec the solver command or any errors opening files and such.
tensorflow version:1.12, cuda version:10.0
When I build my code, there is a error message:
2019-03-23 18:53:29.965772: I tensorflow/core/kernels/cuda_solvers.cc:159] Creating CudaSolver handles for stream 0x55c9d5a16320
2019-03-23 18:53:30.063068: F tensorflow/core/kernels/cuda_solvers.cc:94] Check failed: cusolverDnCreate(&cusolver_dn_handle) == CUSOLVER_STATUS_SUCCESS Failed to create cuSolverDN instance.
This problem occurred after I wrote code about distribution(from tensorflow-probability). Of course if I remove the code and compile again, there is nothing happened.
Is there any way to solve this problem?
I need to write an optimization file for Gurobi (Python) that is a modified version of a classic TSP. I tried to run the example file from their website:
examples.gurobi.com/traveling-salesman-problem/
I always get the following error:
TypeError: object of type 'NoneType' has no len()
What do I need to change?
Thx
Full code: https://www.dropbox.com/s/ewisx805b3o2wq5/beispiel_opt.py?dl=0
I can confirm the error with the example code from Gurobi's website. At the first look the problem seems to be inside the subtour function, that returns None if sum(lengths) == n and the missing check for if tour is None inside the subtourlim function.
Instead of providing a fix for the specific code, I first checked the examples that Gurobi installs inside the specific installation directory:
Mac: /Library/gurobi810/mac64/examples/python/
Linux: /opt/gurobi800/linux64/examples/python/
Windows: c:\gurobi800\win64\examples\python\
And surprisingly the tsp.py from there runs without any errors. Note also that the two mentioned functions are revised. So I guess the example from the website is just a old version of the code.
I am running an optimization in Gurobi which crashes whenever I add a quadratic constraint to the problem that I generate thru the following lines of code:
expression = gurobipy.QuadExpr()
for course_key in hostings:
for kitchen_key in hostings[course_key]:
if not hostings[course_key][kitchen_key].large_gathering:
expression.add(x[kitchen_key,course_key,team_key1]*x[kitchen_key,course_key,team_key2])
mod.addQConstr(expression,gurobipy.GRB.LESS_EQUAL,1,"1MeetingPerPair_"+team_key1+"_"+team_key2)
The optimization always crashes after three iterations:
cmd output
with the following error message:
Unhandled exception at 0x00007FFC596CE6FC (ntdll.dll) in python.exe:
0xC0000374: A heap has been corrupted (parameters: 0x00007FF8FF82C6E0).
Does anyone have any clue as to how this problem could be solved? I am rather clueless as to what the error message even wants to tell me. I tried constructing the constraint in different ways (e. g. using .add instead of .addTerms) but that didn't change anything. Appreciate any help!