Skip to content

Instantly share code, notes, and snippets.

View jgillis's full-sized avatar

Joris Gillis jgillis

View GitHub Profile
<!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;
}
#!/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
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'))
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');
import casadi.*
load SilverboxSimulated
u_data = u;
y_data = y;
%%
% simulation horizon
N = size(u_data, 1);
import casadi.*
% In this example, we fit a nonlinear model to measurements
%
% This example uses more advanced constructs than the vdp* examples:
% Since the number of control intervals is potentially very large here,
% we use memory-efficient Map and MapAccum, in combination with
% codegeneration.
%
% We will be working with a 2-norm objective:
@jgillis
jgillis / simplecacher
Created October 27, 2015 07:25
This file helps you to cache jitted code compilation ( https://github.com/casadi/casadi/issues/1627 )
#!/usr/bin/python
import sys
import hashlib
import subprocess
import shutil
import os
args = sys.argv[1:]
cachedir = ".cache"
@jgillis
jgillis / mfunctionparser.py
Created March 14, 2013 12:58
Parse m-functions in casadi
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:
@jgillis
jgillis / multisens
Created May 24, 2013 07:49
casadi multiple sensitivities
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]))
@jgillis
jgillis / gist:5683620
Last active December 17, 2015 22:39
Method to print the class inheritance hierarchy
def print_subclasses(myclass, depth=0):
print (" " * depth) + " - " + myclass.__name__
for s in myclass.__subclasses__():
print_subclasses(s,depth=depth+1)