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
# Configure this makefile if needed then run | |
# $ make all | |
# to compile and link | |
# What files to compile | |
OBJS=money.cpp | |
# What file to compile to | |
MAINFILE=money | |
# What compiler to use | |
CC=g++ |
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
""" Hacky import & solving of MPS-files (only tested for netlib) | |
- source of mps-files: http://www.netlib.org/lp/data/ | |
- instances need to be uncompressed -> see readme in link-folder | |
- uses cvxopt's mps-parsing | |
- internal problem-modification / canonicalization by cvxopt "_inmatrixform" | |
- only implemented / tested for problems without explicit bound-/range-constraints | |
- see problem table within readme in link-folder for instance-type table | |
- probably ugly/unnecessary dense/sparse-stuff (code is old and hacky) | |
- just to be careful: cvxopt's license is not compatible with scipy! |
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 numpy as np | |
import time | |
from scipy.optimize import minimize, nnls | |
from cvxpy import * | |
np.random.seed(1) | |
""" Test-data generator """ | |
def create_test_data(samples, features, noise, loc=10, scale=2.5): | |
m = np.random.normal(loc=loc, scale=scale, size=(samples, features)) |
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 numpy as np | |
import matplotlib.pyplot as plt | |
np.random.seed(1) | |
N = 1000 | |
r= np.random.randn(N) | |
x = np.exp(0.01 * np.arange(N)) + 0.2 | |
y = np.exp(0.4 * np.arange(N)+r) | |
plt.loglog(x,y,label="Hello ") | |
plt.axvline(x=1.2, color='g') |
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
from gurobipy import * | |
m = Model("model") | |
x = m.addVar(lb=0.0, name="x") | |
y = m.addVar(lb=0.0, name="y") | |
m.update() | |
obj = -x*x - y*y | |
m.setObjective(obj) # default: minimize |
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
using JuMP, AmplNLWriter, NLopt | |
n = 1000 | |
mu1_true = 0.3 | |
mu2_true = 0.55 | |
mu3_true = 0.10 | |
sig1_true = 0.08 | |
sig2_true = 0.12 | |
sig3_true = 0.32 | |
a_0_true = 0.5 |
NewerOlder