@@ -487,12 +487,14 @@ julia> struct Expression
487
487
```
488
488
489
489
For each node ` node ` in the ` .nodes ` field, if ` node.type ` is:
490
+
490
491
* ` NODE_CALL_MULTIVARIATE ` , we look up
491
492
` MULTIVARIATE_OPERATORS[node.index] ` to retrieve the operator
492
493
* ` NODE_CALL_UNIVARIATE ` , we look up
493
494
` UNIVARIATE_OPERATORS[node.index] ` to retrieve the operator
494
495
* ` NODE_VARIABLE ` , we create ` MOI.VariableIndex(node.index) `
495
496
* ` NODE_VALUE ` , we look up ` values[node.index] `
497
+
496
498
The ` .parent ` field of each node is the integer index of the parent node in
497
499
` .nodes ` . For the first node, the parent is ` -1 ` by convention.
498
500
@@ -511,6 +513,16 @@ julia> expr = Expression(
511
513
);
512
514
```
513
515
516
+ The ordering of the nodes in the tape must satisfy two rules:
517
+
518
+ * The children of a node must appear after the parent. This means that the tape
519
+ is ordered topologically, so that a reverse pass of the nodes evaluates all
520
+ children nodes before their parent
521
+ * The arguments for a ` CALL ` node are ordered in the tape based on the order in
522
+ which they appear in the function call.
523
+
524
+ #### Design goals
525
+
514
526
This is less readable than the other options, but does this data structure meet
515
527
our design goals?
516
528
@@ -524,9 +536,6 @@ easy to identify the _parent_ of any node. Therefore, we can use
524
536
[ ` Nonlinear.adjacency_matrix ` ] ( @ref ) to compute a sparse matrix that maps
525
537
parents to their children.
526
538
527
- The tape is also ordered topologically, so that a reverse pass of the nodes
528
- evaluates all children nodes before their parent.
529
-
530
539
### The design in practice
531
540
532
541
In practice, ` Node ` and ` Expression ` are exactly [ ` Nonlinear.Node ` ] ( @ref )
0 commit comments