fdabrandao / mo-book-with-ampl Goto Github PK
View Code? Open in Web Editor NEWThis project forked from mobook/mo-book
Mathematical Opimization
Home Page: https://mo-book.ampl.com
License: MIT License
This project forked from mobook/mo-book
Mathematical Opimization
Home Page: https://mo-book.ampl.com
License: MIT License
I am not able to run LAD-regression (chapter 2), it seems that something broke with some amplpy or numpy update.
The model is very simple:
# indexing sets
set I;
set J;
# parameters
param y{I};
param X{I, J};
# variables
var ep{I} >= 0;
var em{I} >= 0;
var m{J} >= 0;
var b;
# constraints
s.t. residuals {i in I}:
ep[i] - em[i] == y[i] - sum{j in J}(X[i, j] * m[j]) - b;
# objective
minimize sum_of_abs_errors: sum{i in I}(ep[i] + em[i]);
To call the model
def lad_regression(X, y):
ampl = AMPL()
ampl.read("lad_regression.mod")
n, k = X.shape
# note use of Python style zero based indexing
ampl.set["I"] = list(range(n))
ampl.set["J"] = list(range(k))
ampl.param["y"] = y
ampl.param["X"] = X
ampl.option["solver"] = SOLVER
ampl.solve()
return ampl
m = lad_regression(X, y)
m.display("m")
m.display("b")
The issue shows up when X is assigned to ampl.param["X"], X is a npdarray and comes from:
X, y = make_regression(n_samples=n_samples, n_features=n_features, noise=noise)
Use Ipopt, Mosek, Gurobi, Knitro to solve SOCP and exponential cones (Gurobi only SOCP). Progress status for text only:
Progress status for models:
Progress for text only:
Progress for models:
intro.md needs more adaption, like authors, etc
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.