I want to find an expression with an absolute value as an objective function in gurobi. Specifically, it is an expression such as ∑_j ∈ J | ∑_i ∈ P x_ij-d_i *t_i |.
The variable is x_ij, and the others are constants. I tried and errored this formula using abs (), but I couldn't figure it out in the end. I would appreciate it if you could tell me.
model.setObjective(quicksum(quicksum((x[i,j] for i in P)-d[i]*t[i]) for j in W),GRB.MINIMIZE)
#objectfunction
what should I change this?
You could add additional helper variables and then use Gurobi's general abs constraints: