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 TypeError #39

Open
wbogocki opened this issue Dec 4, 2023 · 1 comment
Open

generate_code raises TypeError #39

wbogocki opened this issue Dec 4, 2023 · 1 comment

Comments

@wbogocki
Copy link

wbogocki commented Dec 4, 2023

generate_code() raises a TypeError on an inexistent dictionary entry when called.

Python: 3.11.3
cvxpy: 1.4.1
cvxpygen: 0.3.1

Generating code with CVXPYgen ...

{
	"name": "TypeError",
	"message": "'NoneType' object is not subscriptable",
	"stack": "---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
c:\\Users\\redacted\\codegen\\EPO.ipynb Cell 24 line 3
      <a href='vscode-notebook-cell:/c%3A/Users/redacted/codegen/EPO.ipynb#X30sZmlsZQ%3D%3D?line=0'>1</a> from cvxpygen import cpg
----> <a href='vscode-notebook-cell:/c%3A/Users/redacted/codegen/EPO.ipynb#X30sZmlsZQ%3D%3D?line=2'>3</a> cpg.generate_code(problem, code_dir='./gen', solver='OSQP')

File ~\\.pyenv\\pyenv-win\\versions\\3.11.3\\Lib\\site-packages\\cvxpygen\\cpg.py:69, in generate_code(problem, code_dir, solver, solver_opts, enable_settings, unroll, prefix, wrapper)
     67 variable_info = get_variable_info(problem, inverse_data)
     68 dual_variable_info = get_dual_variable_info(inverse_data, solver_interface, cvxpy_interface_class)
---> 69 parameter_info = get_parameter_info(param_prob)
     70 constraint_info = get_constraint_info(solver_interface)
     72 adjacency, parameter_canon, canon_p_ids = process_canonical_parameters(
     73     constraint_info, param_prob, parameter_info, solver_interface, solver_opts, problem, cvxpy_interface_class
     74 )

File ~\\.pyenv\\pyenv-win\\versions\\3.11.3\\Lib\\site-packages\\cvxpygen\\cpg.py:466, in get_parameter_info(p_prob)
    462     return np.array(user_p_id_to_param[user_p_id].value)
    464 user_p_flat = cI.get_parameter_vector(user_p_total_size, user_p_id_to_col, user_p_id_to_size,
    465                                       user_p_value)
--> 466 user_p_flat_usp = user_p_flat[user_p_sparsity_mask]
    467 parameter_info = ParameterInfo(user_p_col_to_name_usp, user_p_flat_usp, user_p_id_to_col,
    468                                user_p_ids, user_p_name_to_shape, user_p_name_to_size_usp,
    469                                user_p_name_to_sparsity, user_p_name_to_sparsity_type,
    470                                user_p_names, user_p_num, user_p_sparsity_mask, user_p_writable)
    471 return parameter_info

TypeError: 'NoneType' object is not subscriptable"
}
@maxschaller
Copy link
Collaborator

Could you please paste your minimal example?

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

2 participants