Comments (8)
function_internal.hpp is part of the internal API, so I don't think it makes sense to have it be an install target. There are also no efforts to keep it stable from one release to another. If you want to couple your tool tightly with CasADi like this, I would suggest you to include CasADi as a git submodule.
from casadi.
Hello,
Thanks a lot for the answer, including it as a git module is not really an option for me because eventually I'd like to make an anaconda build script that is able to integrate a pre-built casadi-python.
I understand that moving the funciton_internal to the public API is not a good idea. I think maybe it is better then to stick to the casadi callback, which is part of the public API. The problem here is that the memory management is problematic for my applications.
The CallbackInternal holds a raw pointer reference to the user-defined Callback. The problem is that it does not take ownership over this resource and that this Callback can be removed from memory while it is still part of a casadi expression / function. This caused segfaults when I implemented callbacks in python as well.
If you this really is a problem (and I'm not using this callback in an unintended way), I can make a different Issue for this and maybe try to see if I can come up with a solution that does not break the current API. Solving this issue would be very useful for me.
from casadi.
The purpose of Callback is really to cater for Python and Matlab users through offering an overloadable interface via swig.
If you are a c/c++ programmer and especially if you are distributing a numerical package tied to casadi, it makes much more sense to work with 'external'. This has a stable API, does reference counting, is efficient, supports codegen, and is robust against mixing binaries compiled with different compilers because the interface is C only.
from casadi.
Agree that using the external C API probably makes more sense. It's more stable, more efficient and also work with things like C code generation. You can probably resolve your persistency issues you're having in Callback by appropriate static method or singleton patterns, but it's probably not worth it if you can just use the C API instead.
from casadi.
Thanks a lot for the recommendations, I'll proceed with the C API. Also thanks for the recommendation of the singleton pattern. I think I'll use that to access my own solver class from the C API implementation. I'll close this issue.
from casadi.
Thanks a lot for the recommendations, I'll proceed with the C API. Also thanks for the recommendation of the singleton pattern. I think I'll use that to access my own solver class from the C API implementation. I'll close this issue.
It's not necessary to use a singleton I think. You should also be able use the "incref/decref/alloc_mem/init_mem/free_mem functions in the C API. But singleton might be easier.
from casadi.
Interesting! Does the int mem arguments in the C API then refer to different instantiations of user-defined function?
Another quick question: is it possible to instantiate a new external Function without having to dl-load a shared library (and going through the file system)? Is it possible to instantiate an external function from c-function pointers to the name_init_mem, name_free_mem, name_release, name_eval ... functions?
Thanks!
from casadi.
Interesting! Does the int mem arguments in the C API then refer to different instantiations of user-defined function?
Correct. This could be useful if you need to evaluate it in parallel for example.
Another quick question: is it possible to instantiate a new external Function without having to dl-load a shared library (and going through the file system)? Is it possible to instantiate an external function from c-function pointers to the name_init_mem, name_free_mem, name_release, name_eval ... functions?
Thanks!
No, I think you need a shared library to use external. Otherwise, you can just use the C API directly. In principle, you could just-in-time compile the function, but this isn't really properly supported.
from casadi.
Related Issues (20)
- Solution of rootfinder() depends on choice of syntax
- Store the IPOPT display parameters in a variable using CasAdi HOT 2
- Error using casadi's linspace with integrator function object
- Convert solution from DM format HOT 7
- Effects on AD when setting a node of a fixed expression graph to structural zero?
- Inconsistent Broadcasting
- 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
- External function derivative detection in CasADi 3.6.x HOT 7
- qpsol creates multiple gurobi environment
- ipopt Nan detect for output jac_g_x
- '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
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.