예제 #1
0
class _DisjunctData(_BlockData):

    _Block_reserved_words = set()

    @property
    def transformation_block(self):
        return self._transformation_block

    def __init__(self, component):
        _BlockData.__init__(self, component)
        self.indicator_var = Var(within=Binary)
        # pointer to transformation block if this disjunct has been
        # transformed. None indicates it hasn't been transformed.
        self._transformation_block = None

    def activate(self):
        super(_DisjunctData, self).activate()
        self.indicator_var.unfix()

    def deactivate(self):
        super(_DisjunctData, self).deactivate()
        self.indicator_var.fix(0)

    def _deactivate_without_fixing_indicator(self):
        super(_DisjunctData, self).deactivate()

    def _activate_without_unfixing_indicator(self):
        super(_DisjunctData, self).activate()
예제 #2
0
파일: disjunct.py 프로젝트: knut0815/pyomo
class _DisjunctData(_BlockData):
    def __init__(self, component):
        _BlockData.__init__(self, component)
        self.indicator_var = Var(within=Binary)

    def pprint(self, ostream=None, verbose=False, prefix=""):
        _BlockData.pprint(self,
                          ostream=ostream,
                          verbose=verbose,
                          prefix=prefix)

    def set_value(self, val):
        _indicator_var = self.indicator_var
        # Remove everything
        for k in list(getattr(self, '_decl', {})):
            self.del_component(k)
        self._ctypes = {}
        self._decl = {}
        self._decl_order = []
        # Now copy over everything from the other block.  If the other
        # block has an indicator_var, it should override this block's.
        # Otherwise restore this block's indicator_var.
        if val:
            if 'indicator_var' not in val:
                self.add_component('indicator_var', _indicator_var)
            for k in sorted(iterkeys(val)):
                self.add_component(k, val[k])
        else:
            self.add_component('indicator_var', _indicator_var)

    def activate(self):
        super(_DisjunctData, self).activate()
        self.indicator_var.unfix()

    def deactivate(self):
        super(_DisjunctData, self).deactivate()
        self.indicator_var.fix(0)

    def _deactivate_without_fixing_indicator(self):
        super(_DisjunctData, self).deactivate()

    def _activate_without_unfixing_indicator(self):
        super(_DisjunctData, self).activate()
예제 #3
0
파일: disjunct.py 프로젝트: Pyomo/pyomo
class _DisjunctData(_BlockData):

    def __init__(self, component):
        _BlockData.__init__(self, component)
        self.indicator_var = Var(within=Binary)

    def pprint(self, ostream=None, verbose=False, prefix=""):
        _BlockData.pprint(self, ostream=ostream, verbose=verbose, prefix=prefix)

    def set_value(self, val):
        _indicator_var = self.indicator_var
        # Remove everything
        for k in list(getattr(self, '_decl', {})):
            self.del_component(k)
        self._ctypes = {}
        self._decl = {}
        self._decl_order = []
        # Now copy over everything from the other block.  If the other
        # block has an indicator_var, it should override this block's.
        # Otherwise restore this block's indicator_var.
        if val:
            if 'indicator_var' not in val:
                self.add_component('indicator_var', _indicator_var)
            for k in sorted(iterkeys(val)):
                self.add_component(k,val[k])
        else:
            self.add_component('indicator_var', _indicator_var)

    def activate(self):
        super(_DisjunctData, self).activate()
        self.indicator_var.unfix()

    def deactivate(self):
        super(_DisjunctData, self).deactivate()
        self.indicator_var.fix(0)

    def _deactivate_without_fixing_indicator(self):
        super(_DisjunctData, self).deactivate()

    def _activate_without_unfixing_indicator(self):
        super(_DisjunctData, self).activate()
예제 #4
0
파일: disjunct.py 프로젝트: CanLi1/pyomo-1
class _DisjunctData(_BlockData):

    _Block_reserved_words = set()

    def __init__(self, component):
        _BlockData.__init__(self, component)
        self.indicator_var = Var(within=Binary)

    def activate(self):
        super(_DisjunctData, self).activate()
        self.indicator_var.unfix()

    def deactivate(self):
        super(_DisjunctData, self).deactivate()
        self.indicator_var.fix(0)

    def _deactivate_without_fixing_indicator(self):
        super(_DisjunctData, self).deactivate()

    def _activate_without_unfixing_indicator(self):
        super(_DisjunctData, self).activate()