I would like to assign a single value to a paramter that depends on a created set in Pyomo. I have the following code:
import SetUpScenarios import pyomo.environ as pyo import pandas as pd #Define the model model = pyo.ConcreteModel() #Define the sets model.set_timeslots = pyo.RangeSet(1, SetUpScenarios.numberOfTimeSlotsPerDay) #Reading of the data df_buildingData = pd.read_csv("C:/Users/Data/H9_HH1 - Day_4.csv", sep =";") #Create the dictionaries for the set #dictionaryHeatDemand= df_buildingData.set_index('Timeslot')['Q_htg'].to_dict() model.param_heatDemand = pyo.Param(model.set_timeslots, initialize=df_buildingData['Q_htg']) model.param_heatDemand.pprint()
Normally I did that with a dictionary but here the dataframe does not include the set 'timeslot' and with my currently used assignment "model.param_heatDemand = pyo.Param(model.set_timeslots, initialize=df_buildingData['Q_htg'])" the whole dataframe column is assigned to each value of the set. But I just want the first entry of the dataframe column 'Q_htg' to be assigned to the first value of the set timeslots. Any idea how I can do that? I'd appreciate every comment.
Update: A little more information to the code and the data The 'SetUpScenario' class just sets up static values that I can use in other classes. So for this example it is just important to know that the variable 'SetUpScenarios.numberOfTimeSlotsPerDay' has the value 288 (one day with a time resolution of 5 minutes). The dataframe df_buildingData contains 5 columns with 288 values each (one for each timeslot with a resolution of 5 minutes). One of them is the heat demand 'Q_htg'. The values of the Pyomo parameter 'model.param_heatDemand' should just contain one heat demand value of the row 'Q_htg' for each of the 288 elements of the Set 'model.set_timeslots'. So the first value in the set 'model.set_timeslots' should be assigned the first value of the dataframe column 'Q_htg'. The second value in the set 'model.set_timeslots' should be assigned the second value of the dataframe column 'Q_htg' and so on. Both of them have 288 entries.
Does anybody have an idea how I can do that?