Skip to content
Snippets Groups Projects
Commit 6a7f41a1 authored by Christian Doh Dinga's avatar Christian Doh Dinga
Browse files

define consumer parameters

parent d1ce1f69
No related branches found
No related tags found
No related merge requests found
import pandas as pd
import pyomo.environ as pyo
from typing import Dict
def define_consumer_parameters(agent: str, model: pyo.AbstractModel, data: Dict, ts: pd.DataFrame) -> pyo.AbstractModel:
# Extract consumer parameter values from data
total_consumers = data['General']['totConsumers']
share_of_agent = data['Consumers'][agent]['Share']
# Demand
normalized_demand_profile = ts.loc[:, data['Consumers'][agent]['D']].values
demand_profile = total_consumers * share_of_agent * normalized_demand_profile
# PV
pv_availability_factor = ts.loc[:, data['Consumers'][agent]['PV_AF']].values
pv_capacity = data['Consumers'][agent]['PV_cap']
pv_profile = total_consumers * share_of_agent * pv_capacity * pv_availability_factor
# Declare consumer optimization parameters (but do not construct yet)
model.demand_profile = pyo.Param(model.time, name='demand_profile', initialize=dict(enumerate(demand_profile)), mutable=False)
model.pv_profile = pyo.Param(model.time, name='pv_profile', initialize=dict(enumerate(pv_profile)), 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')
# consumer_agents = [id for id in data['Consumers'].keys()]
# ts = pd.read_csv('timeseries.csv', delimiter=';')
# mdict = {m: define_common_parameters(m, data) for m in consumer_agents}
# for agent, model in mdict.items():
# model = define_consumer_parameters(agent, model, data, ts)
# print(model.name)
# print()
# model.pprint()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment