Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DEMOSES-distributed-optimization
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
DEMOSES
DEMOSES-distributed-optimization
Commits
53add548
Commit
53add548
authored
8 months ago
by
Christian Doh Dinga
Browse files
Options
Downloads
Patches
Plain Diff
define generator parameters
parent
6a7f41a1
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/demoses_distibuted_optimization/define_generator_parameters.py
+44
-0
44 additions, 0 deletions
...es_distibuted_optimization/define_generator_parameters.py
with
44 additions
and
0 deletions
src/demoses_distibuted_optimization/define_generator_parameters.py
0 → 100644
+
44
−
0
View file @
53add548
import
numpy
as
np
import
pandas
as
pd
from
typing
import
Dict
import
pyomo.environ
as
pyo
def
define_generator_parameters
(
agent
:
str
,
model
:
pyo
.
AbstractModel
,
data
:
Dict
,
ts
:
pd
.
DataFrame
)
->
pyo
.
AbstractModel
:
# Declare generator cost function parameters (OPEX are parametrized as a/2 * g**2 + b * g)
model
.
gen_cost_param_a
=
pyo
.
Param
(
name
=
'
gen_cost_param_a
'
,
initialize
=
data
[
'
Generators
'
][
agent
][
'
a
'
],
mutable
=
False
)
model
.
gen_cost_param_b
=
pyo
.
Param
(
name
=
'
gen_cost_param_b
'
,
initialize
=
data
[
'
Generators
'
][
agent
][
'
b
'
],
mutable
=
False
)
# Declare generator installed capacity parameter
model
.
gen_installed_capacity
=
pyo
.
Param
(
name
=
'
gen_installed_capacity
'
,
initialize
=
data
[
'
Generators
'
][
agent
][
'
C
'
],
mutable
=
False
)
# Get generator available capacity timeseries: installed capacity * availability factor
if
'
AF
'
in
data
[
'
Generators
'
][
agent
].
keys
():
available_capacity
=
model
.
gen_installed_capacity
*
ts
.
loc
[:,
data
[
'
Generators
'
][
agent
][
"
AF
"
]].
values
else
:
available_capacity
=
model
.
gen_installed_capacity
*
np
.
ones
(
data
[
'
General
'
][
"
nTimesteps
"
])
# Declare available capacity parameter
available_capacity_dict
=
dict
(
enumerate
(
available_capacity
))
model
.
available_capacity
=
pyo
.
Param
(
model
.
time
,
name
=
'
available_capacity
'
,
initialize
=
available_capacity_dict
,
domain
=
pyo
.
Reals
,
mutable
=
False
)
return
model
# # Example usage
# import yaml
# from define_common_parameters import define_common_parameters
# def read_config(config_file):
# with open(config_file, 'r') as file:
# config = yaml.safe_load(file)
# return config
# data = read_config('config.yaml')
# generator_agents = [id for id in data['Generators'].keys()]
# ts = pd.read_csv('timeseries.csv', delimiter=';')
# for agent in generator_agents:
# model = define_common_parameters(agent, data)
# model = define_generator_parameters(agent, model, data, ts)
# print(model.name)
# print()
# model.pprint()
\ No newline at end of file
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