Originally posted by: SystemAdmin
I agree with Tomas that a modeling language for Matlab based on Cplex would be useful. It may have similar features as OPL and Concert for fast model prototyping in Matlab. Below I post a simple comparative example of how modeling is done in Cplex and Yalmip.
First step (get data):
n = 10;
Q = randn(n); Q = Q*Q'/1000;
mu = rand(1,n)/100;
Model and solve with Yalmip (given the data):
x = sdpvar(n,1);
F = [sum(x) == 1, x >= 0, mu*x == 0.05];
optimizer(F, x'*Q*x);
Model and solve with Cplex (given the data):
cplex = Cplex('Var_min');
cplex.addCols(zeros(n,1), [], zeros(n,1), Inf*ones(n,1));
cplex.addRows([1; 0.05], [ones(1,n); mu], [1; 0.05]);
cplex.Model.Q = Q;
cplex.solve();
With Cplex API, a user has to think how to construct a matrix of constraints, RHS, LHS, etc. Modeling with Yalmip can be done in natural form. Of course, the example above is simple. Where the real power comes is the ability to specify constraints of the type:
a' * abs(x) <= 10
card(x) <= 10
norm(D*x,2) <= 10
if (x >= y && x >= z) then ~(x <= 300 || y >= 700))
instead of figuring out how to
split variables to define absolute value constraint
construct MIP problem to restrict cardinality
construct quadratic constraint
define indicator variables/constraints
#CPLEXOptimizers#DecisionOptimization