Hello to Everyone.
I'm implementing a simple fixing heuristic following one of the examples provided (fixanddive.py) in the Gurobi Optimizer Example Tour, using gurobipy. I intend to set the lower bound of an originally defined as binary variable to 1. As in the example, I first relax all binary variables, and then use
v.lb = 1, to set the bound. I noticed that this was causing no effect as I immediatelly print the bounds and the lower bound is still 0 (print
v.lb). I'm most probably missing something here. Any help is greatly appreciated.
Here is part of the script for reference.
# def sortkey(v1):
# sol=v1.x
# return 1-sol
# while heuristic:
#
# M.update()
# M.optimize()
#
# fractional = []
# for v in M.getVars():
# sol = v.x
# if abs(sol-int(sol+0.5)) > 1e-5:
# fractional.append(v)
#
# fractional.sort(key=sortkey)
# c = 0
# for v in fractional:
# if v.x > fixbound:
# c+=1
#
v.lb = 1
# elif c==0:
#
v.lb = 1
# else:
# break
#
# M.update