introducing a comparison related to variables in linear programming
Afficher commentaires plus anciens
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 commentaires
Torsten
le 20 Jan 2023
X1 + X2 > Pdemand
Why are areas of power supply systems [m^2] a power demand [kW] ?
ennes mulla
le 20 Jan 2023
ennes mulla
le 20 Jan 2023
Réponse acceptée
Plus de réponses (1)
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.
Catégories
En savoir plus sur Argument Definitions dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!