Comments (7)
The error is in the second derivative. It generates a first order derivative function (fwd1_EXTERNAL_FUNCTION) using forward mode AD or or finite differencing. But then fails to differentiate fwd1_EXTERNAL_FUNCTION.
from casadi.
Hi @jaeandersson thank you for your quick reply. Do you have any suggestions for how we could debug this further? Especially since this was working with CasADi 3.5.5. Is there anything you are aware of from the previous version that:
- changes how the derivative function is generated, or
- changes how the differentiation is done?
from casadi.
Not off the top of my head. You could look exactly at what kind of derivative functions were generated in 3.5.5 to figure out when it starts diverging from 3.6. Once you've figured out why it's behaving different, you can think of a way to resolve the issue. In any case, second derivatives using FD only is not really recommended, so I'm not even so sure it really worked for you in 3.5.5 either.
from casadi.
Thanks for the input, maybe some clarifications:
- Both
EXTERNAL_FUNCTION
andfwd1_EXTERNAL_FUNCTION
are external functions,fwd1_EXTERNAL_FUNCTION
is not generated via forward AD. - The expected behavior here is that by explicitly setting
opts["enable_fd"] = true
, the second derivative will be calculated using finite differences onfwd1_EXTERNAL_FUNCTION
. We are aware that finite differences are not really the best option, but due to the nature of the external functions, it is the only option. - We could not find any changes in the ReleaseNotes resp. diffs since 3.5.5 with respect to
enable_fd
, yet the assert implies that the explicitopts["enable_fd"] = true
has been discarded. The offending assert not being a new addition either. - Also for completeness, the error is generated when (trying) to create the NLP solver.
/Peter
from casadi.
Hi @jaeandersson. After some additional debugging we believe the error we are observing is due to the changes in #2848, among them I see that some options (in particular enable_fd
) are no longer propagated due to the added if-statement (6b7dc1d#diff-3f30bada163de7ee828d1f3dd0fe431e8233b97aef17d841b8498f1df2507415R385).
Could you comment on the following:
- Is it intentional to no longer propagate
enable_fd
? - If yes, do you have any proposal for what we can change such that the second derivative gets calculated using fd?
from casadi.
- Is it intentional to no longer propagate
enable_fd
?
Yes, it's intentional. In your case, you don't want to enable FD for the function itself, but for its derivative.
- If yes, do you have any proposal for what we can change such that the second derivative gets calculated using fd?
You should be able to pass enable_fd
to to the first order derivative function directly. Try to set
opts["forward_options"] = dict(enable_fd = True)
from casadi.
- Is it intentional to no longer propagate
enable_fd
?Yes, it's intentional. In your case, you don't want to enable FD for the function itself, but for its derivative.
- If yes, do you have any proposal for what we can change such that the second derivative gets calculated using fd?
You should be able to pass
enable_fd
to to the first order derivative function directly. Try to setopts["forward_options"] = dict(enable_fd = True)
We could resolve the issue on our side by additionally adding enable_fd as explicit forward option as you suggested.
Thanks for the help!
from casadi.
Related Issues (20)
- Set bounds not constraint HOT 2
- The infeasible result is shown as βThe infeasible result is shown as abcβ in matlab, I can't find it in the help doc, I look forward to your help.
- NLP solver returning over-constrained warning and wrong results
- Change casadi_int by size_t (unsigned) when iterating vectors and strings
- Use `Fmu2::deserialize` only if compiled with `WITH_FMI2`
- Acessing the adjoint state HOT 3
- python kernel crash during integration
- Integrade NLPsolver in a class but outputs are all zeros
- Performance of FMU implementation HOT 1
- qpsol creates multiple gurobi environment
- ipopt Nan detect for output jac_g_x HOT 2
- 'C compiler cannot create executables' error when trying to compile HSL solver on Mac OS X HOT 5
- g and lam_g from nlpsol_out does not return any values HOT 4
- Too much pagefile HOT 1
- No parallelization when NLP (using mumps) is converted to function object and map is used with threads
- python crash when funtion from opti (sqpmethod) is evaluated in parallel HOT 2
- Add option to check if the number and names of function inputs is correct even when using a map
- stdout handling for external
- codegen C API finenuning HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from casadi.