relentless.model.Variable#
- class relentless.model.Variable(name=None)#
Abstract base class for a variable.
A variable represents a single scalar quantity. The
valueof the variable is an abstract property that must be implemented. On creation, theVariablewill be inserted into theVariableGraphfor the project.Most users should not inherit from this variable directly but should make use of the more flexible
IndependentVariableorDependentVariabletypes.- Parameters:
name (str) – Optional name for the variable. The name must be unique. If one is not specified, a mangled name
__x[id]will be automatically created, whereidis the unique index identifying the variable.
- name#
Name of the variable (specified or autogenerated).
- Type:
name
Examples
Create variables with specified value:
x = relentless.variable.IndependentVariable(value=2.0)
If the value is numerical, arithmetic operations are available:
>>> print(x+2.0) 4.0 >>> print(5.0-x) 1.0 >>> print(2.0*x) 2.0 >>> print(x/4.0) 0.5 >>> print(x**2) 0.25 >>> print(-x) -0.25
Methods
Attributes
countnamesValue of the variable.