This file contains 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
/* Compile with: | |
* gcc optimizer.c -l:libthe_optimizer.a -L./target/debug -pthread -lm -ldl -o optimizer -Wall | |
*/ | |
#include <stdio.h> | |
#include "open_bindings.h" | |
int main() { | |
HomotopyCache * y = solver_new(); | |
const double p[2] = {1.0, 10.0}; |
This file contains 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
use optimization_engine::continuation::HomotopySolverStatus; | |
use serde::{Deserialize, Serialize}; | |
use std::{ | |
io::{prelude::Read, Write}, | |
net::TcpListener, | |
}; | |
use test_optimizer::*; | |
extern crate pretty_env_logger; | |
#[macro_use] |
This file contains 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.casadi as cs | |
import opengen as og | |
u = cs.SX.sym("u", 5) | |
p = cs.SX.sym("p", 2) | |
# COST FUNCTION | |
phi = og.functions.rosenbrock(u, p) | |
# PENALTY-TYPE CONSTRAINTS |
This file contains 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,a,rho,beta,q] = lbfgs(H0, v, Y, S) | |
%LBFGS performs a simple L-BFGS update | |
% | |
% Input arguments: | |
% - H0: Initial Hessian estimate (matrix); typical choice: H0 = (s'y)/(y'y) | |
% where (s,y) is the most recent pair of s and y | |
% - v: the vector on which the L-BFGS Hessian estimate should be applied; | |
% the function will return r = Hk*v, for given v | |
% - Y and S: buffers: Y = [y(k-1), ..., y(0)], where y(k-1) = g(k) - g(k-1) | |
% and Sk = [s(k-1), ..., s(0)], where s(k-1) = x(k) - x(k-1) |
This file contains 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
// ---------------------------------------------------------------------------- | |
// Boxed simple function | |
// ---------------------------------------------------------------------------- | |
struct Chung<'a> { | |
close: Box<Fn(f64) -> f64 + 'a>, | |
} | |
impl<'a> Chung<'a> { | |
fn new<C>(f: C) -> Chung<'a> | |
where |
This file contains 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 shim = cvx_scs( shim ) | |
% CVX_SOLVER_SHIM SeDuMi interface for CVX. | |
% This procedure returns a 'shim': a structure containing the necessary | |
% information CVX needs to use this solver in its modeling framework. | |
if ~isempty( shim.solve ), | |
return | |
end | |
if isempty( shim.name ), |
This file contains 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 [x_, z_, details] = epipr_sqnorm(x,z) | |
if (x'*x <= z) | |
x_ = x; z_ = z; | |
return | |
end | |
theta = 1 - 2 * z; | |
[r, status] = cubic_roots(theta, x); | |
details.status = status; | |
% Pick the right root | |
for i=1:length(r), |
This file contains 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 [controller, Tree, yalmip_struct] = ... | |
FormulateMJLSMPCLV(probStruct,sysStruct,LV) | |
% do_write_file = false; | |
N = probStruct.N; | |
Prob = probStruct.Prob; | |
A = sysStruct.A; | |
B = sysStruct.B; | |
xmin = sysStruct.xmin; | |
xmax = sysStruct.xmax; | |
umin = sysStruct.umin; |
This file contains 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 fun_linear_system(t, x, A) | |
return A*x; | |
end | |
nx = 4; | |
eigens = diagm(-1.+(1:nx)/nx/4); | |
for i=1:2*floor(nx/2) | |
eigens[1,i]=0.4^(i/2); | |
eigens[i,1]=-0.4^(i/2); | |
end |
This file contains 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 [x_star, details] = lasso_newton(A, y, lambda, x0, ops) | |
%LASSO_NEWTON solves the LASSO problem | |
% | |
% min_x ||Ax - y||^2 + lambda*||x||_1 | |
% | |
% | |
% Debug mode | |
dbg = true; |