introducing a comparison related to variables in linear programming

조회 수: 4 (최근 30일)
ennes mulla
ennes mulla 2023년 1월 20일
편집: Matt J 2023년 1월 20일
Hello,
I want to run linear programming to make a trade off between multiple sources of energy. I want to include a battery in the system and size it using linear programming. Therefore, I have the following varaibles:
Pdemand: demands of energy which I have it already as a vector colmun.
X1= A_pv [m^2 ]-maximum total area occupied by the solar photovoltaic system
X2=A_w [m^2 ]-maximum total wind rotor area
.
.
X8=E_bess (t) [kWh]-energy in the BESS at time t
X9=P_(bess.in) (t) [kW]-power in battery at time t
X10=P_(bess.out) (t) [kW]-power out from battery at time t
I started to encounter problems when setting my first inequality since X9 and X10 are related to X1 and X2 as following
if X1 + X2 > Pdemand
X9 = (X1 +X2) - Pdemand;
X10 = 0;
else
X10 = Pdemand - (X1 + X2);
X9= 0;
Now I want to make the first constrain for linear programming by reporting the coefficient to use it later in linear programming
X1 + X2 +X9 +X10 = demands
I included X9 and X10 here in the equation since one of them needs to be zero at the time the other is presented.
A1 = [CX1 CX2 0 0 0 0 0 0 0 CX9 CX10]
As you can see, I am trying to solve for X9 and X10 but before I need them to go throght the if statment which is not possible till I get the results of linear programming first.
Can someone help me please, I have zero ideas how to solve this. Thanks.
  댓글 수: 4
Torsten
Torsten 2023년 1월 20일
편집: Torsten 2023년 1월 20일
You say you have Pdemand as a column vector. So X1 and X2 are also X1(t) and X2(t) ?
It would be helpful to have your problem stated precisely.
ennes mulla
ennes mulla 2023년 1월 20일
yes yes. I over simplified the problem to mention less details, But man ignore this details please, how would you introduce if statment to the LP

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

채택된 답변

Matt J
Matt J 2023년 1월 20일
편집: Matt J 2023년 1월 20일
The constraints you describe are non-convex, so there is no way to formulate them in a linear way. However, you can modify your problem so that the solution to a linear program is encouraged to satisfy those constraints. Introduce additional variables U,V and the constraints,
U=(X1 +X2) - Pdemand
-V<=U<=V %implies V>=abs(U)
X9>=0
V>=X9>=U %(1a)
X10>=0
V>=X10>=-U %(1b)
X9+X10=V %(2)
Also, modify your linear objective to have a penalty term,
min. f(X) + largeNumber*V
So, if largeNumber is large enough, the penalty will force V to its lower bound V=abs(U) at the solution. In that case when U>0 then U=V and constraint (1a) implies X9=U=(X1 +X2) - Pdemand. Additionally constraint (2) then implies X10=0.
A similar argument shows that if U<0 and so -U=V, then constraint (1b) implies X10=V=abs(U)= Pdemand-(X1+X2) and X9=0.

추가 답변 (1개)

Torsten
Torsten 2023년 1월 20일
편집: Torsten 2023년 1월 20일
Your constraint says that
X9 = max(0,X1+X2-Pdemand)
X10 = max(0,Pdemand-(X1+X2))
Usually, it suffices to set the constraints
X9 >= 0
X9 >= X1+X2-Pdemand
X10 >= 0
X10 >= Pdemand-(X1+X2)
since you usually won't "oversupply" in an optimization.
If the constraints don't suffice for your application, look up on how to linearize the max-operator independent of the objective following Larry Snyder's answer under
But in case you have to use this formulation, your problem becomes a problem for intlinprog - it can no longer be solved with linprog.

카테고리

Help CenterFile Exchange에서 Dimensionality Reduction and Feature Extraction에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by