Juan S. P.
Juan S. P.

Reputation: 31

How fix initial value cplex python?

I have a question about, variable fix value because I need fix any variables of my problem with specific values and again solve.

How are you variable fix value in cplex python without appened constraints?

Upvotes: 0

Views: 509

Answers (1)

Daniel Junglas
Daniel Junglas

Reputation: 5930

In order to fix a variable you can just set lower and upper bound of that variable to the fix value:

with cplex.Cplex() as cpx:
    x = cpx.variables.add(lb = [0, 0], ub = [1, 1])
    cpx.variables.set_lower_bounds(x[0], 0.5)
    cpx.variables.set_upper_bounds(x[0], 0.5)
    # The variable x[0] is now fixed to 0.5

Upvotes: 3

Related Questions