nicolapiccinelli / libmpc

libmpc++ is a C++ header-only library to solve linear and non-linear MPC
https://altairlab.gitlab.io/optcontrol/libmpc/
MIT License
138 stars 21 forks source link

Should a negative cost ever occur? #31

Open pwintz opened 7 months ago

pwintz commented 7 months ago

I'm running into a surprising case where the cost is sometimes evaluated to be negative if the optimization algorithm fails to converge to a solution. Is this expected?

[MPC++] Optimization step completed
duration: 340.145 (sec)
status: 1 (opt code: -2)
cost: -1500.16
Scarab: inject roi stats dump end marker
Optimizer Info
         Return code: -2
       Result status: 1
Number of iterations: 800
                Cost: -1500.16
    Constraint error: 0.445752
          Dual error: 0.140763
nicolapiccinelli commented 7 months ago

Hey @pwintz can you provide some context? Kind of problem you are solving, parameters, etc.