Seek help about formulation of the constraints
ユーザーの入力を待っています。I want to write a MIP solver for the max-p-region problem: https://onlinelibrary.wiley.com/doi/epdf/10.1111/j.1467-9787.2011.00743.x
I do not know how I can add this constraint (constraint (4) on page 8, where Ni is a set of integers. Could someone please give me a hint about how to write the addConstrs() for this constraint?

0
-
正式なコメント
This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum, or try Gurobot, our chatbot interface offering instant, expert-level support. -
Hi Yunfan,
I assume you use Python API.
Based on your inputs, I would imagine the following code to work:
import gurobipy as gp
model = gp.Model()
# define K, C, I and x
for k in K:
for c in C:
for i in I:
m.addLConstr(
x[k, c, i] <= gp.quicksum(x[k, c - 1, j] for j in N[i]),
name=f"c_{k}_{c}_{i}",
)
# alternatively
m.addConstrs(
(
x[k, c, i] <= gp.quicksum(x[k, c - 1, j] for j in N[i])
for k in K
for c in C
for i in I
),
name="c",
)0
投稿コメントは受け付けていません。
コメント
2件のコメント