示例#1
0
 def __init__(self, *args, **kwargs):
     """Constructor"""
     #
     # Collect kwargs for SubModel
     #
     _rule = kwargs.pop('rule', None )
     _fixed = kwargs.pop('fixed', None )
     _var = kwargs.pop('var', None )     # Not documented
     #
     # Initialize the SimpleBlock
     #
     kwargs.setdefault('ctype', SubModel)
     SimpleBlock.__init__(self, *args, **kwargs)
     #
     # Initialize from kwargs
     #
     self._rule = _rule
     if isinstance(_fixed, Component):
         self._fixed = [_fixed]
     else:
         self._fixed = _fixed
     if isinstance(_var, Component):
         self._var = [_var]
     else:
         self._var = _var
示例#2
0
 def __init__(self, name='unknown', **kwargs):
     """Constructor"""
     #
     # NOTE: The 'ctype' keyword argument is not defined here.  Thus,
     # a model is treated as a 'Block' class type.  This simplifies
     # the definition of the block_data_objects() method, since we treat
     # Model and Block objects as the same.  Similarly, this avoids
     # the requirement to import PyomoModel.py in the block.py file.
     #
     SimpleBlock.__init__(self, **kwargs)
     self._name = name
     self.statistics = Container()
     self.config = PyomoConfig()
     self.solutions = ModelSolutions(self)
     self.config.preprocessor = 'pyomo.model.simple_preprocessor'
示例#3
0
文件: PyomoModel.py 项目: Pyomo/pyomo
 def __init__(self, name='unknown', **kwargs):
     """Constructor"""
     #
     # NOTE: The 'ctype' keyword argument is not defined here.  Thus,
     # a model is treated as a 'Block' class type.  This simplifies
     # the definition of the block_data_objects() method, since we treat
     # Model and Block objects as the same.  Similarly, this avoids
     # the requirement to import PyomoModel.py in the block.py file.
     #
     SimpleBlock.__init__(self, **kwargs)
     self._name = name
     self.statistics = Container()
     self.config = PyomoConfig()
     self.solutions = ModelSolutions(self)
     self.config.preprocessor = 'pyomo.model.simple_preprocessor'
示例#4
0
 def clone(self):
     instance = SimpleBlock.clone(self)
     # Do not keep cloned solutions, which point to the original model
     instance.solutions.clear()
     instance.solutions._instance = weakref_ref(instance)
     return instance
示例#5
0
 def clone(self):
     instance = SimpleBlock.clone(self)
     # Do not keep cloned solutions, which point to the original model
     instance.solutions.clear()
     instance.solutions._instance = weakref_ref(instance)
     return instance