coin-or / CppAD

A C++ Algorithmic Differentiation Package: Home Page
https://cppad.readthedocs.io
Other
469 stars 95 forks source link

Leppov case missing in local/optimize/get_op_usage.hpp #162

Closed condor-cp closed 1 year ago

condor-cp commented 2 years ago

Hello, I recently experience that running the "optimize" method of CppAD::ADFun runs into an error.

After debugging, it seems that the operation Leppov is missing from the cases of get_op_usage, I thus fall to the default case here and so to an error.

Is there a fundamental reason for this op not to be in the cases ?

bradbell commented 2 years ago

It seems that all the operators, where both arguments are parameters, are missing from https://github.com/coin-or/CppAD/blob/master/include/cppad/local/optimize/get_op_usage.hpp ; i.e.

    EqppOp,   // compare equal
    LeppOp,   // compare <=
    LtppOp,   // compare <
    NeppOp,   // compare !=
    StppOp,   // store in VecAD array

These do appear in https://github.com/coin-or/CppAD/blob/master/include/cppad/local/optimize/get_par_usage.hpp

It will take a while for me to create a test case that demonstrates this bug, understand what if anything should be done, and to then fix it.

In the meantime, you might try removing the

 CPPAD_ASSERT_UNKNOWN(0);

at the end of get_op_usage.hpp

condor-cp commented 2 years ago

Ok, thank you

bradbell commented 2 years ago

The comparison operators EqppOp, // compare equal LeppOp, // compare <= LtppOp, // compare < NeppOp, // compare != have been fixed. See the following commit: https://github.com/coin-or/CppAD/commit/6966000307ecc09a431fbbdd402c330b562dec89

If this satisfies your problem, please close this bug.