CVXPYgen
QOCOGEN can be called from CVXPYgen from version 0.5.0 onwards to generate a custom solver and then to call the custom solver from Python.
After installing QOCO and defining your problem in CVXPY, QOCOGEN can be called to generate a custom solver using CVXPYgen as follows
from cvxpygen import cpg
# problem is a CVXPY problem
cpg.generate_code(problem, code_dir='solver_directory', solver='QOCO')
To call the custom solver through CVXPYgen, run
from solver_directory.cpg_solver import cpg_solve
problem.register_solve('CPG', cpg_solve)
problem.solve(method='CPG', max_iters=100)
where we set the max_iters
option to 100
. For a full list of settings that can be changed, refer to settings.
For an example of setting up and solving a problem using QOCO through CVXPY and QOCOGEN through CVXPYgen, see settings.