MatLAB linprog optimization function?

7 Ansichten (letzte 30 Tage)
Gianluca Ghirlanda
Gianluca Ghirlanda am 9 Jun. 2018
Kommentiert: Alan Weiss am 10 Dez. 2020
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

Akzeptierte Antwort

Alan Weiss
Alan Weiss am 11 Jun. 2018
Depending on your MATLAB version, there are two approaches to linear programming or mixed-integer linear programming.
  • 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.
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

Weitere Antworten (1)

Jose Emilio Loya
Jose Emilio Loya am 9 Dez. 2020
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 Kommentar
Alan Weiss
Alan Weiss am 10 Dez. 2020
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

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by