Hot answers tagged

2

In your specific instance you use only a single index for a two-dimensional variable matrix, causing the KeyError. You should loop over the index sets from your model to produce the results, so for example: outputVariables_list = [model.variable_heatGenerationCoefficient_SpaceHeating[building, time_slot], model.variable_temperatureBufferStorage[building, ...


2

I don't know your entire code or the errors you get, but the general way is optimal_values = [value(model.x[key]) for key in model.x] df = pd.DataFrame(optimal_values) where model.x is your target variable that is optimized.


Only top voted, non community-wiki answers of a minimum length are eligible