This is effectively what a thermostat does.
The problem is that the controller won't know how well insulated each room is, how cold it is outside (including wind speed), which doors and windows are open and when, what people or devices are doing in each room.
The way thermostats solve this is by creating a closed loop where they react to how the room reacts to their actions.
Depending on how your heaters work you'll likely need some dynamic component to react to these unforeseen changes unless you can live with the temperature being very unstable.
To get a rough idea of how long the heaters will have to run you can look at each room in for the last n days and see if the heater's runtime was long enough to (on average) hold your target temperature. Dividing the average temperature with the target temperature will give you an idea whether they were on for too long or too short. (If the heaters have thermostats you'll likely need to subtract a small amount from that value so that it will settle at the minimum required heating time)
If that value is close to 1.0 you know that on those days the heating time was just about perfect.
Once that is the case you can take the previous days heating time and divide it up over the cheapest hours. The smaller of a value n you choose the more reactive the system will be but it will also get a little more unstable. Depending on your house and climate this system described here might simply be unsuitable for you because it takes too long to react to changes.
There are many other ways to approach this very interesting problem. You could for example try to create a more accurate model incorporating weather and other data with machine learning. That way it could even do rudimentary forecasting.