def __init__(self, model, name, nodes, **kwargs): min_volume = pop_kwarg_parameter(kwargs, 'min_volume', 0.0) if min_volume is None: min_volume = 0.0 max_volume = pop_kwarg_parameter(kwargs, 'max_volume', 0.0) initial_volume = kwargs.pop('initial_volume', 0.0) cost = pop_kwarg_parameter(kwargs, 'cost', 0.0) factors = kwargs.pop('factors', None) days = kwargs.pop('days', None) timesteps = kwargs.pop('timesteps', 0) if not timesteps and not days: raise ValueError("Either `timesteps` or `days` must be specified.") super().__init__(model, name, **kwargs) self.min_volume = min_volume self.max_volume = max_volume self.initial_volume = initial_volume self.cost = cost self.nodes = nodes self.days = days self.timesteps = timesteps if factors is None: self.factors = [1.0 for i in range(len(nodes))] else: self.factors = factors
def __init__(self, model, name, **kwargs): """Initialise a new Node object Parameters ---------- model : Model The model the node belongs to name : string A unique name for the node """ color = kwargs.pop('color', 'black') min_flow = pop_kwarg_parameter(kwargs, 'min_flow', 0.0) if min_flow is None: min_flow = 0.0 max_flow = pop_kwarg_parameter(kwargs, 'max_flow', float('inf')) cost = pop_kwarg_parameter(kwargs, 'cost', 0.0) conversion_factor = pop_kwarg_parameter(kwargs, 'conversion_factor', 1.0) super(Node, self).__init__(model, name, **kwargs) self.slots = {} self.color = color self.min_flow = min_flow self.max_flow = max_flow self.cost = cost self.conversion_factor = conversion_factor
def __init__(self, model, name, nodes, **kwargs): min_volume = pop_kwarg_parameter(kwargs, 'min_volume', 0.0) if min_volume is None: min_volume = 0.0 max_volume = pop_kwarg_parameter(kwargs, 'max_volume', 0.0) if 'volume' in kwargs: # support older API where volume kwarg was the initial volume initial_volume = kwargs.pop('volume') else: initial_volume = kwargs.pop('initial_volume', 0.0) cost = pop_kwarg_parameter(kwargs, 'cost', 0.0) factors = kwargs.pop('factors', None) super(VirtualStorage, self).__init__(model, name, **kwargs) self.min_volume = min_volume self.max_volume = max_volume self.initial_volume = initial_volume self.cost = cost self.nodes = nodes if factors is None: self.factors = [1.0 for i in range(len(nodes))] else: self.factors = factors
def __init__(self, model, name, num_outputs=1, num_inputs=1, *args, **kwargs): # cast number of inputs/outputs to integer # this is needed if values come in as strings sometimes num_outputs = int(num_outputs) num_inputs = int(num_inputs) min_volume = pop_kwarg_parameter(kwargs, 'min_volume', 0.0) if min_volume is None: min_volume = 0.0 max_volume = pop_kwarg_parameter(kwargs, 'max_volume', 0.0) initial_volume = kwargs.pop('initial_volume', 0.0) initial_volume_pc = kwargs.pop('initial_volume_pc', None) cost = pop_kwarg_parameter(kwargs, 'cost', 0.0) level = pop_kwarg_parameter(kwargs, 'level', None) area = pop_kwarg_parameter(kwargs, 'area', None) position = kwargs.pop("position", {}) super(Storage, self).__init__(model, name, **kwargs) self.outputs = [] for n in range(0, num_outputs): self.outputs.append( StorageOutput(model, name="[output{}]".format(n), parent=self)) self.inputs = [] for n in range(0, num_inputs): self.inputs.append( StorageInput(model, name="[input{}]".format(n), parent=self)) self.min_volume = min_volume self.max_volume = max_volume self.initial_volume = initial_volume self.initial_volume_pc = initial_volume_pc self.cost = cost self.position = position self.level = level self.area = area # TODO FIXME! # StorageOutput and StorageInput are Cython classes, which do not have # NodeMeta as their metaclass, therefore they don't get added to the # model graph automatically. for node in self.outputs: self.model.graph.add_node(node) for node in self.inputs: self.model.graph.add_node(node) # TODO: keyword arguments for input and output nodes specified with prefix '''
def __init__(self, *args, **kwargs): """ Keywords: control_curve - A Parameter object that can return the control curve position, as a percentage of fill, for the given timestep. """ control_curve = pop_kwarg_parameter(kwargs, 'control_curve', None) above_curve_cost = kwargs.pop('above_curve_cost', None) cost = kwargs.pop('cost', 0.0) if above_curve_cost is not None: if control_curve is None: # Make a default control curve at 100% capacity control_curve = ConstantParameter(1.0) elif not isinstance(control_curve, Parameter): # Assume parameter is some kind of constant and coerce to ConstantParameter control_curve = ConstantParameter(control_curve) if not isinstance(cost, Parameter): # In the case where an above_curve_cost is given and cost is not a Parameter # a default cost Parameter is created. kwargs['cost'] = ControlCurveParameter( self, control_curve, [above_curve_cost, cost]) else: raise ValueError( 'If an above_curve_cost is given cost must not be a Parameter.' ) else: # reinstate the given cost parameter to pass to the parent constructors kwargs['cost'] = cost super(Reservoir, self).__init__(*args, **kwargs)
def __init__(self, *args, **kwargs): """Initialise a new Blender node Parameters ---------- ratio : float (optional) The ratio to constraint the two routes by (0.0-0.1). If no value is given a default value of 0.5 is used. """ Link.__init__(self, *args, **kwargs) self.slots = {1: None, 2: None} self.properties['ratio'] = pop_kwarg_parameter(kwargs, 'ratio', 0.5)
def __init__(self, model, name, outputs=1, inputs=1, *args, **kwargs): min_volume = pop_kwarg_parameter(kwargs, "min_volume", 0.0) if min_volume is None: min_volume = 0.0 max_volume = pop_kwarg_parameter(kwargs, "max_volume", 0.0) initial_volume = kwargs.pop("initial_volume", None) initial_volume_pc = kwargs.pop("initial_volume_pc", None) cost = pop_kwarg_parameter(kwargs, "cost", 0.0) level = pop_kwarg_parameter(kwargs, "level", None) area = pop_kwarg_parameter(kwargs, "area", None) super(Storage, self).__init__(model, name, **kwargs) self.outputs = [] for n in range(0, outputs): self.outputs.append( StorageOutput(model, name="[output{}]".format(n), parent=self)) self.inputs = [] for n in range(0, inputs): self.inputs.append( StorageInput(model, name="[input{}]".format(n), parent=self)) self.min_volume = min_volume self.max_volume = max_volume self.initial_volume = initial_volume self.initial_volume_pc = initial_volume_pc self.cost = cost self.level = level self.area = area # StorageOutput and StorageInput are Cython classes, which do not have # NodeMeta as their metaclass, therefore they don't get added to the # model graph automatically. for node in self.outputs: self.model.graph.add_node(node) for node in self.inputs: self.model.graph.add_node(node)
def __init__(self, model, name, nodes, **kwargs): min_volume = pop_kwarg_parameter(kwargs, "min_volume", 0.0) if min_volume is None: min_volume = 0.0 max_volume = pop_kwarg_parameter(kwargs, "max_volume", 0.0) initial_volume = kwargs.pop("initial_volume", None) initial_volume_pc = kwargs.pop("initial_volume_pc", None) cost = pop_kwarg_parameter(kwargs, "cost", 0.0) factors = kwargs.pop("factors", None) super(VirtualStorage, self).__init__(model, name, **kwargs) self.min_volume = min_volume self.max_volume = max_volume self.initial_volume = initial_volume self.initial_volume_pc = initial_volume_pc self.cost = cost self.nodes = nodes if factors is None: self.factors = [1.0 for i in range(len(nodes))] else: self.factors = factors