locuslab / mpc.pytorch

A fast and differentiable model predictive control (MPC) solver for PyTorch.
https://locuslab.github.io/mpc.pytorch/
MIT License
872 stars 146 forks source link

Boolean subtraction error in pnqp.py #21

Closed sirdr closed 5 years ago

sirdr commented 5 years ago

Hi I'm trying to run the following code

x_lqr, u_lqr, objs_lqr = controller(state, QuadCost(Q, c), model_dynamics)

where controller is initialized as

controller = mpc.MPC(
        n_state=n_state,
        n_ctrl=n_ctrl,
        T=T,
        u_lower=action_low, 
        u_upper=action_high,
        lqr_iter=20,
        verbose=1,
        backprop=True,
        exit_unconverged=False,
        grad_method=GradMethods.AUTO_DIFF)

and I'm getting the following error output

Screen Shot 2019-09-11 at 4 18 19 PM

Any idea what might be causing this ? From the source code pinned below Ic is clearly a boolean and I would expect this to always be a boolean and thus for Line 33 (also pinned below) to always fail.

https://github.com/locuslab/mpc.pytorch/blob/dc6ae9f6e3858510a5df96592fac3a3a17590b2a/mpc/pnqp.py#L32

https://github.com/locuslab/mpc.pytorch/blob/dc6ae9f6e3858510a5df96592fac3a3a17590b2a/mpc/pnqp.py#L33

Also worrying to me is the fact that the error output has If = Ic - 1 on line 31 and not 33. I've updated my package with pip install mpc --upgrade and it claims it's up to date. Any help on this would be super appreciated.

bamos commented 5 years ago

Hi, I think I've fixed this in the latest version. I forgot to push to pypi earlier but just did. Can you try pulling the latest version and try again?

sirdr commented 5 years ago

Yep, that resolved it. Thanks!

bamos commented 5 years ago

Great!