def addVariables(self, model): """ Add variables for MCKP problems @ In, model, pyomo model instance, pyomo abstract model @ Out, model, pyomo model instance, pyomo abstract model """ model = KnapsackBase.addVariables(self, model) model.x = pyomo.Var(model.options, domain=pyomo.Binary) return model
def addVariables(self, model): """ Add variables for SingleKnapsack problems @ In, model, pyomo model instance, pyomo abstract model @ Out, model, pyomo model instance, pyomo abstract model """ model = KnapsackBase.addVariables(self, model) def boundsExpression(model, i): """ set the bounds for soluion variable x using lowerBounds and upperBounds""" return (self.lowerBounds[i], self.upperBounds[i]) model.x = pyomo.Var(model.investments, domain=pyomo.NonNegativeIntegers, bounds=boundsExpression) return model