relentless.model.Variable#

class relentless.model.Variable(name=None)#

Abstract base class for a variable.

A variable represents a single scalar quantity. The value of the variable is an abstract property that must be implemented. On creation, the Variable will be inserted into the VariableGraph for the project.

Most users should not inherit from this variable directly but should make use of the more flexible IndependentVariable or DependentVariable types.

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, where id is the unique index identifying the variable.

id#

Unique index indentifying the variable.

Type:

int

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

count

names

value

Value of the variable.

abstract property value#

Value of the variable.

Type:

float