-
Notifications
You must be signed in to change notification settings - Fork 0
/
p2p_model-julia_init.jl
117 lines (79 loc) · 3.3 KB
/
p2p_model-julia_init.jl
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
##### P2P Main File #####
##### activate environment #####
using Pkg
Pkg.activate(pwd())
##### packages #####
using JuMP
##### data read #####
data_file = "_input/input_data.xlsx";
@info "The data input file is set to" data_file
# data file
include("p2p_model-julia_data_read.jl");
##### MCP model #####
# model file
include("p2p_model-julia_mcp.jl");
# model run specific parameters
p_eex = 6.44;
p_dso = 3.48;
p_tso = 3.44;
p_eeg = 6.52;
p_td = 8.85;
@info "price parameters" p_eex p_dso p_tso p_eeg p_td
p_i = p_dso + p_tso + p_eeg + p_td; # consumption from LBM
p_g = p_eex + p_dso + p_tso + p_eeg + p_td; # consumption from grid
## build and run P2P MCP model
setups = [1:6;];
for s in setups
if s==1
@info "1 - BAU Feed-in"
p2p_mcp = build_p2p_mcp_model(N, T, p_g, p_i, p_d)
fix.(p2p_mcp[:I], 0; force=true) # no import
fix.(p2p_mcp[:X], 0; force=true) # no export
fix.(p2p_mcp[:S_C], 0; force=true) # no storage
fix.(p2p_mcp[:S_D], 0; force=true) # no storage
fix.(p2p_mcp[:S], 0; force=true) # no storage
elseif s==2
@info "2 - Local Sharing"
p_i = p_dso + p_td; # consumption from LBM
p2p_mcp = build_p2p_mcp_model(N, T, p_g, p_i, p_d)
fix.(p2p_mcp[:F], 0; force=true) # no feed-in
fix.(p2p_mcp[:S_C], 0; force=true) # no storage
fix.(p2p_mcp[:S_D], 0; force=true) # no storage
fix.(p2p_mcp[:S], 0; force=true) # no storage
elseif s==3
@info "3 - Home Storage"
p2p_mcp = build_p2p_mcp_model(N, T, p_g, p_i, p_d)
fix.(p2p_mcp[:I], 0; force=true) # no import
fix.(p2p_mcp[:X], 0; force=true) # no export
fix.(p2p_mcp[:F], 0; force=true) # no feed-in
elseif s==4
@info "4 - Home Storage & Local Sharing"
p_i = p_dso + p_td; # consumption from LBM
p2p_mcp = build_p2p_mcp_model(N, T, p_g, p_i, p_d)
fix.(p2p_mcp[:F], 0; force=true) # no feed-in
elseif s==5
@info "5 - Current Regulatory Framework for 4"
p_i = p_dso + p_tso + p_eeg + p_td; # consumption from LBM
p2p_mcp = build_p2p_mcp_model(N, T, p_g, p_i, p_d)
fix.(p2p_mcp[:F], 0; force=true) # no feed-in
elseif s==6
@info "6 - Tech4All"
p_i = p_dso + p_tso + 0.4 * p_eeg + p_td; # consumption from LBM
p_d = p_d .+ 0.4 * p_eeg; # consumption from storage
p2p_mcp = build_p2p_mcp_model(N, T, p_g, p_i, p_d)
fix.(p2p_mcp[:F], 0; force=true) # no feed-in
end
set_optimizer_attribute(p2p_mcp, "output", "no")
set_optimizer_attribute(p2p_mcp, "output_options", "yes")
set_optimizer_attribute(p2p_mcp, "output_errors", "yes")
set_optimizer_attribute(p2p_mcp, "output_major_iterations", "yes")
set_optimizer_attribute(p2p_mcp, "output_final_statistics", "yes")
set_optimizer_attribute(p2p_mcp, "output_final_summary", "yes")
set_optimizer_attribute(p2p_mcp, "cumulative_iteration_limit", 100000)
set_optimizer_attribute(p2p_mcp, "minor_iteration_limit", 10000)
set_optimizer_attribute(p2p_mcp, "convergence_tolerance", 1e-2)
set_optimizer_attribute(p2p_mcp, "lemke_start", "always")
optimize!(p2p_mcp)
@show termination_status(p2p_mcp)
export_parameters_mcp(p2p_mcp,s)
end