I am trying to maximize the absolute distance of binary variables from 0.5 in a relaxed form of a MIP model to push the solution to integer values as much as possible. For that I have linearized the absolute expressions (|0.5-y|) using the conventional variable change technique. To avoid the non-linear constraints (x_plus * x_minus=0) I intend to use SOS sets. But add_sos1 method functions super slow for some reason. Is this normal or a bug or common mistake I am possibly making causes it?
I looked up to see if there is other way of adding SOS sets to the model, but found nothing.
TVijpt = MODEL.continuous_var_dict({(i,j,p,t) for i in NN for j in AA_Plus[i] for p in PP for t in TT if ValidEdge[i,j,p]}, name = 'TV', ub = .5)
TVPijpt = MODEL.continuous_var_dict({(i,j,p,t) for i in NN for j in AA_Plus[i] for p in PP for t in TT if ValidEdge[i,j,p]}, name = 'TVP', ub = .5)
expr = 0
for k in Yijpt.keys():
expr += (TVijpt[k] + TVPijpt[k] )
for k in Yijpt.keys():
MODEL.add_constraint(TVijpt[k] - TVPijpt[k] == .5-Yijpt[k])
MODEL.add_sos1([TVijpt[k],TVPijpt[k]]) # The line is taking too long.