cvxgrp/cvxpygen

Code generation with OSQP fails

chenyx09 opened this issue · 9 comments

Code generation with OSQP fails with error "undefined symbol: osqp_update_verbose". It seems that osqp_update_verbose is not defined in osqp.h when EMBEDDED is set. Can anyone fix this? Thanks!

Hey @chenyx09 Is there a specific example or code you were working with when you got this error? If so, can you share it please?

I am having the same issue.

Solver setting "verbose" not available

I am also getting an error that the setting "polish" is not available for the OSQP solver. Would it be possible to add it?

Hello @ilyanoskov, do you have an example of the code that is failing you could share?

Hi @PTNobel, thanks a lot for looking into this.

I add polish=True here:
https://github.com/cvxgrp/cvxpygen/blob/master/examples/portfolio.ipynb
CleanShot 2023-03-24 at 23 54 04@2x

And it fails for me with the following error:

AttributeError                            Traceback (most recent call last)
~/coding/cvxpygen/examples/portfolio_code/cpg_solver.py in cpg_solve(prob, updated_params, **kwargs)
     30         try:
---> 31             eval('cpg_module.set_solver_%s(value)' % key)
     32         except AttributeError:

~/coding/cvxpygen/examples/portfolio_code/cpg_solver.py in <module>

AttributeError: module 'portfolio_code.cpg_module' has no attribute 'set_solver_polish'

This seems unrelated to the undefined symbol error from the top of the thread. Please open a new issue with your feature request.

Sure, will do, although when I set verbose=True I get the same error:

val = prob.solve(method='CPG', verbose=True)
AttributeError                            Traceback (most recent call last)
~/coding/cvxpygen/examples/portfolio_code/cpg_solver.py in cpg_solve(prob, updated_params, **kwargs)
     30         try:
---> 31             eval('cpg_module.set_solver_%s(value)' % key)
     32         except AttributeError:

~/coding/cvxpygen/examples/portfolio_code/cpg_solver.py in <module>

So I think the issue here is that for OSQP solver, the attributes are not being passed correctly?

I believe that CVXPYgen does not support passing attributes to the solvers, so please file a feature request for that. These both seem unrelated to the linking issue when EMBEDDED is set.

Setting verbose with OSQP was previously not possible by design. I assume that you directly accessed the OSQP interface and invoked osqp_update_verbose (which then obviously failed).

Anyways, setting verbose with OSQP is now supported (as of #18 and version 0.2.3)! At code generation time, you need to add enable_settings=['verbose'] when calling generate_code.