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 | |
| import re | |
| class MFunctionParser: | |
| def parse(self,filename): | |
| f = open(filename,"r") | |
| signature = f.readline() | |
| m = re.search("function \[?([\w,]+)\]? = \w+\((.*)\)",signature) | |
| if not m: |
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
| from casadi import * | |
| x = msym("x",2) | |
| y = msym("y",2,2) | |
| f = MXFunction([x,y],[mul(y,x),y]) | |
| f.setOption("number_of_fwd_dir",2) | |
| f.init() | |
| f.input(0).set(DMatrix([1.1,1.3])) |
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
| def print_subclasses(myclass, depth=0): | |
| print (" " * depth) + " - " + myclass.__name__ | |
| for s in myclass.__subclasses__(): | |
| print_subclasses(s,depth=depth+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
| import numpy as NP | |
| import casadi as C | |
| def qpsolve(H,g,lbx,ubx,A=NP.zeros((0,0)),lba=NP.zeros(0),uba=NP.zeros(0)): | |
| # Convert to CasADi types | |
| H = C.DMatrix(H) | |
| g = C.DMatrix(g) | |
| lbx = C.DMatrix(lbx) | |
| ubx = C.DMatrix(ubx) | |
| A = C.DMatrix(A) | |
| A = A.reshape((A.size1(),H.size1())) # Make sure matching dimensions |
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
| from casadi import * | |
| def HackyFunction(name,ins,outs): | |
| # Obtain all symbolic primitives present in the inputs | |
| Vs = symvar(veccat(*ins)) | |
| # Construct a helper function with these symbols as inputs | |
| h = Function("helper",Vs, ins) | |
| # Assert dense inputs |
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
| <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'> | |
| <html xmlns='http://www.w3.org/1999/xhtml'> | |
| <head><script src='http://d3js.org/d3.v3.min.js'></script><script src='http://cpettitt.github.io/project/dagre-d3/v0.1.5/dagre-d3.min.js'></script><style>svg { overflow: hidden;}.node rect { stroke: #333; stroke-width: 1.5px; fill: #fff;}.edgeLabel rect { fill: #fff;}.edgePath { stroke: #333; stroke-width: 1.5px; fill: none;}.outer { width: 1024px; height: 960px; overflow: auto;}.inner { width: 8000px; height: 6000px;}svg { display: block; width: 100%; height: 100%;} | |
| .link { | |
| stroke: #999; | |
| stroke-width: 2px; | |
| } |
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
| #!/usr/bin/env python | |
| """ | |
| simple example script for running and testing notebooks. | |
| Usage: `ipnbdoctest.py foo.ipynb [bar.ipynb [...]]` | |
| Each cell is submitted to the kernel, and the outputs are compared with those stored in the notebook. | |
| """ | |
| import os,sys,time |
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 os | |
| import subprocess | |
| import io | |
| import shutil | |
| dir = '/home/frs/project/casadi/CasADi/' | |
| shutil.rmtree(os.path.join(dir,'branches')) | |
| os.mkdir(os.path.join(dir,'branches')) |
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.* | |
| load SilverboxSimulated | |
| u_data = u; | |
| y_data = y; | |
| % simulation horizon | |
| N = size(u_data, 1); | |
| % declare symbols for states and controls | |
| y = MX.sym('y'); |
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.* | |
| load SilverboxSimulated | |
| u_data = u; | |
| y_data = y; | |
| %% | |
| % simulation horizon | |
| N = size(u_data, 1); |
OlderNewer