Set definition
Awaiting user inputI'm pretty new at Gurobi and am having trouble defining a set below:
$T_{pt}$ = \{ ($\tau,q$) $\in $ {$ES_p$,...,$LS_p$} x {$1$,...,$d_p$}|$\tau$ + $q$ - $1$ = $t$\}
(Not sure if the Markdown can be shown properly). But basically, I need to create a list (T_pt) of set (tau, q) that are in the subset of cartesian products of {ES_p...LSp} x {1...d_p} such that condition (tau + q -1 = t) is fulfiled.
I managed to create cartesian_list = list(itertools.product({ES_p...LSp},{1...d_p}) but I'm not sure how to create the (tau,q) and link it to the condition.
-
Official comment
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 why not try our AI Gurobot?. -
Hi Shuk,
How is this related to Gurobi? Are you trying to create variables for each tuple (tau,q)?
Creating the list of feasible tuples can be done, e.g., with Python generator expressions:
Tpt = [(tau, q) for tau in range(ESp, LSp + 1) for q in range(1, dp + 1) if tau + q - 1 == t]
Then, you could for example create one binary variable for each pair (tau,q) by:
x = model.addVars(Tpt, vtype=GRB.BINARY, name="x")
Is this what you need?
Best regards,
Mario0
Post is closed for comments.
Comments
2 comments