Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions docs/src/submodules/Nonlinear/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -487,12 +487,14 @@ julia> struct Expression
```

For each node `node` in the `.nodes` field, if `node.type` is:

* `NODE_CALL_MULTIVARIATE`, we look up
`MULTIVARIATE_OPERATORS[node.index]` to retrieve the operator
* `NODE_CALL_UNIVARIATE`, we look up
`UNIVARIATE_OPERATORS[node.index]` to retrieve the operator
* `NODE_VARIABLE`, we create `MOI.VariableIndex(node.index)`
* `NODE_VALUE`, we look up `values[node.index]`

The `.parent` field of each node is the integer index of the parent node in
`.nodes`. For the first node, the parent is `-1` by convention.

Expand All @@ -511,6 +513,16 @@ julia> expr = Expression(
);
```

The ordering of the nodes in the tape must satisfy two rules:

* The children of a node must appear after the parent. This means that the tape
is ordered topologically, so that a reverse pass of the nodes evaluates all
children nodes before their parent
* The arguments for a `CALL` node are ordered in the tape based on the order in
which they appear in the function call.

#### Design goals

This is less readable than the other options, but does this data structure meet
our design goals?

Expand All @@ -524,9 +536,6 @@ easy to identify the _parent_ of any node. Therefore, we can use
[`Nonlinear.adjacency_matrix`](@ref) to compute a sparse matrix that maps
parents to their children.

The tape is also ordered topologically, so that a reverse pass of the nodes
evaluates all children nodes before their parent.

### The design in practice

In practice, `Node` and `Expression` are exactly [`Nonlinear.Node`](@ref)
Expand Down