I know how to assign values from a single dictionary to a 1-dimensional parameter in Pyomo. For that I use the following code
import pyomo.environ as pyo
import pandas as pd
#Define the model
model = pyo.ConcreteModel()
#Read the dataframe from file for one building
df_buildingData = pd.read_csv("C:/Users/Data/H9_HH" + str(1) + "_Day_" + str(4) +".csv", sep =";")
#Define the sets
model.set_timeslots = pyo.RangeSet(1, 288)
#Create the dictionaries for the set
dictionaryHeatDemand_In_W= df_buildingData.set_index('Timeslot')['Q_htg'].to_dict()
#Assign the values from a single dictionary to a 1-dimensional parameter
model.param_heatDemand_In_W = pyo.Param(model.set_timeslots, initialize=dictionaryHeatDemand_In_W)
model.param_heatDemand_In_W.pprint()
and I get the following output
So far so good. However, now I would like to have a 2-dimensional parameter that is based on the set "model.set_timeslots" and the parameter "model.set_buildings". To do that I used the same code but I changed it such that I always work with lists (one entry for every building). Here is the code for the 2-dimensional parameter:
import pyomo.environ as pyo
import pandas as pd
#Define the model
model = pyo.ConcreteModel()
#Reading of the data
list_df_buildingData_mHP_EV= [pd.read_csv("C:/Users/Data/H9_HH" + str(index) + "_Day_" + str(4) +".csv", sep =";") for index in range (1, 4)]
#Define the sets
model.set_timeslots = pyo.RangeSet(1, 288)
model.set_buildings = pyo.RangeSet(1, 3)
#Create the dictionaries for the set
list_dictionaryHeatDemand_In_W_mHP_EV= [list_df_buildingData_mHP_EV[index].set_index('Timeslot')['Q_htg'].to_dict() for index in range (0, 3)]
#Define the parameters of the model in pyomo
model.param_heatDemand_In_W = pyo.Param(model.set_timeslots,model.set_buildings, initialize=list_dictionaryHeatDemand_In_W_mHP_EV)
model.param_heatDemand_In_W.pprint()
However, the outcome when using model.param_heatDemand_In_W.pprint()
does not like the one I would like to have. Here you see a screenshot. There is always a key values at the beginning starting from (1,1) to (288,3). For each of those key values there are 288 entries (288 is the number of set_timeslots). I would like to have a 2-dimensional parameter param_heatDemand_In_W (building, timeslot). So the parameter should have for each of the 3 buildings, 288 timeslots and for each of those timeslots there should be 1 value for the heatDemand.
Any idea how I can do that? I'd appreciate every comment.