opensim-core icon indicating copy to clipboard operation
opensim-core copied to clipboard

Setting exponent to 1 in MocoOutputGoal can return negative values

Open carmichaelong opened this issue 2 years ago • 1 comments

https://github.com/opensim-org/opensim-core/blob/c6dc2a5913df2cb7e7a72da1ebb162fda9eaa022/OpenSim/Moco/MocoGoal/MocoOutputGoal.cpp#L84

If the exponent is set to 1, the integrand can return negative values. Looks like all other values for the exponent will return positive values.

carmichaelong avatar Sep 15 '22 22:09 carmichaelong

We can't use the abs() function here since it is non-smooth (it's fine to use abs() in the third branch of the if-statement since the resulting value is raised some a power > 1, making it smooth).

We should improve the documentation for setExponent() to make it clear what happens in each branch of the if-statement.

nickbianco avatar Sep 16 '22 16:09 nickbianco