Generate Code from Mixed-integer linear programming solver

5 次查看(过去 30 天)
Hello Community,
I am using the solver glpk or cbc for my optimzation, both solvers are implemented in c++ and have an interface to generate a mex file for Matlab. In Matlab you can call the mex file to solve my optimization problem with a program like this:
c = [10, 6, 4]';
a = [ 1, 1, 1;
10, 4, 5;
2, 2, 6];
b = [100, 600, 300]';
lb = [0, 0, 0]';
ub = [inf inf inf];
ctype = ['U';'U';'U'];
vartype = ['C';'C';'C'];
s = -1;
param.msglev = 1;
param.itlim = 100;
[xmin, fmin, status, extra] = ...
glpkcc (c, a, b, lb, ub, ctype, vartype, s, param);
Now I want to you use one of these solvers in a Simulink model, therefore I have to generate an S-function from this mex file. I am able to generate an S-function from a simple c-File, like in the examples provided by MathWorks with the Legacy Code Tool.
Does anyone of you have made experiences with this approach? Is it possible to generate code from these solvers and to use them on an embedded system. Is there another solver, with which I can simply generate code and solve a Mixed Integer Linear Programming (MILP) Problem or Mixed Integer Quadratic Programming (MIQP)? I know Matlab has an integrated solver like intlinprog, but it seems to me that I can't generate code from it.
Thank you for any help!

回答(1 个)

Shaked D
Shaked D 2020-2-4
This doesn't answer your question, but if you have the optimization toolbox, you can just use MATLAB's intlinprog solver. From my experience it's faster than GLPK and CBC.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by