This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function r= dpc_simple_simulate | |
| % get a random starting state between min state and max state | |
| x_min = [-1; -pi; -pi; -.05; -1; -1]; | |
| x_max = -x_min; | |
| x0 = rand(6,1) .* (x_max-x_min)+x_min; | |
| % simulate | |
| tspan = 0:0.01:8; | |
| [tspan, X] = ode45(@dpc_ode, tspan, x0); | |
| r = struct; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import numpy as np | |
| import math | |
| from scipy.integrate import solve_ivp | |
| def main(): | |
| # get a random starting state between min state and max state | |
| x_min = np.array([-1, -np.pi, -np.pi, -.05, -1, -1]); | |
| x_max = -x_min; | |
| x0 = np.random.uniform(low=0.0, high=1.0, size=6) * \ | |
| (x_max-x_min)+x_min; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | x = casadi.MX.sym('x',2); | |
| f = x(1)*x(1) + x(2)*x(2); | |
| g = x(1)+x(2)-10; | |
| % solver = casadi.nlpsol('solver', 'ipopt', struct('x', x, 'f', f, 'g', g),struct('jit',true)); | |
| % solver.generate_dependencies('nlp.c'); | |
| solver = casadi.nlpsol('solver', 'ipopt', struct('x', x, 'f', f, 'g', g)); | |
| solver.generate_dependencies('nlp.c',struct('mex',true)); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import casadi.* | |
| % Degree of interpolating polynomial | |
| d = 3; | |
| % Get collocation points | |
| tau_root = [0 collocation_points(d, 'radau')]; | |
| % Coefficients of the collocation equation | |
| C = zeros(d+1,d+1); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | clear classes % necessary to update/reload .so | |
| MEX_COMPILE = false; | |
| x = casadi.SX.sym('x',2); | |
| f = x; | |
| for i=1:10 | |
| f = sin(f)*cos(f)'; | |
| end | |
| df = jacobian(f,x); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | % syms x | |
| % | |
| % f = x; | |
| % | |
| % for i=1:100 | |
| % f = sin(f)*cos(f); | |
| % end | |
| % diff(f,x) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | x = casadi.SX.sym('x',2); | |
| f = x; | |
| for i=1:10 | |
| f = sin(f)*cos(f)'; | |
| end | |
| df = jacobian(f,x); | |
| fun = casadi.Function('fun',{x},{f}); | |
| jacfun = casadi.Function('jac_fun',{x},{df}); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function testIpoptInterface | |
| x = casadi.MX.sym('x',2); | |
| f = x(1)*x(1) + x(2)*x(2); | |
| g = x(1)+x(2)-10; | |
| % https://groups.google.com/forum/#!searchin/casadi-users/generate|sort:relevance/casadi-users/pxhU1tgkaEI/svmrRIzbFwAJ | |
| fGrad = gradient(f,x); | |
| gJac = jacobian(g,x); | |
| lam = casadi.MX.sym('lam', g.sparsity()); |