-
Notifications
You must be signed in to change notification settings - Fork 1
/
testCalculation.m
51 lines (35 loc) · 1.16 KB
/
testCalculation.m
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
clear
close all
load Grid.mat
tNum = 50;
%% Proposed
tic
[CPrice,SNum] = calCPrice_PTDF_num(PD0(:,tNum),PR(:,tNum));
toc
load('CCarbon.mat','CCarbon');
delta = 0.0001;
Cgen_k1 = Cgen_k+delta*CCarbon;
pg = sdpvar(Ngen,1);
pr = sdpvar(NR,1);
obj_opf = sum(Cgen_k1'*pg*Delta_t);
con1_opf = (1-losskappa)'*(Igen*pg+IR*pr-PD0(:,tNum)) == 0;
con2_opfa = PTDF_l*(Igen*pg+IR*pr-PD0(:,tNum)) <= Sbranch_l;
con2_opfb = -PTDF_l*(Igen*pg+IR*pr-PD0(:,tNum)) <= Sbranch_l;
con3_opf = [PMINgen <= pg <= PMAXgen,0 <= pr <= PR(:,tNum)];
con4_opf = [];
con_opf = [con1_opf,con2_opfa,con2_opfb,con3_opf,con4_opf];
optimize(con_opf,obj_opf,sdpsettings('verbose',0));
PG = value(pg);
(abs((CCarbon')*PG/2-sum(CPrice.*(PD0(:,tNum)))))/((CCarbon')*PG/2)
%% Numerical derivative and integral
Sample = 10;
tic
CPrice = calCPrice_PTDF_numerical_derivative(PD0(:,tNum),PR(:,tNum),Sample);
toc
(abs((CCarbon')*PG/2-sum(CPrice.*(PD0(:,tNum)))))/((CCarbon')*PG/2)
%% Numerical integral
Sample = 10;
tic
CPrice = calCPrice_PTDF_numerical_integral(PD0(:,tNum),PR(:,tNum),Sample);
toc
(abs((CCarbon')*PG/2-sum(CPrice.*(PD0(:,tNum)))))/((CCarbon')*PG/2)