當前位置: 首頁>>代碼示例>>Python>>正文


Python environ.Var方法代碼示例

本文整理匯總了Python中pyomo.environ.Var方法的典型用法代碼示例。如果您正苦於以下問題:Python environ.Var方法的具體用法?Python environ.Var怎麽用?Python environ.Var使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pyomo.environ的用法示例。


在下文中一共展示了environ.Var方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: declareStartStopVariables

# 需要導入模塊: from pyomo import environ [as 別名]
# 或者: from pyomo.environ import Var [as 別名]
def declareStartStopVariables(self, pyM):
        """
        Declare start/stop variables.

        :param pyM: pyomo ConcreteModel which stores the mathematical formulation of the model.
        :type pyM: pyomo Concrete Model
        """
        setattr(pyM, 'startVariable_' + self.abbrvName,
                pyomo.Var(getattr(pyM, 'operationVarStartStopSetBin_' + self.abbrvName), pyM.timeSet, domain=pyomo.Binary))
        
        setattr(pyM, 'stopVariable_' + self.abbrvName,
                pyomo.Var(getattr(pyM, 'operationVarStartStopSetBin_' + self.abbrvName), pyM.timeSet, domain=pyomo.Binary)) 
開發者ID:FZJ-IEK3-VSA,項目名稱:FINE,代碼行數:14,代碼來源:conversionDynamic.py

示例2: declareDiscretizationPointVariables

# 需要導入模塊: from pyomo import environ [as 別名]
# 或者: from pyomo.environ import Var [as 別名]
def declareDiscretizationPointVariables(self, pyM):
        """
        Declare discretization point variables.

        :param pyM: pyomo ConcreteModel which stores the mathematical formulation of the model.
        :type pyM: pyomo Concrete Model
        """
        setattr(pyM, 'discretizationPoint_' + self.abbrvName,
                pyomo.Var(getattr(pyM, 'discretizationPointVarSet_' + self.abbrvName), pyM.timeSet, domain=pyomo.NonNegativeReals)) 
開發者ID:FZJ-IEK3-VSA,項目名稱:FINE,代碼行數:11,代碼來源:conversionPartLoad.py

示例3: declareDiscretizationSegmentBinVariables

# 需要導入模塊: from pyomo import environ [as 別名]
# 或者: from pyomo.environ import Var [as 別名]
def declareDiscretizationSegmentBinVariables(self, pyM):
        """
        Declare discretization segment variables.

        :param pyM: pyomo ConcreteModel which stores the mathematical formulation of the model.
        :type pyM: pyomo Concrete Model
        """
        setattr(pyM, 'discretizationSegmentBin_' + self.abbrvName,
                pyomo.Var(getattr(pyM, 'discretizationSegmentVarSet_' + self.abbrvName), pyM.timeSet, domain=pyomo.Binary)) 
開發者ID:FZJ-IEK3-VSA,項目名稱:FINE,代碼行數:11,代碼來源:conversionPartLoad.py

示例4: declareDiscretizationSegmentConVariables

# 需要導入模塊: from pyomo import environ [as 別名]
# 或者: from pyomo.environ import Var [as 別名]
def declareDiscretizationSegmentConVariables(self, pyM):
        """
        Declare discretization segment variables.

        :param pyM: pyomo ConcreteModel which stores the mathematical formulation of the model.
        :type pyM: pyomo Concrete Model
        """
        setattr(pyM, 'discretizationSegmentCon_' + self.abbrvName,
                pyomo.Var(getattr(pyM, 'discretizationSegmentVarSet_' + self.abbrvName), pyM.timeSet, domain=pyomo.NonNegativeReals)) 
開發者ID:FZJ-IEK3-VSA,項目名稱:FINE,代碼行數:11,代碼來源:conversionPartLoad.py

示例5: declarePhaseAngleVariables

# 需要導入模塊: from pyomo import environ [as 別名]
# 或者: from pyomo.environ import Var [as 別名]
def declarePhaseAngleVariables(self, pyM):
        """
        Declare phase angle variables.

        :param pyM: pyomo ConcreteModel which stores the mathematical formulation of the model.
        :type pyM: pyomo Concrete Model
        """
        setattr(pyM, 'phaseAngle_' + self.abbrvName,
                pyomo.Var(getattr(pyM, 'phaseAngleVarSet_' + self.abbrvName), pyM.timeSet, domain=pyomo.Reals)) 
開發者ID:FZJ-IEK3-VSA,項目名稱:FINE,代碼行數:11,代碼來源:lopf.py

示例6: declareRealNumbersVars

# 需要導入模塊: from pyomo import environ [as 別名]
# 或者: from pyomo.environ import Var [as 別名]
def declareRealNumbersVars(self, pyM):
        """ 
        Declare variables representing the (continuous) number of installed components [-]. 
        
        :param pyM: pyomo ConcreteModel which stores the mathematical formulation of the model.
        :type pyM: pyomo ConcreteModel
        """
        abbrvName = self.abbrvName
        setattr(pyM, 'nbReal_' + abbrvName, pyomo.Var(getattr(pyM, 'continuousDesignDimensionVarSet_' + abbrvName),
                domain=pyomo.NonNegativeReals)) 
開發者ID:FZJ-IEK3-VSA,項目名稱:FINE,代碼行數:12,代碼來源:component.py

示例7: declareIntNumbersVars

