# Entities¶

##
`Constr`

¶

##
`Graph`

¶

The graph class.

Graphs are created by adding them to a model using the the addGraph method.

###
```
idx: int
```

`property`

`readonly`

¶

The unique id of the graph in the model.

###
```
m: int
```

`property`

`readonly`

¶

The number of edges.

###
```
n: int
```

`property`

`readonly`

¶

The number of vertices.

###
```
sink: int
```

`property`

`readonly`

¶

The sink vertex of the graph.

###
```
source: int
```

`property`

`readonly`

¶

The source vertex of the graph.

###
```
vars: List[Var]
```

`property`

`readonly`

¶

The edge variables associated to the graph

##
`LinEqua`

¶

Class to represent linear equations.

Equations are primarily used as temporary objects when adding linear expressions to models. It should not be necessary to use them by themselves.

The equation consists of an LinExpr and a ConstrSense such that

```
expr = 2 * x + 3 * y + 6
equa = LinEqua(expr, 'L') # 2 * x + 3 * y <= 6
equa = expr <= 0 # 2 * x + 3 * y <= 6
```

The LinEqua derives from LinExpr and can be manipulated in the same fashion.

###
```
__init__(self, expr, sense='E', rhs=0)
```

`special`

¶

Initialize linear equation

**Parameters:**

Name | Type | Description | Default |
---|---|---|---|

`expr` |
`Union[LinExpr, LinEqua]` |
An expression or copy from another equation |
required |

`sense` |
`str` |
The constraints sense as either Equal, LessOrEqual, or GreaterOrEqual. |
`'E'` |

##
`LinExpr`

¶

Class to represent linear expressions.

Expressions are operator overloaded so it is possible to do

```
expr = 2 * x - y + 4
expr += 3 * z
expr *= 2
expr += otherExpr
```

###
```
coefs: List[float]
```

`property`

`readonly`

¶

A list of the coefficients.

###
```
constant: float
```

`property`

`readonly`

¶

The constant term.

###
```
vars: List[Var]
```

`property`

`readonly`

¶

A list of the variables.

###
```
__init__(self, coefs=[], vars=[], constant=0.0)
```

`special`

¶

Initialize linear expression

**Parameters:**

Name | Type | Description | Default |
---|---|---|---|

`coefs` |
`List[float]` |
List of coefficients. |
`[]` |

`vars` |
`List[Var]` |
List of variables. |
`[]` |

`constant` |
`float` |
A constant term |
`0.0` |

**Exceptions:**

Type | Description |
---|---|

`ValueError` |
If |

###
```
addConstant(self, constant)
```

¶

Adds a constant to the linear expression.

**Parameters:**

Name | Type | Description | Default |
---|---|---|---|

`constant` |
`float` |
The constant to add. |
required |

###
```
addExpr(self, expr)
```

¶

Adds another expression to the linear expression.

**Parameters:**

Name | Type | Description | Default |
---|---|---|---|

`expr` |
`LinExpr` |
The expression to add. |
required |

###
```
addTerm(self, coef, var)
```

¶

Adds a term to the linear expression.

**Parameters:**

Name | Type | Description | Default |
---|---|---|---|

`coef` |
`float` |
The coefficients. |
required |

`var` |
`Var` |
The variable. |
required |

##
`Path`

¶

The path class.

Paths represents a list of edge variables for a graph in a solution. Obtain the paths of a solution using the path property.

###
```
graphIdx: int
```

`property`

`readonly`

¶

The id of the graph the path is associated to.

###
```
idx: int
```

`property`

`readonly`

¶

The unique id of the path in a solution.

###
```
obj: float
```

`property`

`readonly`

¶

The objective coefficient.

###
```
vars: List[Var]
```

`property`

`readonly`

¶

The edge variables associated to the path.

###
```
x: float
```

`property`

`readonly`

¶

The value in the current solution.

##
`Solution`

¶

The solution class.

A solution holds a list of non-zero variables and a (if applicable) a list of paths. Obtain the solutions from the model using the solutions property.

###
```
idx: int
```

`property`

`readonly`

¶

The unique id of the solution.

###
```
objectiveValue: float
```

`property`

`readonly`

¶

The objective value of the solution.

###
```
paths: List[Path]
```

`property`

`readonly`

¶

The paths associated to the solution.

###
```
vars: List[Var]
```

`property`

`readonly`

¶

The variables in the solution. Including edge variables.

##
`Var`

¶

The variable class.

Variables are created by adding variables to a model using the either the addVar method to create a single variable or the addGraph method to add a graph with corresponding edge variables stored in the Graph.vars property.

For an edge variable this class offers the possibility to query for source and target vertices or the edge in the graph.

###
```
edge: Tuple[int, int]
```

`property`

`readonly`

¶

The edge of a edge variable.

**Exceptions:**

Type | Description |
---|---|

`ValueError` |
If the variable is not associated with a graph. |

###
```
graphIdx: int
```

`property`

`readonly`

¶

The id of the graph the variable is associated to.

**Exceptions:**

Type | Description |
---|---|

`ValueError` |
If the variable is not associated with a graph. |

###
```
idx: int
```

`property`

`readonly`

¶

The unique id of the variable in the model.

###
```
lb: float
```

`property`

`readonly`

¶

The lower bound.

###
```
name: str
```

`property`

`readonly`

¶

The variable name.

###
```
obj: float
```

`property`

`readonly`

¶

The objective coefficient.

###
```
source: int
```

`property`

`readonly`

¶

The source vertex of a edge variable.

**Exceptions:**

Type | Description |
---|---|

`ValueError` |
If the variable is not associated with a graph. |

###
```
target: int
```

`property`

`readonly`

¶

The target vertex of a edge variable.

**Exceptions:**

Type | Description |
---|---|

`ValueError` |
If the variable is not associated with a graph. |

###
```
ub: float
```

`property`

`readonly`

¶

The upper bound.

###
```
x: float
```

`property`

`readonly`

¶

The value in the current solution