Many optimization algorithms, including those at the heart of mathematical optimization solvers, incorporate randomness. In the Gurobi Optimizer, random numbers are used to make tie-breaking decisions for everything from pivot selection in the simplex algorithm to branching decisions and the behavior of heuristics (and more!). This may seem surprising to users who run a small model several times and observe the exact same results each time - but this phenomenon is *determinism* and is a different concept - see Is Gurobi deterministic? for details.

The ability to be both deterministic and random is provided by pseudorandom number generators. Determinism allows us to have reproducible behavior given the initial conditions are identical, where randomness allows for varying behavior when initial conditions are changed. The simplest way of changing the initial conditions is through the Seed parameter. Any change to the value of Seed, from the default of 0, will be noted in the log.

*The effect of Seed on the result of a deterministic optimization:*

>> import gurobipy as gp

>> m = gp.read("misc07.mps") # misc07.mps is distributed with your Gurobi installation

>> m.params.OutputFlag=0

>> m.optimize()

>> print(m.Work) # Work units are a measure of effort spent by the solve

1.322220613458911

>> m.reset() # remove previous solutions found

>> m.params.Seed=1 # set a new seed value

>> m.optimize()

>> print(m.Work)

1.4098640086245844

>> m.reset()

>> m.params.Seed=0 # back to default

>> m.optimize()

>> print(m.Work)

1.322220613458911

## Comments

0 comments

Article is closed for comments.