Linearizing step function

  • 5 August 2019
  • 2 replies

hi all,
need help for linearizing step function.

say "y" is depending on "x" such that,
y= ax if x is between 1 and 2
y= bx if x is between 3 and 4
y= cx if x is between 5 and 6

a, b and c are parameters/constant which will have values 8 or 9.
"y" is not final objective function and a, b and c must choose value either 8 or 9.

solution requested for maximizing/minimizing "y".


Best answer by mohansx 6 August 2019, 23:33

View original

2 replies

Userlevel 6
Badge +6
Hi @chrdttchavan did this help solve your problem? Or did you find another way? It may help others to know. Thanks 🙂
Userlevel 5
Badge +2
Hi @chrdttchavan ,

One way of linearizing this is to use binary variables. I would recommend you to create a set Ranges (with index r) - each element in this set corresponds to the different steps/ranges you have for x.

Ranges := data{Range-1, Range-2, Range-3}.


LowerLimit(r) := {1, 3, 5};
UpperLimit(r) := {3, 4, 6};
MultiplicationFactor(r) := {a, b, c};.


Now have the following constraints.

y = sum[r, BinaryVariable(r)*MultiplicationFactor(r)]

sum[r, BinaryVariable(r)] = 1

x >= BinaryVariable(r) * LowerLimit(r)


X <= (1-BinaryVariable(r))*M + UpperLimit(r)

Here, M is a sufficiently large positive number. You can use M = 10 for your case.

You are essentially using BinaryVariable(r) to track in which range does the value of x lie in, and based on the value of BinaryVariable(r), you can calculate the value of y.


Didn't find what you were looking for? Try searching on our documentation pages:

AIMMS Developer & PRO | AIMMS How-To | AIMMS SC Navigator