I am using Gekko to solve an optimization models for job assignment, so one of the decision variable (Xijt)(i=workers, j=jobs, t=time periods) is binary whether the worker is selected to the job(x=1) or not (x=0). I got solution (The value of the objective function). However, for the variables value when use - Print(str (x)) - I got all values of x as shown in the attached picture but I want to get only the selected workers where xijt =1. Same issue with the second variables (Yijt) continues number indicates number of hours for worker i to perform job j at time t. When use - Print(str (Y)) - I got all values of Y but I want to get the Y values for only selected workers where xijt =1. Any idea about resolving that please. click here for output screenshot and for code
model = GEKKO()
model.options.SOLVER = 1
x = {}
for i in I:
for j in J:
for t in T:
x[i, j, t] = model.Var(lb=0.00, ub=1.00001,integer=True, name="x %s %s %s" % (i, j, t))
y = {}
for i in I:
for j in J:
for t in T:
y[i, j, t] = model.Var(integer=False, name="y %s %s %s" % (i, j, t))
# model.update()
for l in L:
for i in I:
for j in J:
for t in T:
model.Equation(x[i, j, t] * (q[i][l] - s[j][l]) >= 0)
for j in J:
for i in I:
for t in T:
model.Equation(x[i, j, t] * (lc[j][t] * y[i, j, t] * (sum(q[i][l] / s[j][l] for l in L) / len(L))) <= uc[j][t])
model.Equation(x[i, j, t] * (lz[j][t] * y[i, j, t] * (sum(q[i][l] / s[j][l] for l in L) / len(L))) <= uz[j][t])
for j in J:
for t in T:
model.Equation(sum(x[i, j, t] for i in I) == 1)
for i in I:
for t in T:
model.Equation(sum(x[i, j, t] for j in J) == 1)
for i in I:
for t in T:
model.Equation(sum(y[i, j, t] for j in J) <= 8)
objt = sum(sum(sum((x[i, j, t] * v[j] * lc[j][t] * y[i, j, t] * (sum(q[i][l] / s[j][l] for l in L) / len(L))) - (
x[i, j, t] * lz[j][t] * y[i, j, t] * (sum(q[i][l] / s[j][l] for l in L) / len(L))) for j in J) for i in I) for t in
T)
model.Obj(-objt)
model.solve(disp=True, debug=False)
print(str (x))
print(str (y))