MatLAB linprog optimization function?

조회 수: 11 (최근 30일)
Gianluca Ghirlanda
Gianluca Ghirlanda 2018년 6월 9일
댓글: Alan Weiss 2020년 12월 10일
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

채택된 답변

Alan Weiss
Alan Weiss 2018년 6월 11일
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

추가 답변 (1개)

Jose Emilio Loya
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
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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by