Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generate_code raises IndexError when solver="CLARABEL" #26

Closed
kunalmenda opened this issue Sep 20, 2023 · 2 comments
Closed

generate_code raises IndexError when solver="CLARABEL" #26

kunalmenda opened this issue Sep 20, 2023 · 2 comments

Comments

@kunalmenda
Copy link

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

@PTNobel
Copy link
Member

PTNobel commented Sep 23, 2023

Hey Kunal,

We don't support Clarabel in CVXPYgen yet. That work can't really start till #24 is done I think.

@maxschaller
Copy link
Collaborator

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants