cvxgrp / qcml

A Python parser for generating Python/C/Matlab solver interfaces
Other
42 stars 9 forks source link

bug? scalar parameter offset #50

Closed steve3141 closed 9 years ago

steve3141 commented 10 years ago

Clearly this is a minor issue since it involves a "pointless" constant added to the objective function, which can simply be removed. But I came across it when doing some "automated" problem generation, and it should be simple to fix. Minimal example:

variable x(2)
parameter aconst
minimize norm(x) + aconst

Generates the error:

  File "U:\python\lib\python\qcml\qc_lang.py", line 144, in solve_func
    result['objval'] = multiplier * sol['info']['pcost'] + offset
TypeError: unsupported operand type(s) for +: 'float' and 'str'

By debugging I see that 'offset' has been left as the string aconst rather than the value params['aconst']

Thanks, Steve

echu commented 10 years ago

Oh, awesome. :) Thanks for catching that.

On Wed, Jul 16, 2014 at 8:26 AM, steve3141 notifications@github.com wrote:

Clearly this is a minor issue since it involves a "pointless" constant added to the objective function, which can simply be removed. But I came across it when doing some "automated" problem generation, and it should be simple to fix. Minimal example:

variable x(2) parameter aconst minimize norm(x) + aconst

Generates the error:

File "U:\python\lib\python\qcml\qc_lang.py", line 144, in solve_func result['objval'] = multiplier * sol['info']['pcost'] + offset TypeError: unsupported operand type(s) for +: 'float' and 'str'

By debugging I see that 'offset' has been left as the string aconst rather than the value params['aconst']

Thanks, Steve

— Reply to this email directly or view it on GitHub https://github.com/cvxgrp/qcml/issues/50.

echu commented 10 years ago

Give it a shot now.

steve3141 commented 10 years ago

Thanks for the quick response. Sorry I haven't had a chance to try this yet, will let you know if there is still any problem.