Allow warm-start in diffcp#867
Conversation
akshayka
left a comment
There was a problem hiding this comment.
Thanks for the PR! We should (only) support True/False warm-starting in CVXPY. See my comment.
|
Looks great. One more thing (& probably the last thing) --- can you add a unit test that exercises the warm start code path? Something simple is fine, e.g., similar to https://sourcegraph.com/github.com/cvxgrp/cvxpy@af2f1e8eddb2997ac52d105f6e81d5d63582180d/-/blob/cvxpy/tests/test_scs.py#L186-196 (without the print statement). The test could go in test_scs.py or test_derivative.py. Also, flake8: |
akshayka
left a comment
There was a problem hiding this comment.
Looks good, just a few small nits. I'll approve & merge once they're addressed. Thanks!
| result2 = prob.solve(solver=cp.DIFFCP, warm_start=True, eps=1e-4) | ||
| time2 = prob.solver_stats.solve_time | ||
| self.assertAlmostEqual(result2, result, places=2) | ||
| print(time > time2) |
There was a problem hiding this comment.
Delete the print statement, please.
| cones = scs_conif.dims_to_solver_dict(data[ConicSolver.DIMS]) | ||
| # Default to eps = 1e-4 instead of 1e-3. | ||
| solver_opts['eps'] = solver_opts.get('eps', 1e-4) | ||
| warm_start_dict = None |
There was a problem hiding this comment.
warm_start_dict -> warm_start_tuple
| obj = cp.Minimize(cp.sum(cp.exp(x))) | ||
| prob = cp.Problem(obj, [cp.sum(x) == 1]) | ||
| result = prob.solve(solver=cp.DIFFCP, eps=1e-4) | ||
| time = prob.solver_stats.solve_time |
| result = prob.solve(solver=cp.DIFFCP, eps=1e-4) | ||
| time = prob.solver_stats.solve_time | ||
| result2 = prob.solve(solver=cp.DIFFCP, warm_start=True, eps=1e-4) | ||
| time2 = prob.solver_stats.solve_time |
|
Should be done now. Let me know if there is anything else to change. Thanks! |
This PR allows to warm-start SCS in diffcp. Note that the
warm_startoption in diffcp now conflicts with the standard cvxpywarm_startoption which is True/False.Also, it would be good to check the type of the
warm_startentry in diffcp to avoid errors:https://github.com/cvxgrp/diffcp/blob/2e0d3f7337e19509bd312272ed59be1f93104ff2/diffcp/cone_program.py#L248-L251