reno.components.Flow#

class reno.components.Flow(eq=None, label=None, doc=None, min=None, max=None, dim=1, group='', cgroup='', dtype=None)#

Bases: TrackedReference

A flow is a rate, a movement of some material/thing/quantity per some unit of time.

Flow equations probably reference stocks, moving stuff from one stock to another etc. Flows are what stocks are defined in terms of (in_flows and out_flows.)

https://insightmaker.com/docs/flows https://en.wikipedia.org/wiki/Stock_and_flow

Methods

__init__([eq, label, doc, min, max, dim, ...])

Create a rate of change equation.

astype(dtype)

Returns a symbolic operation to convert the output of this equation to the specified type.

clip(min, max)

Returns a symbolic operation for enforcing the output is between the passed min and max.

debug_equation(t[, sample])

Get a latex string output with the debug version of this equation.

display()

Display an ipython markdown with the equation latex.

equal(obj)

Returns a symbolic operation for checking equality with passed object.

equation(**kwargs)

Return the full latex string representation for the entire equation, not just the right hand side.

eval([t, save, force])

Compute the equation for the given timestep.

find_parts_of_type(search_type[, ...])

Recursively search for all EquationParts in the tree of the specified type.

from_dict(data, refs)

Deserialize reference and parse data from dictionary previously saved from to_dict().

get_shape()

Get the size of the additional "data" dimension.

get_type()

Get the type of the target output of this equation expression.

history(index_eq)

Get a reference to a previous value of this reference.

initial_vals()

Variables can be set to distributions, so the inital vals in that case will be a population sampled from the eq distribution.

is_static()

Convenience shortcut for reno.utils.is_static() - True if this equation doesn't rely on any dynamic values (thus constant), False if it does.

latex(**kwargs)

Get the string representation for referring to this flow, italized and as a function of t to better represent that this should be a rate?

max_refs()

Get any references found in the max constraint equation.

mean([axis])

Returns a symbolic operation to find the series-wise mean of the array.

min_refs()

Get any references found in the min constraint equation.

not_equal(obj)

Returns a symbolic operation for checking inequality with passed object.

plot([ax])

Plot (or add to passed axes) this reference's values.

populate(n, steps)

Initialize the matrix of values with size n x steps.

pt(**refs)

Get a pytensor graph representing this piece of an equation.

pt_str(**refs)

Construct a string containing relevant pytensor code for this piece of the equation.

qual_name([dot])

Get a string with both the model and the reference name if this model is a submodel of something else.

resolve_init_array(obj_or_eq)

Convert a number or scalar/distribution into correct starting array.

seek_refs([include_ref_types])

Recursively find a list of all References immediately underneath this part.

series_max()

Returns a symbolic operation to find the series-wise maximum of the array.

series_min()

Returns a symbolic operation to find the series-wise minimum of the array.

sum([axis])

Returns a symbolic operation to find the series-wise sum of the array.

to_dict()

Serialize class into a dictionary for saving to file.

Attributes

dtype

The type of each underlying value.

shape

The size of the data dimension, 1 by default.

timeseries

Returns symbolic operation for getting a timeseries view of the data.

model

Keep a reference to container model, makes it easier to compare refs across multiple models.

init

Initial value/equation for initial value for stock/flow/var at t=0

dim

Size of an optional extra dimension, allowing a given reference to describe a vector of values at every timestep.

implicit

Implicit components (normally created as subcomponents of more advanced operations) don't show up in diagrams, latex, or output JSON, since they are created by operations.

computed_mask

Follows same shape as value (up through first two dimensions), set of booleans indicating which values have already been evaluated and saved.

label

Label is what's used in any visual representation (e.g. allows spaces where name does not.).

doc

A docstring to explain/describe the reference.

Parameters:
__annotations__ = {}#
__lshift__(stock)#

Return stock with this flow applied as an outflow.

(outflow << stock)

Parameters:

stock (Stock)

Return type:

Stock

__module__ = 'reno.components'#
__rshift__(stock)#

Return stock with this flow applied as an inflow.

(inflow >> stock)

Parameters:

stock (Stock)

Return type:

Stock

__setattr__(name, value)#

Implement setattr(self, name, value).

Parameters:
  • name (str)

  • value (Any)

Return type:

None

debug_equation(t, sample=0, **kwargs)#

Get a latex string output with the debug version of this equation.

Parameters:
  • t (int)

  • sample (int)

  • kwargs (dict)

Return type:

str

display()#

Display an ipython markdown with the equation latex.

Return type:

None

equation(**kwargs)#

Return the full latex string representation for the entire equation, not just the right hand side.

Parameters:

kwargs (dict)

Return type:

str

initial_vals()#

Variables can be set to distributions, so the inital vals in that case will be a population sampled from the eq distribution.

Return type:

None

latex(**kwargs)#

Get the string representation for referring to this flow, italized and as a function of t to better represent that this should be a rate?

Parameters:

kwargs (dict)

Return type:

str