1

I'm using cvxpy to solve an integer programming problem. For feasible solutions, the .solve() method for cvxpy returns in a few tenths of a second. For infeasible solutions, it can take 30+ seconds for cvxpy to return "infeasible". Questions:

1) Is there a way to pass a timeout value to the solve() method? If no, what is the recommended way to call cvxpy from a python program where I don't want to wait indefinitely?
2) Is it typical that cvxpy will take 30+ seconds to return infeasible?

user2558918
  • 103
  • 1
  • 2
  • 4
  • If your `cvxpy` code is relatively contained, you could move it to s subprocess via `multiprocessing.Process`. Use its `.join` and `.terminate` methods to control timeout. – tdelaney Feb 24 '20 at 02:01

1 Answers1

1

The answer to this question is dependent on the solver you are using. This page has a a summary of options for different solvers.

You can see that CBC (Coin-or branch and cut) has a maximumSeconds option, but most solvers don't have a similar option.

However, most solvers allow you to specify a maximum number of iterations, which in practice will allow you some control to bound the computational time required for the solver to halt.

foglerit
  • 7,792
  • 8
  • 44
  • 64
  • Thank you. This worked great. I've changed my code to the code below and it works perfectly now. problem.solve(solver=cp.ECOS_BB, mi_max_iters=5) – user2558918 Feb 24 '20 at 03:30