The problem at hand is to develop the code for the mictrocontroller of an autonomous thermostat for a building with multiple rooms. The goal is to minimize power usage while ensuring that the temperature in each room is maintained at a comfortable level. The system must take into account various factors such as the current day of the week, time of the day, external temperature, and motion prediction in each room. Based on this data the system has to determine the radiator schedule for a number of time intervals.
The goal of this example is of demonstrating how SOLVER-AI can be used to optimize energy usage in smart home systems. It showcases the use of predictive modeling in anticipating room occupancy and temperature changes, leading to more efficient energy usage. The system forecasts future states enabling it to make proactive decisions and optimize performance.
The example also showcases how the system can intelligently adapt to changes in habits by uploading updated historical data.
Don't forget to also have a look at Implementing a Readily Deployed Solar Plant Sizing Tool in 400 Lines of Code.
The clients with its examples can be downloaded from https://github.com/SOLVER-AI-LTD/client. The code can be found in:
Let's consider a building with numRooms
number of rooms. We'll refer to i
as the room number, with i
being an integer in range [0, numRooms-1]. The building is fitted with an autonomous thermostat which:
Dth
(1/6 hour in the example). The file has as columns:weekday
: Day of the week, integer in range [0, 6] where 0 is Monday and 6 is Sunday.th
: Time of the day in hours, with range [0, 23.99]. motion_i
: Motion in room i
, which has value 1 if motion was detected in the interval Dth
and 0 if no motion was detected.Dth
and stores it in a temperatureSensorData.csv, which has columns:C_i
: State of the radiator in room i
, which has values 0 if off and 1 if on.T_i
: Temperature in room i
.Te
: External temperature.DTh_i
: Temperature variation in room i
in the time interval Dth
.power
: Power consumption during interval Dth
.Objectives and Constraints
Considering numForecastIntervals
times, spaced by Dth, our objective is to determine the radiator states C_i_j
for each of the times th_j
and weekday_j
, so that:
i
the temperature is greater than a required temperature requiredT_j
.i
the temperature is greater than a required Tmin_j
.
The implementation that can be found in the code is as depicted in the image below, with N
= numForecastIntervals
- 1.
Autonomous Thermostat Implementation (for room i).
The columns correspond to the different times j
, with each subsequent column at Dth
time difference from the previous one.
at j = 0
i
: temperature T_i_0
, the current state of the radiators C_i_0
and the external temperature.DTh_i_0
and power_0
.at j = 1
th_1
and weekday_1
by adding Dth
to the previous time and weekday.T_i_1
from DTh_i_0
from the prediction at the previous step.Te
.C_i_1
temperatureSensorData.csv can be used for predicting DTh_i_1
and power_1
.at j, where j is greater or equal to 2 and smaller than N
th_j
and weekday_j
by adding Dth
to the previous time and weekday.T_i_j
from DTh_i_1
from the prediction at the previous step.Te
.C_i_j
temperatureSensorData.csv can be used for predicting DTh_i_j
and power_j
.motion_i_j
.motion_i_j
and the required temperature requiredT_i
relative to room i
:motion_i_j
is greater than 0.4 (the probability of having movement is greater than 40%) then Tconstraint_i_j is the difference between the current temperature T_i_j
and the requiredT_i temperature for room i
.T_i_j
is a large positive number.Tmin_i
, TconstraintMin_i_j
is the difference between the current temperature T_i_j
and the minimum temperature.at j = N = numForecastIntervals - 1
th_N
and weekday_N
by adding Dth
to the previous time and weekday.T_i_N
from DTh_i_1
from the prediction at the previous step.motion_i_N
.motion_i_N
and the required temperature requiredT_i
relative to room i
:motion_i_N
is greater than 0.4 (the probability of having movement is greater than 40%) then Tconstraint_i_N is the difference between the current temperature T_i_N
and the requiredT_i temperature for room i
.T_i_N
is a large positive number.Tmin_i
, TconstraintMin_i_N
is the difference between the current temperature T_i_N
and the minimum temperature.Therefore, in order to perform this implementation, we need to set up:
th_j
and weekday_j
Te_j
, where in this case we consider all of them equal to Te
.numForecastIntervals
- 2.numForecastIntervals
- 1.T_i_j
for j
from 1 to numForecastIntervals
- 1.Tconstr_i_j
for j
from 2 to numForecastIntervals
- 1.TconstrMin_i_j
for j
from 2 to numForecastIntervals
- 1.power
as the sum of the power_j
for j
from 1 to numForecastIntervals
- 2.We'll then have to set:
th_0
, weekday_0
) and the the state values for j
= 0, T_i_0
for each room.requiredT_i
.Tmin_i
.Dth
.C_i_j
for all rooms and i
and j
from 1 to numForecastIntervals
- 2 to vary between 0 and 1 and be an integer.Tconstr_i_j
is greater than 0 for j
from 0 to numForecastIntervals
- 1.TconstrMin_i_j
is greater than 0 for j
from 0 to numForecastIntervals
- 1.power
to be minimized.In the code we:
Notes:
The code provided in example_thermostat perform all of the operations, from createion of the modules and Problem, to execution, to deletion. This would obviously not be the case if this was implemented in reality. We could imagine that: