Linear Programming - Optimization Over One Year

3 次查看(过去 30 天)
Dear Community,
I am totally stuck on this problem and am really looking forward to your ideas:
I try to find a solution to a linear optimization problem. I want to maximize the total arbitrage value for one year. In each hour arbitrage can be defined as the product of price (Pt) and amount of energy (Et). The amount is positive when energy is bought and negative when energy is sold.
The optimization function can be defined as:
max (Pt*Et) summed over one year (t=1 to t=8670)
There are two constraints to this function:
0 <= St <= Smax (Smax = Energy Capacity, constant)
-Pmax <= Et <= Pmax (Pmax = Power Limit, constant)
The hourly state of charge (St) is defined as follows:
St = St-1 + Et * n , if Et => 0 (with St-1 being the state of charge from the previous hour)
St = St-1 + Et * m , if Et < 0
I want the program to return the amount of energy stored or discharged for each hour of the year (8670 hours) so that the maximum arbitrage value for that year was reached. Means, it shall not optimize for each day but rather optimize for one whole year. If this problem turns out to be too heavy computational wise, one could shrink the time frame to two weeks.
Having consulted this help page ( Link ) I could not come up with a solution to optimize for a set of interdependent time steps. Can you?
Thanks so much in advance, Mathias

采纳的回答

Alan Weiss
Alan Weiss 2018-7-18
I think that you might find some enlightenment in these examples:
If you don't have a current version of the toolbox (R2017b or later) then use the solver-based examples linked from each of these problem-based examples.
Alan Weiss
MATLAB mathematical toolbox documentation

更多回答(1 个)

Mathias Dirksmeier
Mathias Dirksmeier 2018-7-18
Hi Alan,
thanks for your reply. I also made a first, own attempt. Would you give me some feedback on this? I actually struggle a lot with the nonlinear constraint as I need to define the hourly state of charge, which is itself dependent on the energy sold or bought the period before.
fun = @(x)sum(x.*p);
a1(1:length(p)) = 1;
a2(1:length(p)) = -1;
A = [a1; a2]; % Linear inequality constraint: A*x ≤ b.
b = Pmax;
x0(1:length(p)) = 0; % Starting solution
Aeq = []; % Linear Equality constraint: Aeq*x = beq
beq = [];
lb = []; % Lower and upper bounds: lb ≤ x ≤ ub
ub = [];
nonlcon = @capacity; % Nonlinear inequalities or equalities: c(x) ≤ 0 and ceq(x) = 0
x = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon);
And the nonlinear constraint function:
function [c,ceq] = capacity(x)
S(0)= Smax/2;
for i = 1:length(x)
if x >= 0
c = Smax - S(i-1) - x * n;
S(i)=S(i-1) + x * n;
else
c = Smax - S(i-1) - x * m;
S(i)=S(i-1) + x * m;
end
end
ceq = [];
I am really curious for your take on this!
  9 个评论
Mathias Dirksmeier
Mathias Dirksmeier 2018-7-24
Well, wouldn't that make the problem even harder to solve? Is a MIP easier to solve than a Nonlinear Program?
Alan Weiss
Alan Weiss 2018-7-24
It depends on the MILP and the nonlinear program. There are a lot of tricks that can be used to solve an MILP because it is linear in the variables. Nonlinear problems are quite hard in general. But again, it depends on the problems.
Alan Weiss
MATLAB mathematical toolbox documentation

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Problem-Based Nonlinear Optimization 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by