------------------------------------------------------------------------------------------------------------------
from gurobipy import *
def myCallback(model, where):
global y, counter
if where == GRB.Callback.MIPSOL:
print '*** In callback! where = MIPSOL'
if counter < counterLimit:
model.cbLazy(y >= counter)
counter += 1
print 'added cut! counter =', counter
counter = 1
counterLimit = 5
model = Model('test')
model.setParam('Outputflag', 0)
model.setParam('LazyConstraints', 1)
model.setParam('Threads', 1)
x = model.addVar(vtype=GRB.BINARY, name='x')
y = model.addVar(vtype=GRB.CONTINUOUS, name='y')
model.update()
model.setObjective(x+y, GRB.MINIMIZE)
model.optimize(myCallback)
counterLimit = 10
model.optimize(myCallback)