示例#1
0
文件: MCKP.py 项目: milljm/LOGOS
 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
示例#2
0
    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