필터 지우기
필터 지우기

How can I make the negative output values of the linprog optimization to be treated as if they was positive when optimizing a problem?

조회 수: 4 (최근 30일)
How can I make the negative output values of the linprog optimization to be treated as if they was positive when optimizing a problem?
My output is as follows (being printed into an external file):
Gen1 P: 0.00 Gen2 P: 200.00 P12: 66.67 P13: -66.67 P32: 133.33
It is a power flow problem, and the output might therefore be negative if power flows in a different direction to my chosen one. What the optimizer clearly does, is treating the negative value as a "gain" and hence it tries to maximize this value (only constrained by the bounds and other constraints I have defined). I need this negative value to be treated as a positive one when optimizing, as negative only indicates direction and not a gain. In other words, I need the negative value to be minimized in the same manner as a positive value. Is there an option to do this directly when launching the optimizer?

채택된 답변

Matt J
Matt J 2013년 11월 14일
편집: Matt J 2013년 11월 14일
I need this negative value to be treated as a positive one when optimizing, as negative only indicates direction and not a gain.
Then the objective function is not linear and linprog is not applicable. Consider applying lsqlin() instead to the quadratic function
diag(f)*[Gen1; Gen2; P12; P13^2; P32]
where f is the same weight vector that you used in linprog for the objective function.
  댓글 수: 1
Matt J
Matt J 2013년 11월 14일
편집: Matt J 2013년 11월 14일
You could also apply linprog, but split the problem into two cases. In the first case you assume the solution has P13>=0 and you impose the appropriate lb(i) lower bound. In the second case you constrain P13<=0 with an appropriate ub(i) and reverse the sign of the weight f(i) in the objective function. You solve each problem using linprog and take the result that gives the better objective function value.

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

추가 답변 (2개)

Ben Petschel
Ben Petschel 2013년 11월 15일
If you need to minimise something like abs(x), just replace x with y-z so your objective becomes to minimise y+z with y>=0 and z>=0. This can all be plugged straight into linprog along with all the other linear constraints.

Matt J
Matt J 2013년 11월 15일
편집: Matt J 2013년 11월 15일
You could also replace terms f(i)*abs(x(i)) in the objective function with f(i)*w where w(i) is an additional variable introduced into the problem formulation. You then add constraints,
w(i)>=x(i)
w(i)>=-x(i)

카테고리

Help CenterFile Exchange에서 Linear Least Squares에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by