I have an MIP model, which includes some sets of binary variables, e.g., y_{rnt}. Instead of having a loop over each index (like below), I would like to only print (an store) variables such that y_{rnt}=1. Does the docplex offer any function in python?
The example for identifying with multiple loops (inefficient):
# R, N, and T are inputs. We also have the solution as the output of the MIP model
x = 0
for r in range(1, R+1):
for n in range(1, N+1):
for t in range(1, T+1):
if solution.get_value(y[r, n, t]) == 1:
x = x + 1