`generate_code` raises IndexError when `solver="CLARABEL"`
kunalmenda opened this issue · comments
Kunal Menda commented
Hello, I'm trying to use cvxpygen
but running into an error when I try using CLARABEL
as a solver.
Minimal example
import cvxpy as cp
from cvxpygen import cpg
import numpy as np
# define CVXPY problem
m, n = 3, 2
x = cp.Variable(n, name='x')
A = cp.Parameter((m, n), name='A', sparsity=[(0, 0), (0, 1), (1, 1)])
b = cp.Parameter(m, name='b')
problem = cp.Problem(cp.Minimize(cp.sum_squares(A @ x - b)), [x >= 0])
# assign parameter values and test-solve
np.random.seed(0)
A.value = np.zeros((m, n))
A.value[0, 0] = np.random.randn()
A.value[0, 1] = np.random.randn()
A.value[1, 1] = np.random.randn()
b.value = np.random.randn(m)
problem.solve(solver='CLARABEL')
# generate code
cpg.generate_code(problem, code_dir='nonneg_LS', solver='CLARABEL')
Output
Generating code with CVXPYgen ...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/kunalmenda/anaconda3/envs/test/lib/python3.10/site-packages/cvxpygen/cpg.py", line 155, in generate_code
for dual_id in dual_id_maps[0].keys():
IndexError: list index out of range
Is there any way to avoid this error?
Thanks,
Kunal
Parth Nobel commented
Hey Kunal,
We don't support Clarabel in CVXPYgen yet. That work can't really start till #24 is done I think.
Maximilian Schaller commented
Hi @kunalmenda, you can use Clarabel now if you are a Mac or Linux user. See #28. Feel free to install from sources by cloning the repo via git clone --recurse-submodules https://github.com/cvxgrp/cvxpygen.git
and installing via python setup.py install
. You will need Rust
and Eigen
(more info here).