Skip to main content
Solved

Linearizing step function

  • August 5, 2019
  • 2 replies
  • 674 views

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

Best answer by mohansx

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.

2 replies

mohansx
Forum|alt.badge.img+5
  • Former AIMMSian
  • 223 replies
  • Answer
  • August 6, 2019
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.

Jess Es
Forum|alt.badge.img+6
  • Grand Master
  • 121 replies
  • August 23, 2019
Hi @chrdttchavan did this help solve your problem? Or did you find another way? It may help others to know. Thanks 🙂


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

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