Skip to content

Instantly share code, notes, and snippets.

View jaeandersson's full-sized avatar

Joel Andersson jaeandersson

  • Madison, Wisconsin
View GitHub Profile
@jaeandersson
jaeandersson / qpsolve.py
Last active March 20, 2025 14:35
Solve QP using qpOASES and CasADi from Python
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
@jaeandersson
jaeandersson / Circle.m
Last active August 29, 2015 13:58
(Incomplete) Matlab interface generated from https://github.com/jaeandersson/swig/tree/matlab
classdef Circle < Shape
methods
function self = Circle(varargin)
self@Shape('_swigCreate',uint64(0),false);
if nargin==3 && ischar(varargin{1}) && strcmp(varargin{1},'_swigCreate')
self.swigCPtr = varargin{2};
self.swigOwn = varargin{3};
else
% How to get working on C side? Commented out, replaed by hack below
%self.swigCPtr = example_wrap('new_Circle',varargin{:});
@jaeandersson
jaeandersson / gist:8555820
Created January 22, 2014 09:22
Get diagonal entries of the Hessian in CasADi
#include <iostream>
#include <fstream>
#include <ctime>
#include <iomanip>
#include <symbolic/casadi.hpp>
#include <symbolic/stl_vector_tools.hpp>
using namespace CasADi;
using namespace std;
@jaeandersson
jaeandersson / gist:5531420
Created May 7, 2013 09:32
modifications of examples/cplusplus/ipopt_nl.cpp
/*
* This file is part of CasADi.
*
* CasADi -- A symbolic framework for dynamic optimization.
* Copyright (C) 2010 by Joel Andersson, Moritz Diehl, K.U.Leuven. All rights reserved.
*
* CasADi is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.