- Problem-Based, where you express your objective and constraints in terms of symbolic-like problem variables.
- Solver-Based, where you set up your problem as a function of a single vector variable and write matrices that represent the linear constraints in terms of this one variable.
MatLAB linprog optimization function?
8 ビュー (過去 30 日間)
古いコメントを表示
Hello everyone, I am currently trying to recreate the optimization presented in "Optimizing the distribution of Italian building energy retrofit incentives with Linear Programming" in MATLAB. The goal of the research is to propose an optimization-based methodology for the evaluation of retrofit incentives for different regions. However, I am struggling implementing the main part.

I am trying to do the optimization using the linprog command. Linprog requires a vector as objective function, however, to my understanding my objective function would be a matrix given the (5) equation. This is what I have so far.
A = Value.avg_cost;
At = A';
bt = Value.budget_ma;
b = Value.budget_ret;
l_b = zeros(1,5);
l_bt = zeros(1,5);
u_b = sum(Value.n');
u_bt = Value.N;
A = [A;A'];
b = [b bt];
l_b = [l_b l_bt];
u_b = [u_b u_bt];
f = -sum(Value.avg_sav);
x(:,c) = linprog(f,A,b,[],[],l_b,u_b);
Since I have two inequality constraints I have decided to make a big matrix out of them (A) and the relative vector (b), then I tried to develop a objective function f that was the sum of both rows and columns. s_ij correspond to avg_sav and a_ij to avg_cost, while b_i and b_j are budget_ma and budget_ret respectively. The l_b and u_b corresponds to the upper and lower boundaries of the variable x. Is it correctly formulated? Thank you in advance for the help!
Gianluca
0 件のコメント
採用された回答
Alan Weiss
2018 年 6 月 11 日
Depending on your MATLAB version, there are two approaches to linear programming or mixed-integer linear programming.
There are plenty of examples of both types of approaches. Generally, I think that the problem-based approach is more straightforward, but you are free to use whichever one suits your style. I am sure that, if you look through the examples, you will find one that shows how to set up your variables correctly.
Alan Weiss
MATLAB mathematical toolbox documentation
0 件のコメント
その他の回答 (1 件)
Jose Emilio Loya
2020 年 12 月 9 日
Hellow, can someone help me?
I am try to solve a transportation problem, but I´m having problems using the "lineprog" function.
I´m using this:
[xopt, fval] = linprog(lpp.f,lpp.A,lpp.b,[],[],lpp.lb);
and they show mw this:
'linprog' requires Optimization Toolbox.
Error in try1 (line 19)
[xopt, fval] = linprog(lpp.f,lpp.A,lpp.b,[],[],lpp.lb);
Im using the R202b version. thank you
1 件のコメント
Alan Weiss
2020 年 12 月 10 日
It sounds like you do not have OOptimization Toolbox installed. If you have a license for it, reinstall the toolbox.
Alan Weiss
MATLAB mathematical toolbox documentation
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!