linear programming to solve conditional equations

8 views (last 30 days)
I am solving a Hydro power system optimization and faced a conditional constraint equation of the form below. have a look and send me your ideas.
it is as follows:
I have a Conditional spillage constraint equation of the form:
  • S(r,t) = V(r,t) - Vrmax *
Where V(r,t) = the reservoir level (volume) in time period t, S(r,t) = spill in time period t and Vrmax is the maximum reservoir volume.
Both V(r,t) and S(r,t) are variables whereas Vrmax is a parameter which i already have the data.
The Condition is:
if S(r,t) >= 0
then V(r,t) = Vrmax (that means V(r,t) takes the value of Vrmax)
and s(r,t) = s(r,t) (that means S(r,t) takes its own value)
else If s(r,t) < 0
then V(r,t) = V(r,t) (that means V(r,t) takes its own value)
and s(r,t) =0 (that s(r,t) takes a value of zero)
In addition there are two upper and lower bound equations for the above variables (V and S):
  • V(r,t) <= Vrmax *
  • S(r,t) >=0 *
my questions are:
1. I was attempting to use the function Linprog to solve the equation. But linprog accepts only coefficients of equation in matrix form which makes it difficult for the above equation since it is conditional. Is there any way I can represent such function in MATLAB linear programming platform using matrix? IF not what else can I do?
2. The three equations inside double asterics are standard equations used in water reservioir simulation. but it is clear that the first equation cant hold true if both the second and third holds true. how can this be managed?
Regards Ashenafi
  2 Comments
Matt J
Matt J on 17 Aug 2014
Edited: Matt J on 17 Aug 2014
Is s(r,t) the same thing as S(r,t)? You use them case-insensitively?
2. ... but it is clear that the first equation cant hold true if both the second and third holds true?
Yes it can. They admit a trivial solution S(r,t)=0, V(r,t)=Vrmax. Clearly though, there is something wrong with the way you have formulated the problem. The solution requires no work at all...
Matt J
Matt J on 17 Aug 2014
Edited: Matt J on 17 Aug 2014
and s(r,t) =0 (that s(r,t) takes a value of zero)
But you have said that this condition occurs when s(r,t)<0. How can you simultaneously have s(r,t)<0 and s(r,t)=0?
And why do you even consider the case s(r,t)<0? later, you stipulate the bound S(r,t)>=0. I'm still presuming s(r,t) and S(r,t) are notation for the same thing. You haven't said otherwise...

Sign in to comment.

Answers (1)

Johan Löfberg
Johan Löfberg on 18 Aug 2014
Edited: Johan Löfberg on 18 Aug 2014
So you want S = min(V,Vmax)?
This can not be represented in a simple linear program (unless it is maximized in the objective, or only is constrained from below). It can however be represented in a mixed-integer linear program, i.e, by adding binary variables to you model to represent the different cases
Let d be a binary variable and you have two cases
d = 0: S = V, V <= Vmax
d = 1: S = Vmax, V>=Vmax
To implement this using mixed-integer linear programming, you typically use something called big-M modelling.
The MATLAB Toolbox YALMIP (disclaimer, I'm the developer)can help you do this if you don't want to do it manually. For reference, the code would be something like
V = sdpvar(1);
S = sdpvar(1);
d1 = binvar(1);
d2 = binvar(1);
Constraints = [0 <= V <= Vupperbound, 0 <= S <= Vmax]
Constraints = [Constraints, implies(d1, S = V, V <= Vmax];
Constraints = [Constraints, implies(d2, S = Vmax, V >= Vmax];
Constraints = [Constraints, d1 + d2 == 1];
or you let YALMIP modelling machinery take over completely
V = sdpvar(1);
S = sdpvar(1);
Constraints = [0 <= V <= Vupperbound, 0 <= S <= Vmax]
Constraints = [Constraints, S = min(V,Vmax)];
  2 Comments
Maryam Bahramipanah
Maryam Bahramipanah on 2 May 2015
Hi Johan
I am trying to do the same as you explained here using YALMIP (use binary variables). Which solver you suggested to apply for this problem?

Sign in to comment.

Categories

Find more on Graphics Performance in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!