I am currently working on a optimization problem on GUROBI.All my variables are of binary type.I have a variable y which is equal to the absolute of difference of two binary decision variables.However,when i tried to use the abs() function,i get this output.
TypeError: bad operand type for abs(): 'gurobipy.LinExpr'
Therefore,i am now squaring the difference (since difference is always -1,0 or 1). But this causes higher optimization time(quadratic expressions after squaring). Is there any alternative to this?
Also,there is a case(not binary variables) where the difference of two variables may not be -1,0 or 1.How do i take the absolute in this case?