-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcharge.m
More file actions
68 lines (55 loc) · 1.45 KB
/
charge.m
File metadata and controls
68 lines (55 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
N = 5000;
rho = [0.1:0.1:3];
Rmax = 50;
total_revenues = zeros(N,size(rho,2));
for rhoo = 1:size(rho,2)
for n = 1:N
R = zeros(24,1);
x = zeros(24,1);
P_d = zeros(24,1); P_d(1) = 50;
P_s = zeros(25,1);
W = zeros(25,1);
revenues = zeros(24,1);
charge_eff = 0.8;
discharge_eff = 0.8;
for t = 1:24
% Commitment
x(t) = (R(t)*discharge_eff+10)*rho(1,rhoo);
% Wind
W(t+1) = unifrnd(5,15);
% Spot Price
P_s(t+1) = P_d(t) + normrnd(3,2);
% Storage
excess = (max(W(t+1) - x(t),0));
shortage = max(x(t) - W(t+1),0);
if excess > 0
R(t+1) = min(R(t)+charge_eff*(excess),Rmax);
revenues(t) = x(t) * P_d(t);
else
if shortage < R(t)
R(t+1) = R(t) - shortage;
revenues(t) = x(t) * P_d(t);
else
R(t+1) = 0;
revenues(t) = x(t) * P_d(t) - (shortage - R(t)) * P_s(t+1);
end
end
% Next Price
if unifrnd(0,1) < 0.5
change = 1;
else
change = -1;
end
P_d(t+1) = P_d(t) + change;
end
total_revenues(n,rhoo) = sum(revenues);
end
end
tr_mean = mean(total_revenues)
plot(rho,tr_mean,'r')
xlabel('Rho')
ylabel('Mean Total Revenue')
title('Rho VS Mean Total Revenue')
max(tr_mean)
[val,idx]=max(tr_mean,[],2)
rho(1,idx)