I have a decision variable for the power of a heating device $P$ that can have the following levels: 0, 900, 1300, 2000 (Unit is Watt [W]).

Now I would like to know if and how I can model in an equation. If the levels were distributed evenly, I could just use an integer variable $x$ with 4 values ${0, 1,2,3}$ and calculate the output power by using

$P = x* (1/3)* P^{max}$

But for my application this can't be done. A way to archieve this is to use 4 binary variables with one variable for each level and ensure in an additional constraint that only one of them can be active. However, this would create multiple additional binary variables. So I am asking you whether you are aware of a way how to model this elegantly?


1 Answer 1


If you plot your power levels versus the integers 0 to 3, you will see that the function is neither convex nor concave. For that reason, I am fairly confident you will need to use binary variables.

  • $\begingroup$ Thanks Prubin for your anwer. Does this mean that if I have 20 discrete levels for example, I'll need 20 binary variables and there is no way to avoid this? That would be way to much for my model and thus I'd choose the linearization instead knowing that this would be a simplification. $\endgroup$
    – PeterBe
    Commented Aug 26, 2022 at 6:41
  • $\begingroup$ Yes, with 20 levels you would need 20 binary variables, but I'm not sure that would be much of a problem in performance terms (unless you need 20 parameters for each of a thousand different power levels). Along with the 20 binaries would be a single SOS1 constraint (sum of binaries equals 1). $\endgroup$
    – prubin
    Commented Aug 26, 2022 at 15:01
  • $\begingroup$ @prubing: Thanks Prubin for your comment and effort. I really appreciate it. Why do you think that 20 binary variables would not affect the performance of the solver? I learned in Operations Research classes that every binary variable significantly increases the complexitiy of the Branch and Bound algorithms for Mixe-Integer problems (and this is in line with my experience). And what do you mean by "unless you need 20 parameters for each of a thousand different power levels"? $\endgroup$
    – PeterBe
    Commented Aug 27, 2022 at 9:40
  • 1
    $\begingroup$ Adding a binary variable usually (not always) adds to solution time, but does not necessarily increase it "significantly". Whether your model will be tractable with the required number of binaries (and associated constraints) is an empirical question. Linear approximation might solve faster (not guaranteed but plausible), but would not necessarily produce an optimal solution to the original model. Depending on how $P$ occurs in the model, the linearized solution might not even be feasible. So I would suggest trying the SOS1 formulation before surrendering and using an approximation. $\endgroup$
    – prubin
    Commented Aug 27, 2022 at 16:08
  • $\begingroup$ Thanks Prubin for your answer. I upvoted and accepted it. $\endgroup$
    – PeterBe
    Commented Aug 28, 2022 at 9:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.