bimal
bimal

Reputation: 83

How to apply ceiling or floor function on a decision variable

How I can linearize a constraint(s) with ceiling or floor functions via linear programming. I know I should introduce some integer variables, but not sure how and which constraints I should write to meet the desired purpose.

E.g., if the solver decides the value of the decision variable x = 4.2, then I want y (integer variable) to assume the value of 4

I am struggling with right formulation.

Upvotes: 3

Views: 242

Answers (1)

Bhartendu Awasthi
Bhartendu Awasthi

Reputation: 1029

You can model the expression floor(x) for a decision variable x by introducing new integer variable y (as you suggested) and adding the following constraints:

y <= x
y + 1 >= x + e

where e is epsilon : a small tolerance range

ceil(x) can be modelled in a similar way

Upvotes: 1

Related Questions