Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
Bi-Level_EVA
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Daniel Strach
Bi-Level_EVA
Commits
717308f6
Commit
717308f6
authored
Jan 18, 2023
by
Christoph von Oy
Browse files
Options
Downloads
Patches
Plain Diff
Unified runme and runme_community
parent
8e00a996
No related branches found
No related tags found
No related merge requests found
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
Model_Library
+1
-1
1 addition, 1 deletion
Model_Library
runme.py
+117
-269
117 additions, 269 deletions
runme.py
runme_community.py
+0
-113
0 additions, 113 deletions
runme_community.py
with
118 additions
and
383 deletions
Model_Library
@
63dd8424
Compare
6dadedf5
...
63dd8424
Subproject commit 6
dadedf53098caad20ccadebdd8b67aa312cbf62
Subproject commit 6
3dd8424cf069f35f33428e94f50dee3fe2aab39
This diff is collapsed.
Click to expand it.
runme.py
+
117
−
269
View file @
717308f6
This diff is collapsed.
Click to expand it.
runme_community.py
deleted
100644 → 0
+
0
−
113
View file @
8e00a996
import
time
import
pandas
as
pd
import
Tooling.input_profile_processor.input_profile_processor
import
Model_Library.Prosumer.main
as
main
import
Model_Library.District.main_district
as
main_district
from
functools
import
partial
from
multiprocessing
import
Pool
from
tqdm
import
tqdm
import
os
def
process_each_prosumer
(
prosumer_name
,
prosumer_specification
,
input_profiles
,
t_horizon
,
t_step
,
prosumer_strategy
):
start_time
=
time
.
time
()
prosumer
=
main
.
Main
(
prosumer_name
,
prosumer_specification
,
input_profiles
,
t_horizon
,
t_step
)
after_setup_time
=
time
.
time
()
print
(
"
process_each_prosumer:
\t
Prosumer Construction [s]:
\t
"
+
str
(
after_setup_time
-
start_time
))
prosumer
.
run_optimization
(
prosumer_strategy
)
after_optimization_time
=
time
.
time
()
print
(
"
process_each_prosumer:
\t
Prosumer Optimization [s]:
\t
"
+
str
(
after_optimization_time
-
after_setup_time
))
prosumer
.
show_results
()
return
prosumer
.
prosumer
start_time
=
time
.
time
()
t_start
=
pd
.
Timestamp
(
"
2019-05-10 00:00:00
"
)
# start time of simulation
t_horizon
=
240
# number of time steps to be simulated
t_step
=
1
# length of a time step in hours
input_profile_dict
=
{
'
irradiance_1
'
:
[
'
irradiance
'
,
'
input_files/data/irradiance/Lindenberg2006BSRN_Irradiance_60sec.csv
'
],
'
temperature_1
'
:
[
'
air_temperature
'
,
'
input_files/data/temperature/temperature.csv
'
],
'
demand_electric_1
'
:
[
'
elec_demand
'
,
'
generate
'
,
3000
],
'
demand_heat_1
'
:
[
'
therm_demand
'
,
'
generate
'
,
6000
,
'
temperature_1
'
],
'
demand_hot_water_1
'
:
[
'
hot_water_demand
'
,
'
generate
'
,
1500
,
'
temperature_1
'
],
'
irradiance_2
'
:
[
'
irradiance
'
,
'
input_files/data/irradiance/Lindenberg2006BSRN_Irradiance_60sec.csv
'
],
'
temperature_2
'
:
[
'
air_temperature
'
,
'
input_files/data/temperature/temperature.csv
'
],
'
demand_electric_2
'
:
[
'
elec_demand
'
,
'
generate
'
,
3000
],
'
demand_heat_2
'
:
[
'
therm_demand
'
,
'
generate
'
,
6000
,
'
temperature_2
'
],
'
demand_hot_water_2
'
:
[
'
hot_water_demand
'
,
'
generate
'
,
1500
,
'
temperature_2
'
],
'
irradiance_3
'
:
[
'
irradiance
'
,
'
input_files/data/irradiance/Lindenberg2006BSRN_Irradiance_60sec.csv
'
],
'
temperature_3
'
:
[
'
air_temperature
'
,
'
input_files/data/temperature/temperature.csv
'
],
'
demand_electric_3
'
:
[
'
elec_demand
'
,
'
generate
'
,
0
],
'
demand_heat_3
'
:
[
'
therm_demand
'
,
'
generate
'
,
0
,
'
temperature_3
'
],
'
demand_hot_water_3
'
:
[
'
hot_water_demand
'
,
'
generate
'
,
0
,
'
temperature_3
'
],
'
elec_price_1
'
:
[
'
elec_price
'
,
'
input_files/data/prices/day-ahead/hourly_price.csv
'
]}
input_profiles
=
Tooling
.
input_profile_processor
.
input_profile_processor
.
process_input_profiles
(
input_profile_dict
,
t_start
,
t_horizon
,
t_step
)
after_input_processing_time
=
time
.
time
()
print
(
"
runme:
\t\t\t
Profile Processing [s]:
\t
"
+
str
(
after_input_processing_time
-
start_time
))
# 'topology_path': path to directory that contains the matrices that define the prosumer topology
# 'config_path': path to global configurations like prices, injection prices, emission costs, etc.
prosumer_dict
=
{
'
SCN2_CAT1_PV11_3000_6000
'
:{
'
topology_path
'
:
'
input_files/models/prosumer_models/SCN2_CAT1_PV11
'
,
'
config_path
'
:
'
input_files/models/prosumer_models/SCN2_CAT1_PV11/config.csv
'
,
'
profiles
'
:
{
'
irradiance
'
:
'
irradiance_1
'
,
'
air_temperature
'
:
'
temperature_1
'
,
'
elec_demand
'
:
'
demand_electric_1
'
,
'
therm_demand
'
:
'
demand_heat_1
'
,
'
hot_water_demand
'
:
'
demand_hot_water_1
'
}},
'
SCN0_CAT1_3000_6000
'
:
{
'
topology_path
'
:
'
input_files/models/prosumer_models/SCN0_CAT1
'
,
'
config_path
'
:
'
input_files/models/prosumer_models/SCN0_CAT1/config.csv
'
,
'
profiles
'
:
{
'
irradiance
'
:
'
irradiance_2
'
,
'
air_temperature
'
:
'
temperature_2
'
,
'
elec_demand
'
:
'
demand_electric_2
'
,
'
therm_demand
'
:
'
demand_heat_2
'
,
'
hot_water_demand
'
:
'
demand_hot_water_2
'
}}}
prosumer_strategy
=
[
'
annuity
'
]
parallel_processing
=
False
before_optimization_time
=
time
.
time
()
print
(
"
runme:
\t\t\t
Prosumer Setup [s]:
\t\t
"
+
str
(
before_optimization_time
-
after_input_processing_time
))
# Run multiple independent prosumers in parallel on multiple cores
prosumers
=
dict
.
fromkeys
(
prosumer_dict
.
keys
())
if
parallel_processing
:
count_processes
=
len
(
prosumer_dict
.
keys
())
pool
=
Pool
(
os
.
cpu_count
())
parallel_func
=
partial
(
process_each_prosumer
,
input_profiles
=
input_profiles
,
t_horizon
=
t_horizon
,
t_step
=
t_step
,
prosumer_strategy
=
prosumer_strategy
)
mapped_values
=
list
(
tqdm
(
pool
.
map
(
parallel_func
,
list
(
prosumer_dict
.
keys
()),
list
(
prosumer_dict
.
values
())),
total
=
count_processes
))
# Normal processing, one core only
else
:
for
prosumer_name
in
list
(
prosumer_dict
.
keys
()):
prosumers
[
prosumer_name
]
=
process_each_prosumer
(
prosumer_name
,
prosumer_dict
[
prosumer_name
],
input_profiles
,
t_horizon
,
t_step
,
prosumer_strategy
)
after_optimization_time
=
time
.
time
()
print
(
"
runme:
\t\t\t
Prosumer Optimization [s]:
\t
"
+
str
(
after_optimization_time
-
before_optimization_time
))
start_community_time
=
time
.
time
()
community_assets_dict
=
{
'
ca_bat
'
:
{
'
topology_path
'
:
'
input_files/models/district_models/example_CA
'
,
'
config_path
'
:
'
input_files/models/district_models/example_CA/config.csv
'
,
'
profiles
'
:
{
'
irradiance
'
:
'
irradiance_3
'
,
'
air_temperature
'
:
'
temperature_3
'
,
'
elec_demand
'
:
'
demand_electric_3
'
,
'
therm_demand
'
:
'
demand_heat_3
'
,
'
hot_water_demand
'
:
'
demand_hot_water_3
'
}}}
community_assets_strategy
=
'
sizing_max_operational_profit
'
before_community_assets_time
=
time
.
time
()
print
(
"
runme:
\t\t\t
Community Assets Setup [s]:
\t
"
+
str
(
before_community_assets_time
-
start_community_time
))
community_assets
=
main
.
Main_CA
(
community_assets_dict
,
input_profiles
,
t_horizon
,
t_step
).
community_assets
after_community_assets_time
=
time
.
time
()
print
(
"
runme:
\t\t\t
Community Assets Constr. [s]:
\t
"
+
str
(
after_community_assets_time
-
before_community_assets_time
))
community_dict
=
{
'
community
'
:
{
'
config_path
'
:
'
input_files/models/district_models/example_community/config.csv
'
,
'
profiles
'
:
{
'
elec_price
'
:
'
elec_price_1
'
}}}
community_strategy
=
[
'
max_operational_profit
'
]
before_community_optimization_time
=
time
.
time
()
print
(
"
runme:
\t\t\t
Comm. Optimization Setup [s]:
\t
"
+
str
(
before_community_optimization_time
-
after_community_assets_time
))
community_main
=
main_district
.
MainDistrict
(
community_dict
,
prosumers
,
community_assets
,
input_profiles
,
t_horizon
,
t_step
,
community_assets_strategy
,
community_strategy
)
after_community_optimization_time
=
time
.
time
()
print
(
"
runme:
\t\t\t
Community Optimization [s]:
\t
"
+
str
(
after_community_optimization_time
-
before_community_optimization_time
))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment