code: def optimize(model,cand,obj):
      
      # model.Params.OutputFlag = 0 # silent mode
      model.setObjective(obj,"minimize")
  
      model.optimize()
      x,y,C,U = model.data
      status = model.getStatus()
      if status == "optimal" or status == "bestsollimit": # todo GRB.Status.SUBOPTIMAL:
          sols = model.getSols()
          for sol in sols:
              cand.append((model.getVal(var=U,solution=sol),model.getVal(var=C,solution=sol)))
  
       #   for k in range(model.SolCount):
       #       model.Params.SolutionNumber = k
       #       cand.append(model.getVal(U),model.getVal(C))
      return status
docs: optimize: function for solving the model, updating candidate solutions' list
      Parameters:
          - model: Gurobi model object
          - cand: list of pairs of objective functions (for appending more solutions)
          - obj: name of a model's variable to setup as objective
      Returns the solver's exit status