4

I have an mixed-integer linear optimization problem that includes a energetic difference equation for the temperature of a building for the time $t$:

$$T(t) = T(t-1) + \frac{E^{\rm Heating}(t)-E^{\rm Demand}(t)}{V\cdot \rho\cdot c}, t>1$$

I used to have the temperature in the constraints with a minimum and maximum value:

$$T_{\min}\leq T(t) \leq T_{\max}$$

Now I would like to transform it from a constraint to the objective function. So what I want is to quantify the violation of this "constrain" $Z$ and minimize it in the objective function. So the equations should actually look like this:

\begin{align}\text{if} \hspace{0,5cm}T(t) < T_{\min} &\implies Z(t) = T_{\min} - T(t)\\\text{if} \hspace{0,5cm}T(t) > T_{\max} &\implies Z(t) = T(t) - T_{\max}\end{align}

And in the objective function $\min \sum_{t} Z(t)$.

Now my question is, whether this is possible to define within a mixed-integer linear problem and if so, how can I do that?

PeterBe
  • 1,632
  • 2
  • 15
  • 30

1 Answers1

9

Introduce nonnegative variables $Z^+(t)$ and $Z^-(t)$, impose linear constraints $$T_\min \le T(t)-Z^+(t)+Z^-(t) \le T_\max,$$ and minimize $$\sum_t (Z^+(t)+Z^-(t)).$$ Notice that this approach easily allows penalizing overage and underage differently, if you want, just by changing the objective coefficients.

RobPratt
  • 32,006
  • 1
  • 44
  • 84
  • Thanks for your answer. Can I just directly use it or do I have to implement something like a Big-M approach. Because I have some "if" conditions and there, from what I have seen, most often the Big-M approach is used. – PeterBe Apr 27 '22 at 07:47
  • You can use it directly, without introducing binary variables or big-M constraints. The objective will naturally drive your “if” conditions to be satisfied for every optimal solution. – RobPratt Apr 27 '22 at 12:12
  • 1
    Thanks a lot Pratt for your help. I really appreciate it. I upvoted and accepted your answer. – PeterBe Apr 27 '22 at 12:18