how to write this objective function in python
AnsweredDecision variables is p_{ij} and y{ij}.p_{ij} is a continuous nonnegative variable and y{ij} is a variable that can only take 0 or 1.
0

Hi,
You can model your objective function with the help of adding general constraints that model the exponential function (for example, with the method addGenConstrExp if using the Python API), and using the trick in the article How do I divide by a variable in Gurobi?. Specifically, you can do something like below, where aux, exp, z, and q are helper variables:
m.addConstrs( aux[i] == gp.quicksum( (a[i] + p[i,j]  b[i]*w[i,j]) * y[i,j] for j in range(N) ) for i in range(M))
for i in range(M):
m.addGenConstrExp(exp[i], aux[i])
m.addConstr( z[i] * (1+exp[i]) == 1)
m.addConstr( q[i] == exp[i] * z[i])
obj = gp.quicksum( p[i,j] * q[i] for i in range(M) for j in range(N))
m.setObjective(obj)Best regards,
Simran0
Please sign in to leave a comment.
Comments
1 comment