So let's continue with the idea of an optimal HVAC control. We'll assume the following things:

1. We have a simple HVAC unit with a constant power output which is turned on or off and the duty cycle can be varied. We will assume that any duty cycle is possible in contrast to reality where you have to worry about breaking the machine. Alternatively we can assume that the machine is continuous variable speed so that the power output can be varied from 0 to 1 times the maximum output. This is a good place to start since it tells us what we could do with the ideal machine (such variable speed machines do exist but are rare in home applications, real systems typically have to be off for several minutes before restarting for machine protection so duty cycles are limited).
2. We have a temperature sensor inside the house which reads the current average air temperature.
3. We know the external air temperature as a function of time by a very good forecast. Perhaps it's a heat wave and today is going to be just like yesterday. The point is we can use information about the future external temperature to help us optimize the schedule, again it gives us a "best case" scenario.

Let's define a nondimensional version of the problem. We want to keep the temperature at 75F say (~24C), so we will define a new temperature variable T which is zero when the true temperature is 75. Also, let's define a "sensitivity scale" which is 2 degrees F, if things change by that much we will notice, so T = (Temp - 75F) / 2F, which you will notice is the ratio of two measurements in the same units, and therefore has no units, that's what we mean by "nondimensional", in other words T is just a number that expresses how far away from our set point we are in multiples of our sensitivity amount which we decided was 2 degrees F.

Now we can define a badness (per unit time) function by some important properties:

Badness is a function of our T variable, and our T variable is equal to zero at our preferred temperature.  Therefore:

${\rm Badness}(0) = 0$

$\frac{d{\rm Badness}}{dT}|_{T=0} = 0$

Finally, since badness is on an arbitrary scale, we can define the unit of badness as how bad it is to be one T unit above optimal for one unit of time. This means: ${\rm Badness}(1) = 1$

Now the rest of the badness curve can be defined according to personal preference. Initially I had thought to cause Badness to go to $+\infty$ at some small distance from 0, perhaps corresponding to 90F and 65F, because I thought it would be desirable to force the system to keep the building from getting too cold or too hot, but I now think those singular points should be at physically significant points so that we are dealing with finite badness for all conceivably realistic temperatures. So for example at 105F we have a significant risk of death due to heat induced health problems, this is T=15, and at 32F we have the freezing point of water, which it would be ridiculous to approach indoors, this is at T=-21.5 so we can let the function go to positive infinity at these points, perhaps the easiest way is to put a "pole" at those points, meaning a division by zero. So a suitable function would have singular part, and then nonsingular part as follows:

${\rm Badness}(T) = -A/(T-15) + 1/(T+21.5) + B_{ns}(T)$ where $B_{ns}(T)$ is the nonsingular part that induces the proper behavior in the vicinity of 0. For a very simple function that fits these criteria we can use:

${\rm Badness}(T) = \frac{-630T^2}{2T^2+13T-645}$ which I got by simply rescaling and shifting the singular part of the badness function above, so that the nonsingular part is a simple constant. If we want to model a real person's preferences, we should in fact have some adjustable function for the nonsingular part, perhaps a radial basis function with several centers, for example at -10, -5, -2, -1, 0, 1, 2, 5, 10 which gives us 9 degrees of freedom to adjust to model our preferences in the vicinity of 0, however for the moment, let's stick with the simpler rational function I have above to see what happens qualitatively.

So far we have defined badness as a function of temperature, but in overall badness, we also need to consider badness as a function of how much we're running the A/C unit. We need a tradeoff between the two. Since our temperature badness is a nondimensional number, we also need a nondimensional number related to run time. First let's define our nondimensional time scale.

A good time unit to use seems to be the time it takes for our external temperature to go from its high to its low, since this is a naturally measurable timescale in the system. Another slightly better timescale to use is the time from our arrival at home to the external nighttime temperature reaching our optimal temperature. In my neighborhood yesterday (during a heat wave) the high at 3PM was 104 F and the external temperature reached 75F at midnight. If we assume that a typical person arrives at home at 6PM then our natural timescale is 6 hrs from 6pm to midnight. In addition, the high was at 3PM so if we start our clock at 6PM and use one unit of t is 6 hrs, we have time = 6PM + t * 6hrs meaning that the high occurs at t=-1/2, we arrive home at t=0, and our external temperature reaches our desired setpoint at t=1. So to define our overall badness we have the following functional (A function which maps functions of T and d into real numbers):

$\int_{0}^1 {\rm Badness}(T) dt + B \times {\rm RunBadness}(d) dt$

Here we define ${\rm RunBadness}(d)$ as a function of duty cycle and $B$ is a constant that rescales RunBadness to express the relative preferences for running time vs temperature tradeoff.

To define badness of running the A/C we need to assess our personal preferences, so there is no right answer, but because we're interested in a qualitative result initially, we can imagine that dollars will do as a measurement scale. How many dollars would we be willing to pay to keep the internal temperature at T=1 for the full time t from 0 to 1? How many dollars DO we pay to run the A/C system at full duty cycle for one unit of time? The ratio of the two tells us how bad running is vs temperature discomfort. For example, if you have a 40,000 btu/hr central A/C with a coefficient of performance (COP) of 2 (the A/C uses 20,000 btu/hr to extract the 40,000 btu/hr) then doing the unit conversion, you need about 6  kilowatts to run it (25 Amps at 240 V, my A/C is on a 30Amp breaker so this sounds reasonable). Running for 6 hours, at $0.12 / kWh the cost to run continuously for 1 time unit is$4.32. Suppose you're willing to pay $3 to avoid 6 hours of being 77F (one unit of temperature badness) then B =$4.32/\$3 = 1.44 a reasonable starting place. We will adjust this B to see qualitatively what the run/temperature tradeoff does to the optimal result.

In the next article I will come up with a simple model of the thermodynamics of the house, and then we can assess some of these costs.