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.

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
Please sign in to leave a comment.
Comments
1 comment