diff --git a/src/demoses_distibuted_optimization/define_consumer_parameters.py b/src/demoses_distibuted_optimization/define_consumer_parameters.py new file mode 100644 index 0000000000000000000000000000000000000000..67215366a43bceb3d2d55d2efc8bbbe2895d99bc --- /dev/null +++ b/src/demoses_distibuted_optimization/define_consumer_parameters.py @@ -0,0 +1,44 @@ +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