# 需要導入模塊: from pyomo import environ [as 別名]
# 或者: from pyomo.environ import Var [as 別名]
def declareIntNumbersVars(self, pyM):
        """ 
        Declare variables representing the (discrete/integer) number of installed components [-]. 
        
        :param pyM: pyomo ConcreteModel which stores the mathematical formulation of the model.
        :type pyM: pyomo ConcreteModel
        """
        abbrvName = self.abbrvName
        setattr(pyM, 'nbInt_' + abbrvName, pyomo.Var(getattr(pyM, 'discreteDesignDimensionVarSet_' + abbrvName),
                domain=pyomo.NonNegativeIntegers)) 
開發者ID:FZJ-IEK3-VSA,項目名稱:FINE,代碼行數:12,代碼來源:component.py

示例8: declareBinaryDesignDecisionVars

# 需要導入模塊: from pyomo import environ [as 別名]
# 或者: from pyomo.environ import Var [as 別名]
def declareBinaryDesignDecisionVars(self, pyM, relaxIsBuiltBinary):
        """ 
        Declare binary variables [-] indicating if a component is considered at a location or not [-]. 
        
        :param pyM: pyomo ConcreteModel which stores the mathematical formulation of the model.
        :type pyM: pyomo ConcreteModel
        """
        abbrvName = self.abbrvName
        if relaxIsBuiltBinary:
            setattr(pyM, 'designBin_' + abbrvName, pyomo.Var(getattr(pyM, 'designDecisionVarSet_' + abbrvName),
                    domain=pyomo.NonNegativeReals, bounds=(0,1)))
        else:
            setattr(pyM, 'designBin_' + abbrvName, pyomo.Var(getattr(pyM, 'designDecisionVarSet_' + abbrvName),
                    domain=pyomo.Binary)) 
開發者ID:FZJ-IEK3-VSA,項目名稱:FINE,代碼行數:16,代碼來源:component.py

示例9: declareOperationVars

# 需要導入模塊: from pyomo import environ [as 別名]
# 或者: from pyomo.environ import Var [as 別名]
def declareOperationVars(self, pyM, opVarName):
        """ 
        Declare operation variables.
        
        :param pyM: pyomo ConcreteModel which stores the mathematical formulation of the model.
        :type pyM: pyomo ConcreteModel
        """
        abbrvName = self.abbrvName
        setattr(pyM, opVarName + '_' + abbrvName,
                pyomo.Var(getattr(pyM, 'operationVarSet_' + abbrvName), pyM.timeSet, domain=pyomo.NonNegativeReals)) 
開發者ID:FZJ-IEK3-VSA,項目名稱:FINE,代碼行數:12,代碼來源:component.py

示例10: declareOperationBinaryVars

# 需要導入模塊: from pyomo import environ [as 別名]
# 或者: from pyomo.environ import Var [as 別名]
def declareOperationBinaryVars(self, pyM, opVarBinName):
        """ 
        Declare operation Binary variables. Discrete decicion between on and off.
        
        :param pyM: pyomo ConcreteModel which stores the mathematical formulation of the model.
        :type pyM: pyomo ConcreteModel
        """
        abbrvName = self.abbrvName
        setattr(pyM, opVarBinName + '_' + abbrvName,
                pyomo.Var(getattr(pyM, 'operationVarSetBin_' + abbrvName), pyM.timeSet, domain=pyomo.Binary))

    ####################################################################################################################
    #                              Functions for declaring time independent constraints                                #
    #################################################################################################################### 
開發者ID:FZJ-IEK3-VSA,項目名稱:FINE,代碼行數:16,代碼來源:component.py

示例11: free_pyomo_initializers

# 需要導入模塊: from pyomo import environ [as 別名]
# 或者: from pyomo.environ import Var [as 別名]
def free_pyomo_initializers(obj):
    obj.construct()
    if isinstance(obj, Var):
        attrs = ('_bounds_init_rule', '_bounds_init_value',
                 '_domain_init_rule', '_domain_init_value',
                 '_value_init_rule', '_value_init_value')
    elif isinstance(obj, Constraint):
        attrs = ('rule', '_init_expr')
    else:
        raise NotImplementedError

    for attr in attrs:
        if hasattr(obj, attr):
            setattr(obj, attr, None) 
開發者ID:PyPSA,項目名稱:PyPSA,代碼行數:16,代碼來源:opt.py

示例12: empty_model

# 需要導入模塊: from pyomo import environ [as 別名]
# 或者: from pyomo.environ import Var [as 別名]
def empty_model(model):
    logger.debug("Storing pyomo model to disk")
    rules = {}
    for obj in model.component_objects(ctype=Constraint):
        if obj.rule is not None:
            rules[obj.name] = obj.rule
            obj.rule = None

    bounds = {}
    for obj in model.component_objects(ctype=Var):
        if obj._bounds_init_rule is not None:
            bounds[obj.name] = obj._bounds_init_rule
            obj._bounds_init_rule = None

    fd, fn = tempfile.mkstemp()
    with os.fdopen(fd, 'wb') as f:
        pickle.dump(model.__getstate__(), f, -1)

    model.__dict__.clear()
    logger.debug("Stored pyomo model to disk")

    gc.collect()
    yield

    logger.debug("Reloading pyomo model")
    with open(fn, 'rb') as f:
        state = pickle.load(f)
    os.remove(fn)
    model.__setstate__(state)

    for n, rule in iteritems(rules):
        getattr(model, n).rule = rule

    for n, bound in iteritems(bounds):
        getattr(model, n)._bounds_init_rule = bound

    logger.debug("Reloaded pyomo model") 
開發者ID:PyPSA,項目名稱:PyPSA,代碼行數:39,代碼來源:opt.py


注:本文中的pyomo.environ.Var方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。