You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I modify the example code slightly to add a new parameter that requires a transpose operation, i.e.:
importcvxpy_codegenascgm=10n=5A=cg.Parameter(m, n, name='A')
b=cg.Parameter(m, name='b')
c=cg.Parameter(n, name='c') # <--------- New paramx=cg.Variable(n, name='x')
f0=cg.norm(A*x-b) -c.T*x# <--------- Transpose addedprob=cg.Problem(cg.Minimize(f0))
prob.codegen('least_squares_example')
I get the following exception:
Traceback (most recent call last):
File "transpose_test.py", line 10, in
prob.codegen('least_squares_example')
File "/usr/local/lib/python3.5/dist-packages/cvxpy_codegen-0.0.1-py3.5.egg/cvxpy_codegen/problem.py", line 31, in codegen
CodeGenerator(obj, constraints, vars, params).codegen(target_dir)
File "/usr/local/lib/python3.5/dist-packages/cvxpy_codegen-0.0.1-py3.5.egg/cvxpy_codegen/code_generator.py", line 100, in codegen
self.template_vars.update(param_handler.get_template_vars())
File "/usr/local/lib/python3.5/dist-packages/cvxpy_codegen-0.0.1-py3.5.egg/cvxpy_codegen/param/param_handler.py", line 72, in get_template_vars
self.process_expression(root_param)
File "/usr/local/lib/python3.5/dist-packages/cvxpy_codegen-0.0.1-py3.5.egg/cvxpy_codegen/param/param_handler.py", line 92, in process_expression
data_arg = self.process_expression(expr.atom)
File "/usr/local/lib/python3.5/dist-packages/cvxpy_codegen-0.0.1-py3.5.egg/cvxpy_codegen/param/param_handler.py", line 121, in process_expression
data_list = get_atom_data(expr, arg_data)
File "/usr/local/lib/python3.5/dist-packages/cvxpy_codegen-0.0.1-py3.5.egg/cvxpy_codegen/atoms/atoms.py", line 68, in get_atom_data
raise TypeError("Constant expressions involving the %s atom not supported." % str(type(expr)))
TypeError: Constant expressions involving the <class 'cvxpy.atoms.affine.transpose.transpose'> atom not supported.
I can get it to run by removing the transpose operator and redefining the parameter as a row vector, i.e.: c = cg.Parameter(1,n, name='c')
...but it would be nice to support the canonical constraint form where c is a column vector. As it is I'll have to always remember to transpose that value in particular before passing in to the C function call or Python wrapper.
The text was updated successfully, but these errors were encountered:
If I modify the example code slightly to add a new parameter that requires a transpose operation, i.e.:
I get the following exception:
I can get it to run by removing the transpose operator and redefining the parameter as a row vector, i.e.:
c = cg.Parameter(1,n, name='c')
...but it would be nice to support the canonical constraint form where c is a column vector. As it is I'll have to always remember to transpose that value in particular before passing in to the C function call or Python wrapper.
The text was updated successfully, but these errors were encountered: