Skip to main content

how to use value of a continuous variable as another variable's index?

Answered

Comments

1 comment

  • Mario Ruthmair
    • Gurobi Staff

    Hi,

    Yes, variables as indices of other variables are not possible. Maybe you can reformulate your problem in a way to avoid this situation. But without knowing your problem, you might work with binary variables Y[i,k,t] for i in V, k in K, t in the domain of variable a_int[i,k]. Then,

    a_int[i,k] == sum_{t} t * Y[i,k,t]
    sum_{t} Y[i,k,t] == 1

    The continuous coordinate variables might also have another index, i.e., Z[i,k,t]. Together with the Y[i,k,t], you can ensure that only one Z[i,k,t] is non-zero:

    LB * Y[i,k,t] <= Z[i,k,t] <= UB * Y[i,k,t]
    X[t,k] = sum_{i} Z[i,k,t]

    Not sure if that works for your problem. Maybe you need more constraints to limit the number of non-zero 3-index variables.

    Best regards,
    Mario

    0

Please sign in to leave a comment.