# pyomo - pass time limit to NEOS

I am sending a pretty complex Pyomo MINLP to NEOS using Couenne. I'm getting an error message that the solve time is too long (sorry, I don't have it still in my Python console). Is there a way to set a max time and return the best feasible result? I was able to get solutions back prior to adding my last set of constraints. Current code is:

# lots of code for model building...

solver_manager = SolverManagerFactory('neos')
results = solver_manager.solve(model , opt='couenne',load_solutions=True,tee=True)
model.solutions.store_to(results)
results.write()


complex Pyomo MINLP to NEOS using Couenne.

So, I had to Google a bit to understand this part as I am not familiar with the package nor the NEOS service.

It would be beneficial as to where in the run-time progress you get the error message and what it exactly states.

From the NEOS webpage I found the following limitations

Retrieving results If you are having trouble receiving results, you should read the NEOS Server FAQ section on results before contacting support. Jobs that exceed the 8 hour time limit or the 3 GB memory limit will not return results.

I am guessing your model doesn't run for 8 hours, but maybe you are hitting the 3 GB memory limit before a solution has been found?

Edit below, as a comment shed some new light for the reason to the time limit (or I misunderstood the question).

If you simply want a feasible solution (fast), then I would model the problem as a decision problem (see this answer on Comp Sci SE).

Shortly put and in general terms, you change the problem from something like:

\begin{align} \min&\quad f(x) \\ \text{s.t.} &\quad Ax = b \\ &\quad x \in \Bbb R\end{align}

to

\begin{align} \min&\quad 0 \\ \text{s.t.} &\quad Ax = b \\ &\quad f(x)\leq K\\ &\quad x \in \Bbb R\end{align}

where $$K$$ is a large constant you are fairly certain a feasible solution has an objective less than (or Integer.MAX_VALUE or "large enough"). The problem should terminate as soon as a solution has been found.

• It may actually be taking that long. The issue is that I am willing to settle for a feasible solution, within a given time limit that I want to be able to specify. – Ralph Jun 3 '19 at 1:22
• In that case I think you need to look at your Counne model to see if you can force it to run more frequent heuristics or maybe set an internal timelimit of e.g. 7 hours. This could force it to stop more gracefully and send the best solution back to you. I guess that if you hit the 8 hour limit then the server kills the process in brutal manner with no callback of the solution, but I don't know. – Tue Christensen Jun 3 '19 at 8:37
• That's the point - I'm trying to pass a time limit as an argument to Couenne. For the purposes of this project, essentially any feasible solution will be fine, I am much more concerned about getting a fast feasible answer than the optimal answer. – Ralph Jun 3 '19 at 10:53
• That seems to be something else than what you originally stated, so that would require a slightly different approach. I will make an edit for it. – Tue Christensen Jun 3 '19 at 10:57
• Thanks Tue. I'll give that a shot. The issue is that there are many thousands (millions?) of feasible solutions. The objective function is nonlinear (constraints are linear / integer) so I think Couenne is spending way too much time searching the solution space for a global maximum when a local maximum will be generally acceptable. – Ralph Jun 3 '19 at 11:50