Solved

# Linearizing step function

• 2 replies
• 615 views

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".

thanks.
Hi @chrdttchavan did this help solve your problem? Or did you find another way? It may help others to know. Thanks 🙂
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.

Set

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

Parameters,

LowerLimit(r) := {1, 3, 5};

UpperLimit(r) := {3, 4, 6};

MultiplicationFactor(r) := {a, b, c};.

BinaryVariable(r).

Now have the following constraints.

Constraint_1

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

Constraint_2

sum[r, BinaryVariable(r)] = 1

Constraint_3(r)

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

Constraint_4(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.