Variable division in or-tools python

649 Views Asked by At

I am working with MIP solver provided by or-tools (in python)

assume we have two variables x and y . I know how to maximize one single variable OR the sum of two variables.

for example, if we want to maximize 2*x we can do it this way

objective = solver.Objective()
objective.SetCoefficient(x,2)
objective.SetMaximization()

and if we want to maximize 2*x + 3*y we can do it this way

objective = solver.Objective()
objective.SetCoefficient(x,2)
objective.SetCoefficient(y,3)
objective.SetMaximization()

but waht I don't know is how to maximize a variable that is divided by another variable. my question is how to maximize (x/y) ?

1

There are 1 best solutions below

0
On

A MIP solver only accepts linear equations. By definition, division is not linear. There can be very special cases when you can linearize division, for instance if y has a small set of possible values.

You can have a look at the CP-SAT solver, which proposes division, but cannot deal with continuous variables.