Rust Casadi Interface
This is an interface to CasADi functions of the form phi(u; p), where u is a decision variable and p a parameter.
- Using CasADi's MATLAB or Python interface, you may define a cost function
- We provide helper functions which generate C code for the given function and its Jacobian
- Then
icasadioffers a convenient interface to the C code from Rust - This is a
no-stdlibrary which can be used on embedded devices - And
icasadican be used in embedded numerical optimization modules written in Rust
This library is available on crates.io at https://crates.io/crates/icasadi
Code generation in Python
Coming very soon
Code generation in MATLAB
Here is an example of such a function (MATLAB example)
% File: matlab/example.m
= 10; % number of decision variables
= 2; % number of parameters
= casadi.SX.sym; % decision variables
= casadi.SX.sym; % parameters
= * cos' * ; % cost function phi(u; p)
We may then create C code for this function and its Jacobian using
= ;
This will create two functions:
cost: which maps(u, p)tophi(u; p),grad_cost: the Jacobian matrix ofphiwith respect touevaluated at(u, p)
Here is an example of use:
// File: main.rs
extern crate icasadi;
Compiling, Running, Testing
To build the project, run
$ cargo build
To compile the main function (main.rs), run
$ cargo run
To run the unit tests, do
$ cargo test