alphaville / optimization-engine

Nonconvex embedded optimization: code generation for fast real-time optimization + ROS support
https://alphaville.github.io/optimization-engine/
Other
512 stars 53 forks source link

Possible error in ALM/PM constraint implementation #275

Open djrakita opened 2 years ago

djrakita commented 2 years ago

Describe the bug The res: &mut [f64] slice in f2 (or f1) functions in ALM/PM constraints can be incorrect length.

A clear and concise description of what the bug is. I was implementing an equality constraint in my code using OpEn, and realized that the output of JF_2(u)^T d should be 6x1 but the res: &mut [f64] slice was only of length 1, causing the code to panic when I tried to assign to res[0], res[1], ..., res[5]. When digging into this issue, I realized that I believe the same issue is present in the public example (explained below).

To Reproduce Looking at the provided pm.rs example (though the same issue may be present for alm as well), the output of jf2t should be a 3x1 vector or, in other words, res should be a slice of length 3. However, res is, instead, a slice of length 1. This example appears to fail silently as res and u have zipped iterators, which just stops after the single entry of res without actually iterating through all of u as well.

Expected behavior The output of jf2t should be length 3 and, thus, res should be a slice of length 3.

System information:

:warning: Please, provide the following information:

alphaville commented 1 year ago

Must be related to #309 - we're looking at it now and hopefully we'll resolve both issues soon