Python pyomo.environ.Var() Examples
The following are 12
code examples of pyomo.environ.Var().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pyomo.environ
, or try the search function
.
Example #1
Source File: conversionDynamic.py From FINE with MIT License | 5 votes |
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))
Example #2
Source File: conversionPartLoad.py From FINE with MIT License | 5 votes |
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))
Example #3
Source File: conversionPartLoad.py From FINE with MIT License | 5 votes |
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))
Example #4
Source File: conversionPartLoad.py From FINE with MIT License | 5 votes |
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))
Example #5
Source File: lopf.py From FINE with MIT License | 5 votes |
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))
Example #6
Source File: component.py From FINE with MIT License | 5 votes |
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))
Example #7
Source File: component.py From FINE with MIT License | 5 votes |
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))
Example #8
Source File: component.py From FINE with MIT License | 5 votes |
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))
Example #9
Source File: component.py From FINE with MIT License | 5 votes |
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))
Example #10
Source File: component.py From FINE with MIT License | 5 votes |
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 # ####################################################################################################################
Example #11
Source File: opt.py From PyPSA with GNU General Public License v3.0 | 5 votes |
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)
Example #12
Source File: opt.py From PyPSA with GNU General Public License v3.0 | 5 votes |
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")