Sorry to bother @davidusb
Okay I’m a bit stuck here, I’ve reduced my def_total_hours to 1 and 0, with the start timestep 0,26 and 26,26. But still getting infeasible.
Am I missing something ? I feel like I’m missing something reaaaaaally basic…
But I did some googling - my power_var_no_loads were negative a few times yesterday - is it related to this? If so - I’ve just fixed the template to be always >= 0
/edit
I can run Day Ahead Optimsation and it will be Optimal but when I run MPC optimisation it goes Infeasible. Need to try again with fresh eyes tomorrow…
2024-06-01 01:54:47,680 - web_server - INFO - Passed runtime parameters: {'soc_init': 0.06, 'prod_price_forecast': [0.15, 0.1, 0.09, 0.09, 0.09, 0.09, 0.08, 0.09, 0.09, 0.12, 0.17, 0.27, 0.32, 0.32, 0.24, 0.31, 0.14, 0.06, 0.05, 0.05, 0.06, 0.04, 0.05, 0.04, 0.04, 0.33, 0.33, 0.35, 0.35, 0.42, 0.52, 0.58, 0.58, 0.58, 0.58, 0.42, 0.4, 0.12, 0.11, 0.09, 0.08, 0.1, 0.09, 0.09, 0.09, 0.08, 0.08, 0.08], 'load_cost_forecast': [0.26, 0.21, 0.19, 0.19, 0.19, 0.19, 0.18, 0.19, 0.19, 0.22, 0.27, 0.39, 0.44, 0.44, 0.35, 0.43, 0.24, 0.18, 0.16, 0.16, 0.18, 0.16, 0.16, 0.16, 0.16, 0.42, 0.42, 0.44, 0.44, 0.51, 0.63, 0.7, 0.7, 0.7, 0.7, 0.52, 0.5, 0.22, 0.21, 0.19, 0.18, 0.21, 0.19, 0.19, 0.19, 0.18, 0.18, 0.18], 'pv_power_forecast': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 80.69999999999999, 296, 959.8, 1774.4, 2450.7, 2909.2, 3880, 3920.4, 3698.6, 3252.5, 2844.1, 2508.4, 2321.8999999999996, 2238.9, 2009.9, 1507.3000000000002, 937.4, 381.2, 123.30000000000001, 22.4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 'num_def_loads': 2, 'def_total_hours': [4, 2], 'P_deferrable_nom': [3600, 6000], 'def_start_timestep': [0, 0], 'def_end_timestep': [0, 0], 'set_def_constant': [False, True], 'treat_def_as_semi_cont': [True, True]}
2024-06-01 01:54:47,680 - web_server - INFO - >> Setting input data dict
2024-06-01 01:54:47,680 - web_server - INFO - Setting up needed data
2024-06-01 01:54:47,683 - web_server - INFO - Retrieving weather forecast data using method = list
2024-06-01 01:54:47,683 - web_server - INFO - Retrieving data from hass for load forecast using method = naive
2024-06-01 01:54:47,684 - web_server - INFO - Retrieve hass get data method initiated...
2024-06-01 01:54:52,071 - web_server - INFO - >> Performing dayahead optimization...
2024-06-01 01:54:52,071 - web_server - INFO - Performing day-ahead forecast optimization
2024-06-01 01:54:52,080 - web_server - INFO - Perform optimization for the day-ahead
2024-06-01 01:54:52,086 - web_server - DEBUG - Deferrable load 0: Proposed optimization window: 0 --> 0
2024-06-01 01:54:52,086 - web_server - DEBUG - Deferrable load 0: Validated optimization window: 0 --> 0
2024-06-01 01:54:52,087 - web_server - DEBUG - Deferrable load 1: Proposed optimization window: 0 --> 0
2024-06-01 01:54:52,088 - web_server - DEBUG - Deferrable load 1: Validated optimization window: 0 --> 0
2024-06-01 01:54:52,401 - web_server - INFO - Status: Optimal
2024-06-01 01:54:52,401 - web_server - INFO - Total value of the Cost function = 0.09
2024-06-01 01:55:57,841 - web_server - INFO - Passed runtime parameters: {'soc_init': 0.06, 'prod_price_forecast': [0.15, 0.1, 0.09, 0.09, 0.09, 0.09, 0.08, 0.09, 0.09, 0.12, 0.17, 0.27, 0.32, 0.32, 0.24, 0.31, 0.14, 0.06, 0.05, 0.05, 0.06, 0.04, 0.05, 0.04, 0.04, 0.33, 0.33, 0.35, 0.35, 0.42, 0.52, 0.58, 0.58, 0.58, 0.58, 0.42, 0.4, 0.12, 0.11, 0.09, 0.08, 0.1, 0.09, 0.09, 0.09, 0.08, 0.08, 0.08], 'load_cost_forecast': [0.26, 0.21, 0.19, 0.19, 0.19, 0.19, 0.18, 0.19, 0.19, 0.22, 0.27, 0.39, 0.44, 0.44, 0.35, 0.43, 0.24, 0.18, 0.16, 0.16, 0.18, 0.16, 0.16, 0.16, 0.16, 0.42, 0.42, 0.44, 0.44, 0.51, 0.63, 0.7, 0.7, 0.7, 0.7, 0.52, 0.5, 0.22, 0.21, 0.19, 0.18, 0.21, 0.19, 0.19, 0.19, 0.18, 0.18, 0.18], 'pv_power_forecast': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 80.69999999999999, 296, 959.8, 1774.4, 2450.7, 2909.2, 3880, 3920.4, 3698.6, 3252.5, 2844.1, 2508.4, 2321.8999999999996, 2238.9, 2009.9, 1507.3000000000002, 937.4, 381.2, 123.30000000000001, 22.4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 'prediction_horizon': 44, 'num_def_loads': 2, 'P_deferrable_nom': [3600, 6000], 'def_start_timestep': [0, 0], 'def_end_timestep': [0, 0], 'soc_final': 0.06, 'treat_def_as_semi_cont': [True, True], 'set_def_constant': [False, True], 'weight_battery_discharge': 0.2, 'weight_battery_charge': 0, 'def_total_hours': [4, 2]}
2024-06-01 01:55:57,842 - web_server - INFO - >> Setting input data dict
2024-06-01 01:55:57,842 - web_server - INFO - Setting up needed data
2024-06-01 01:55:57,843 - web_server - INFO - Retrieve hass get data method initiated...
2024-06-01 01:55:59,553 - web_server - INFO - Retrieving weather forecast data using method = list
2024-06-01 01:55:59,554 - web_server - INFO - Retrieving data from hass for load forecast using method = naive
2024-06-01 01:55:59,554 - web_server - INFO - Retrieve hass get data method initiated...
2024-06-01 01:56:04,183 - web_server - INFO - >> Performing naive MPC optimization...
2024-06-01 01:56:04,184 - web_server - INFO - Performing naive MPC optimization
2024-06-01 01:56:04,191 - web_server - INFO - Perform an iteration of a naive MPC controller
2024-06-01 01:56:04,197 - web_server - DEBUG - Deferrable load 0: Proposed optimization window: 0 --> 0
2024-06-01 01:56:04,197 - web_server - DEBUG - Deferrable load 0: Validated optimization window: 0 --> 0
2024-06-01 01:56:04,198 - web_server - DEBUG - Deferrable load 1: Proposed optimization window: 0 --> 0
2024-06-01 01:56:04,198 - web_server - DEBUG - Deferrable load 1: Validated optimization window: 0 --> 0
2024-06-01 01:56:04,260 - web_server - INFO - Status: Infeasible
2024-06-01 01:56:04,261 - web_server - INFO - Total value of the Cost function = -2.70
[Edit 2] It’s come good now, it was the SOC_INIT being the same as SOC_FINAL
@Lildan you were right - I should’ve tried this first (but I forgot I could manually adjust the SOC to test). I think the battery was able to gain a bit of charge in the early morning light, so by the time I woke up EMHASS was tuning optimal.
soc_init = 0.06, soc_final = 0.06
2024-06-01 09:48:55,283 - web_server - INFO - Passed runtime parameters: {'soc_init': 0.06, 'prod_price_forecast': [0.09, 0.05, 0.06, 0.06, 0.06, 0.06, 0.07, 0.05, 0.05, 0.33, 0.33, 0.33, 0.34, 0.38, 0.48, 0.58, 0.58, 0.58, 0.51, 0.42, 0.4, 0.11, 0.11, 0.09, 0.09, 0.09, 0.09, 0.11, 0.09, 0.08, 0.08, 0.08, 0.08, 0.08, 0.07, 0.06, 0.06, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 'load_cost_forecast': [0.2, 0.17, 0.18, 0.18, 0.18, 0.18, 0.19, 0.16, 0.17, 0.42, 0.42, 0.42, 0.43, 0.48, 0.59, 0.7, 0.7, 0.7, 0.62, 0.52, 0.5, 0.22, 0.21, 0.19, 0.19, 0.19, 0.19, 0.21, 0.2, 0.18, 0.18, 0.18, 0.18, 0.18, 0.17, 0.16, 0.16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 'pv_power_forecast': [2019.2, 1873.6999999999998, 2618.3999999999996, 3577.3, 3171.1, 2453.6, 2226.5, 2155.6000000000004, 1947.2, 1435, 894.9, 354.9, 110.9, 22.2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 54.4, 244.79999999999998, 830.2, 1720.6, 2523.2000000000003, 3181.6], 'def_total_hours': [1, 1], 'prediction_horizon': 28, 'num_def_loads': 2, 'P_deferrable_nom': [3600, 6000], 'def_start_timestep': [0, 2], 'def_end_timestep': [8, 8], 'soc_final': 0.06, 'treat_def_as_semi_cont': [True, True], 'set_def_constant': [False, True], 'weight_battery_discharge': 0.2, 'weight_battery_charge': 0}
2024-06-01 09:48:55,283 - web_server - INFO - >> Setting input data dict
2024-06-01 09:48:55,283 - web_server - INFO - Setting up needed data
2024-06-01 09:48:55,285 - web_server - INFO - Retrieve hass get data method initiated...
2024-06-01 09:48:57,151 - web_server - INFO - Retrieving weather forecast data using method = list
2024-06-01 09:48:57,152 - web_server - INFO - Retrieving data from hass for load forecast using method = naive
2024-06-01 09:48:57,152 - web_server - INFO - Retrieve hass get data method initiated...
2024-06-01 09:49:01,627 - web_server - INFO - >> Performing naive MPC optimization...
2024-06-01 09:49:01,627 - web_server - INFO - Performing naive MPC optimization
2024-06-01 09:49:01,633 - web_server - INFO - Perform an iteration of a naive MPC controller
2024-06-01 09:49:01,637 - web_server - DEBUG - Deferrable load 0: Proposed optimization window: 0 --> 8
2024-06-01 09:49:01,637 - web_server - DEBUG - Deferrable load 0: Validated optimization window: 0 --> 8
2024-06-01 09:49:01,638 - web_server - DEBUG - Deferrable load 1: Proposed optimization window: 2 --> 8
2024-06-01 09:49:01,638 - web_server - DEBUG - Deferrable load 1: Validated optimization window: 2 --> 8
2024-06-01 09:49:01,672 - web_server - INFO - Status: Infeasible
2024-06-01 09:49:01,672 - web_server - INFO - Total value of the Cost function = -0.79
soc_init = 0.07, soc_final = 0.06
2024-06-01 09:49:20,795 - web_server - INFO - Passed runtime parameters: {'soc_init': 0.07, 'prod_price_forecast': [0.09, 0.05, 0.06, 0.06, 0.06, 0.06, 0.07, 0.05, 0.05, 0.33, 0.33, 0.33, 0.34, 0.38, 0.48, 0.58, 0.58, 0.58, 0.51, 0.42, 0.4, 0.11, 0.11, 0.09, 0.09, 0.09, 0.09, 0.11, 0.09, 0.08, 0.08, 0.08, 0.08, 0.08, 0.07, 0.06, 0.06, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 'load_cost_forecast': [0.2, 0.17, 0.18, 0.18, 0.18, 0.18, 0.19, 0.16, 0.17, 0.42, 0.42, 0.42, 0.43, 0.48, 0.59, 0.7, 0.7, 0.7, 0.62, 0.52, 0.5, 0.22, 0.21, 0.19, 0.19, 0.19, 0.19, 0.21, 0.2, 0.18, 0.18, 0.18, 0.18, 0.18, 0.17, 0.16, 0.16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 'pv_power_forecast': [2019.2, 1873.6999999999998, 2618.3999999999996, 3577.3, 3171.1, 2453.6, 2226.5, 2155.6000000000004, 1947.2, 1435, 894.9, 354.9, 110.9, 22.2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 54.4, 244.79999999999998, 830.2, 1720.6, 2523.2000000000003, 3181.6], 'def_total_hours': [1, 1], 'prediction_horizon': 28, 'num_def_loads': 2, 'P_deferrable_nom': [3600, 6000], 'def_start_timestep': [0, 2], 'def_end_timestep': [8, 8], 'soc_final': 0.06, 'treat_def_as_semi_cont': [True, True], 'set_def_constant': [False, True], 'weight_battery_discharge': 0.2, 'weight_battery_charge': 0}
2024-06-01 09:49:20,795 - web_server - INFO - >> Setting input data dict
2024-06-01 09:49:20,795 - web_server - INFO - Setting up needed data
2024-06-01 09:49:20,797 - web_server - INFO - Retrieve hass get data method initiated...
2024-06-01 09:49:22,566 - web_server - INFO - Retrieving weather forecast data using method = list
2024-06-01 09:49:22,566 - web_server - INFO - Retrieving data from hass for load forecast using method = naive
2024-06-01 09:49:22,567 - web_server - INFO - Retrieve hass get data method initiated...
2024-06-01 09:49:26,750 - web_server - INFO - >> Performing naive MPC optimization...
2024-06-01 09:49:26,750 - web_server - INFO - Performing naive MPC optimization
2024-06-01 09:49:26,756 - web_server - INFO - Perform an iteration of a naive MPC controller
2024-06-01 09:49:26,760 - web_server - DEBUG - Deferrable load 0: Proposed optimization window: 0 --> 8
2024-06-01 09:49:26,760 - web_server - DEBUG - Deferrable load 0: Validated optimization window: 0 --> 8
2024-06-01 09:49:26,761 - web_server - DEBUG - Deferrable load 1: Proposed optimization window: 2 --> 8
2024-06-01 09:49:26,761 - web_server - DEBUG - Deferrable load 1: Validated optimization window: 2 --> 8
2024-06-01 09:49:26,817 - web_server - INFO - Status: Optimal
2024-06-01 09:49:26,818 - web_server - INFO - Total value of the Cost function = -0.80
/Edit
Fixed a few more things and now it’s running much more reliably.
Ensured all my end/start timesteps are greater than or equal to 0 and rounded integer values (they were before, and I experimented with floats).
Ensured the prediction horizon is 5x timestep length (if < 3, default to 48).
To calculate runtime left of a load - I was calculating the current runtime of a load by it’s energy used / power draw, which meant sometimes a 0Wh / 3600W for hot water element, so I just checked if it was 0, leave as 0.
Ensured I wasn’t running MPC more than once a minute by using delay node with 1msg/min.
So far so good. Any other ideas/tips I could try?