I have written a code for my problem My problem is Min L
Subject to:
0 ≤ Qt ≤ Qm
St = St-1 + It - Qt
Sd ≤ St ≤ Sm
Qt ≤ L
%Read the excel file containing time series inflow data
data = xlsread('Reservoir.xlsx');
t = data(:,1); % days
I(:,1) = data(:,2); % m^3
T = data(end,1); % days
S_0 = data(1,5); % m^3
S_d = data(2,5); % m^3
S_m = data(3,5); % m^3
Q_m = data(4,5); % m^3
L = optimvar('L',1,'LowerBound',0,'UpperBound',Q_m);
Q = optimvar('Q',T,'LowerBound',0,'UpperBound',Q_m);
S = optimvar('L',T,'LowerBound',S_d,'UpperBound',S_m);
waterbalance = optimconstr(T,1);
for t = 1:T
if t == 1
storage = S_0;
else
storage = S(t-1);
end
waterbalance(t) = S(t) == storage + I(t) - Q(t);
end
discharge = optimconstr(T,1);
for t= 1:T
discharge(t) = Q(t)<=L;
end
prob.Constraints.waterbalance = waterbalance;
prob.Constraints.discharge = discharge;
prob = optimproblem;
prob.Objective = L;
sol = solve(prob)
I need the minimized value for L. But i am getting answer as 0. Please help me.

댓글 수: 4

Guillaume
Guillaume 2018년 10월 24일
I've closed your other duplicate of this question as this one describes the problem better.
Torsten
Torsten 2018년 10월 24일
Please include your optimization problem in the usual mathematical notation.
Torsten
Torsten 2018년 10월 24일
I always use "linprog" to solve this kind of problems.
Can you please tell me how to use "linprog" here?

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

 채택된 답변

Torsten
Torsten 2018년 10월 29일
편집: Torsten 2018년 10월 29일

0 개 추천

- Take L, Qt, St as variables to be solved for.
- Define upper bounds ub and lower bounds lb to account for
0 Qt ≤ Qm
Sd ≤ St ≤ Sm
- Define matrix Aeq and vector beq to account for
St - St-1 + Qt = It
- Define matrix A and vector b to account for
Qt - L 0
- Define the vector f as (1,0,0,...,0).
- Call linprog.
Best wishes
Torsten.

추가 답변 (0개)

카테고리

제품

릴리스

R2018a

태그

질문:

2018년 10월 24일

편집:

2018년 10월 29일

Community Treasure Hunt

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

Start Hunting!

Translated by