from gekko import GEKKO y = ['towel','hammer','wrench','screwdriver'] v = [11,8,3,6] w = [3,5,7,4] items = len(y) # Create model m = GEKKO() # Variables x = m.Array(m.Var,len(y),lb=0,ub=1,integer=True) # Objective m.Maximize(m.sum([v[i]*x[i] for i in range(items)])) # Constraint limit = 14 m.Equation(m.sum([w[i]*x[i] for i in range(items)]) <= limit) # Optimize with APOPT m.options.SOLVER = 1 m.solve() # Print the value of the variables at the optimum for i in range(items): print("%s = %f" % (y[i], x[i].value[0])) # Print the value of the objective print("Objective = %f" % (-m.options.objfcnval))