当前位置: 首页>>代码示例>>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;未经允许,请勿转载。