pycopancore.data_model.variable module

A class to define model variables, inherits from Symbol.

Each Variable can be connected to any number of entity types and/or process taxa.

EPS = 1e-10

infinitesimal value for ensuring strict bounds

class Variable(name, *args, **assumptions)[source]

Bases: Symbol

Metadata object representing a model variable or parameter.

AMIP = None
CETS = None
CF = None
IAMC = None
ODE_dependencies = None
__getitem__(instance)[source]

magic method allowing access to instance values via var[instance]

__setitem__(instance, value)[source]

magic method allowing access to instance values via var[instance]

_assumptions0
_assumptions_orig
_can_be_target = True
_check_valid(v)[source]

check validity of candidate value

_explicit_class_assumptions = {}
_get_instances(instances)[source]
_iterable = False
_prop_handler = {'extended_negative': <function Expr._eval_is_extended_negative>, 'extended_positive': <function Expr._eval_is_extended_positive>}
_uid = None
add_derivatives(values)[source]

adds summands to referenced attribute values

add_noise(instances=None, distribution=<bound method Random.gauss of <random.Random object>>, *, factor=1, offset=0, multiplicative=False)[source]

Set values in selected entities to random value. If distribution=None, use uninformed_prior. If optional p is given, replace current value only with probability p.

allow_none = None
array_shape = None
assert_valid(value)[source]

Make sure by assertion that value is valid

property branchings

Branchings.

property cardinalities

Cardinalities.

clear_derivatives(*, instances=None)[source]

Set all derivatives to zero.

Parameters:

instances (list) – List of the entities

codename = None
convert_to_standard_units(instances=None)[source]

Convert to standart units.

Replace all variable values of type DimensionalQuantity to float using the standard unit

copy(**kwargs)[source]
datatype = None
property default

default initial value

default_assumptions = {}
desc = None
eval(instances=None, *, unit=None)[source]

Return values for given entities, optionally in a different unit.

Parameters:

instances (iterable) – List of entities/process taxa

Return type:

List of variable value of each entity

explicit_dependencies = None
fast_set_values(values)[source]

fast-track method to set values without checks and conversions

get_derivatives(instances=None)[source]

Return a list of derivatives saved in entities.

Parameters:

instances (list) – List of entities/process taxa

get_quantity(instance, unit=None)[source]
get_value(instance, unit=None)[source]

Get value.

get_values(instances, unit=None)[source]

Get values.

is_extensive = None
is_intensive = None
is_valid(value)[source]

Is valid.

levels = None
lower_bound = None
name
owning_class = None
quantum = None
readonly = None
ref = None
scale = None
set_to_default(instances=None)[source]

Set values in selected entities to default if a default was given

set_to_random(instances=None, distribution=None, *, p=1)[source]

Set values in selected entities to random value. If distribution=None, use uninformed_prior. If optional p is given, replace current value only with probability p.

set_value(instance, value)[source]

Set value for some instance, possibly performing conversion to correct unit if value is a DimensionalQuantity, otherwise using own default unit

set_values(instances=None, values=None, *, dictionary=None)[source]

Set values for the variable.

This function set values for the variable. If given a list of entities, it sets values for all of them.

Parameters:
  • dictionary (dictionary) – Optional dictionary of variable values keyed by Entity object (e.g. {cell:location, individual:age}, …)

  • instances (list) – List of entities/process taxa

  • values (list/array) – Optional corresponding list or array of values

strict_lower_bound = None
strict_upper_bound = None
symbol = None
property target_class

Target class.

property target_instances

Target instances.

property target_variable

Target variable.

uninformed_prior = None
unit = None
upper_bound = None