Comments (4)
If you introduce parameters, you can keep those pure-numeric dot_m(t)
, T_ram(t)
helper functions as-is:
params = struct;
params.dot_m = MX.sym('dot_m')
params.T_ram = MX.sym(...)
...
p = [params.dot_m;params.T_ram;...]
f = Function('f', {x, u, p}, {dynamics(x,u,d,params)}, {'x','u', 'p'},{'x_dot'});
% In the dynamics, write params.dot_m instead of dot_m(t), and similar for others..
%Integration options
G = struct;
G.tf = T/N;
%Construct DAE
dae = struct;
dae.x = x; %define the states
dae.u = u; %define the control parameter
dae.p = p; %define paramaeters
% dae.t = t; %define the time parameter
dae.ode = f(x,u,p); %define the RH side of ode
intg = integrator('intg','cvodes',dae, G); %Integration command
res = intg('x0',x,'p',p,'u',u); %integrate symbolically
x_next = res.xf; %Assign the final state of x to x_next
%Returns x_next
F = Function('F',{x, u, p},{x_next},{'x','u','p'},{'x_next'});
% This loop is now devoid of any symbolic operations -> faster
for i = 1:length(t0)
u_input = g(i, :);
pp_num = [dot_m(i);T_ram(i)]
x_next = F(x_current, u_input, p_num);
x_current = x_next;
X(:, i) = full(x_current); % Store the state at the current time step
end
If you are willing to rewrite your helpers, you could consider using interpolant
to CasADi Functions out of dot_m
, T_ram
, and use a time-dependant ode formulation
f = Function('f', {x, u, t}, {dynamics(t,x,u,d)}, {'x','u', 't'},{'x_dot'});
...
dae.t = t; %define the time parameter
dae.ode = f(x,u,t); %define the RH side of ode
...
from casadi.
Do you mean a lot of time to implement, or to solve?
from casadi.
to solve.
from casadi.
Thank you so much @jgillis
Out of curiostiy, Is there an example on how to use (interpolant) to CasADi functions out of helper functions I can look at?
from casadi.
Related Issues (20)
- JIT Compiliation time HOT 5
- warm start for OSQP solver
- illegal hardware instruction HOT 2
- IpTNLP.hpp: No such file or directory HOT 1
- Problem linking IPOPT to casadi HOT 2
- Can I use IDAs in Casadi as simulink solver? HOT 1
- Interface madNLP HOT 1
- What is the main difference between SX and MX, and does it have a big impact on the solution speed?
- Regression bug for threaded sqpmethod+qrqp HOT 2
- missed opportunity for cse in Function hierarchies
- Error evaluating the gradient of the objective function
- Trying to build gives error with "WITH_IPOPT" flag HOT 3
- Installing Casadi in Anaconda with Gurobi (Windows)
- sz_w() of expanded function doesn't match codegen HOT 3
- Add function_internal.hpp to the install interface HOT 8
- Is DM and SX matrix creation thread safe? HOT 3
- How to use "print_options()" in python? HOT 2
- blocksqp cannot silence qpoases licence print
- Documentation: code for MX in the section on SX
- casadi build from source (from git repo) failing with SWIG 4.2.0 HOT 7
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.