4.1.11.1. hyperflow/LinExp

This part describes variable specifiers, linear expressions, and linear constraints. See Variable Specifiers, Linear Expressions, and Constraints for a higher-level description of these entities.

Linear expressions (hyperflow.LinExp) and constraints (hyperflow.LinConstraint) can be implicitly created from variable specifiers and operators, meaning one rarely need to instantiate them explicitly. However creating the zero-expression might sometimes be useful (e.g., in a sum expression) and can be done simply with the expression hyperflow.LinExp().

A variable specifier is a representation of either a single variable or a sum of variables. The addition, multiplication and division operators are overloaded for variable specifiers and linear expressions such that expressions can be written in the natural manner.

The operators <=, == and >= are overloaded on linear expressions to make the creation of linear constraints easier. However, one argument to the operator must be a linear expression while the other argument must be a number.

All variable specifiers are defined in module scope. See Hyperflow Model for an overview of the specifiers.

class hyperflow.VarSumVertex

Represents the sum of all variables indicated by the given id. Can be indexed to retrieve a specifier for a single variable in the set.

__init__(id)

Construct a variable specifier for a sum of variables associated with vertices in the underlying derivation graph.

Parameters:

id (str) – The ID for the variable set to represent.

__getitem__(x)

Select the variable associated with the derivation graph vertex which represents the given object. When the resulting specifier is given to a flow model, if the given object is a vertex, then it must belong to the same derivation graph as the one underlying the model. If the given object is a graph, a vertex in the underlying derivation graph must exist which has the graph associated.

Parameters:

x (DG.Vertex or Graph) – a graph or vertex used to select a vertex in the underlying derivation graph.

Returns:

a variable specifier for a single variable in the set represented by this object.

Return type:

VarVertex or VarVertexGraph

id

The ID for this specifier.

Type:

str

class hyperflow.VarVertex

Represents a variable associated with a single vertex in a derivation graph.

__init__(id, v)
Parameters:
  • id (str) – The ID for the variable set to select variables from.

  • v (DG.Vertex) – The vertex used to select a variable from the variable set.

id

The ID for the underlying set specifier.

Type:

str

vertex

The graph used to index into the variable set.

Type:

DG.Vertex

class hyperflow.VarVertexGraph

Represents a variable associated with a single vertex in a derivation graph. This is done implicitly by a graph, and when this specifier is later given to a flow model a vertex with the graph associated must exist in the underlying derivation graph.

__init__(id, g)
Parameters:
  • id (str) – The ID for the variable set to select variables from.

  • g (Graph) – The graph used to select a variable from the variable set.

id

The ID for the underlying set specifier.

Type:

str

graph

The graph used to index into the variable set.

Type:

Graph

class hyperflow.VarSumEdge

Represents the sum of all variables indicated by the given id. Can be indexed to retrieve a specifier for a single variable in the set.

__init__(id)

Construct a variable specifier for a sum of variables associated with edges in the underlying derivation graph.

Parameters:

id (str) – The ID for the variable set to represent.

__getitem__(e)

Select the variable associated with the derivation graph edge which represents the given object. When the resulting specifier is given to a flow model, the given edge must be long to the same derivation graph as the one underlying the model.

Parameters:

e (DG.HyperEdge) – an edge used to select a variable.

Returns:

a variable specifier for a single variable in the set represented by this object.

Return type:

VarEdge

id

The ID for this specifier.

Type:

str

class hyperflow.VarEdge

Represents a variable associated with an edge in a derivation graph.

__init__(id, e)
Parameters:
  • id (str) – The ID for the variable set to select variables from.

  • e (DG.HyperEdge) – The edge used to select a variable from the variable set.

id

The ID for the underlying set specifier.

Type:

str

edge

The edge used to index into the variable set.

Type:

DG.HyperEdge

class hyperflow.VarSumCustom

Represents the sum of all variables indicated by the given id. Can be indexed to retrieve a specifier for a single variable in the set.

__init__(id)

Construct a variable specifier for a sum of custom variables.

Parameters:

id (str) – The ID for the variable set to represent.

__getitem__(id)

Select the variable associated with the given name. When the resulting specifier is given to a flow model that variable must have been created in the specification in some way.

Parameters:

e (str) – a name used to select a variable.

Returns:

a variable specifier for a single variable in the set represented by this object.

Return type:

VarCustom

id

The ID for this specifier.

Type:

str

class hyperflow.VarCustom

Represents a custom variable.

__init__(id, name)
Parameters:
  • id (str) – The ID for the variable set to select variables from.

  • name (str) – The name used to select a variable from the variable set.

id

The ID for the underlying set specifier.

Type:

str

name

The name used to index into the variable set.

Type:

str

class hyperflow.Var

Represents any variable specifier. They are all implicitly convertible to this type.

class hyperflow.LinExp

Represents a linear expression over variable specifiers.

The usual arithmetic operators are overloaded on variable specifiers and this class to automatically create expressions.

class hyperflow.LinConstraint

Represents a linear constraint with a hyperflow.LinExp on one side, and a constant on the other side. The operators <=, ==, and >= are overloaded on linear expressions to automatically create constraints.

4.1.11.1.1. Pre-defined Variable Specifiers

Each of the variable specifiers are defined in the submodule hyperflow.vars, and then import in the root module, so they are directly accessible.

4.1.11.1.1.1. Base Model

hyperflow.vars.inFlow
mod.inFlow
Type:

hyperflow.VarSumVertex

hyperflow.vars.outFlow
mod.outFlow
Type:

hyperflow.VarSumVertex

hyperflow.vars.isInUsed
mod.isInUsed
Type:

hyperflow.VarSumVertex

hyperflow.vars.isOutUsed
mod.isOutUsed
Type:

hyperflow.VarSumVertex

hyperflow.vars.isInLessOut
mod.isInLessOut
Type:

hyperflow.VarSumVertex

hyperflow.vars.isInGreaterOut
mod.isInGreaterOut
Type:

hyperflow.VarSumVertex

hyperflow.vars.isInOutZero
mod.isInOutZero
Type:

hyperflow.VarSumVertex

hyperflow.vars.vertexFlow
mod.vertexFlow
Type:

hyperflow.VarSumVertex

hyperflow.vars.isVertexUsed
mod.isVertexUsed
Type:

hyperflow.VarSumVertex

hyperflow.vars.transitInternalFlow
mod.transitInternalFlow
Type:

hyperflow.VarSumVertex

hyperflow.vars.edgeFlow
mod.edgeFlow
Type:

hyperflow.VarSumEdge

hyperflow.vars.isEdgeUsed
mod.isEdgeUsed
Type:

hyperflow.VarSumEdge

hyperflow.vars.isBothReverseUsed
mod.isBothReverseUsed
Type:

hyperflow.VarSumEdge

4.1.11.1.1.2. OverallCatalysis

hyperflow.vars.isOverallCata
mod.isOverallCata
Type:

hyperflow.VarSumVertex

4.1.11.1.1.3. OverallAutocatalysis

hyperflow.vars.isOverallAutocata
mod.isOverallAutocata
Type:

hyperflow.VarSumVertex

4.1.11.1.1.4. Thermodynamics

hyperflow.vars.energy
mod.energy
Type:

hyperflow.VarSumVertex

hyperflow.vars.logConcentration
mod.logConcentration
Type:

hyperflow.VarSumVertex

hyperflow.vars.deltaEnergy
mod.deltaEnergy
Type:

hyperflow.VarSumEdge