A Reference is a name binding. It binds a name, such as
to an object.
References are manually created by the user
as attributes of
>>> space.foo = 1
When a Reference is created as an attribute of a
the name becomes available in the namespace associated with the
The Formulas of child
Cells of the
UserSpace are evaluated in the namespace,
so the name that appears in the Formulas refers to the object
that the name is bound to by the Reference.
Continuing with the above example,
suppose a Cells
baz is defiened in the same Space
>>> space.baz.formula def baz(): return foo
foo in the
baz definition referes to
>>> space.baz() 1
>>> model.bar = "bar"
bar defined above is also defined in
>>> space.bar 'bar'
bar can be referred to from the Formulas of child
>>> def baz(): ... return bar >>> space.baz = baz >>> space.baz.formula def baz(): return bar >>> space.baz() 'bar'
Reference objects themselves are hidden from the user,
and the bound objects are always referenced by the names.
To access the attributes of
ReferenceProxy objects are used.
- class ReferenceProxy(impl)¶
Proxy to interface to References
Reference objects are not exposed to the user, thus ReferenceProxy objects are used to interface to References. A proxy object to a Reference can be created and returned by the
get_object()function, by passing the full dotted name of the Reference to
>>> mx.get_object("Model1.Space1.foo", as_proxy=True)
Reference shares its ultimate base class with Model, Space and Cells classes, and below are attributes common among those classes.
The parent of the Reference.
The Model that the Reference belongs to.