I'm trying to find a way of setting the values of a binary MVar object (which is my decision variable) of size n to {-1,1}. Right now I have a vector that can either take values 0 or 1 (due to binary condition), but instead of 0 and 1, I need the variable to take the values -1 and 1. This is what I tried doing, but I don't think it's working:
x = m.addMVar(shape = n, vtype = GRB.BINARY, name = 'X') #My decision variable
y = m.addMVar(shape = n, vtype = GRB.INTEGER, name = 'Y') #Auxiliar decision variable
m.addConstr(y == 2*x - 1) #Transformation from {0,1} to {-1,1}
m.setObjective(#function with y as decision variable)