User-Define Functions and DAG Utilities

EAGO has included basic functionality to manipulate user-defined functions. These features are largely experimental and we're interested in providing additional for novel use cases. Please contact us by opening an issue in the Github issue tracker with any questions or requests for additional features.

DAG Substitution and Flattening

EAGO.Script.dag_flattening!Function
dag_flattening!

Flattens (usually) the dag by making all registered substitutions for every nonlinear term in the Optimizer.

EAGO.Script.flatten_expression!Function
flatten_expression!

Flattens (usually) the dag by making all registered substitutions for the expression expr::_NonlinearExprData. Performs a depth-first search through the expression adding the terminal node to the stack, then checking to determine if it matches a registered substitution pattern. If it doesn't not then node is added to the new expression graph representation and it's children are added to the queue. If an expression (node) is identified as a pattern then it is substituted and any children expression nodes are then checked for patterns until the depth first search is exhausted.

EAGO.Script.register_substitution!Function
register_substitution!

Specifies that the src::Template_Graph should be subsituted out for the trg::Template_Graph.

Conventions for substition, the expression to be checked always appears at key 1 in the Template_Graph and operations are ordered from low value to high value left to right so if 1 is a -, and 4 => 1, 3 => 1 then the expression is 4 - 3

EAGO.Script.Template_GraphType
Template_Graph

Holds a list of Template_Nodes, set of directed edges, lengths, an adjacency matrix and the number of children.

EAGO.Script.Template_NodeType
Template_Node

A structure which holds a symbol indicating whether the node is an operator, a number, or an expression type, a value which identifies the function or symbol value, potentially a numeric value num_value, and a check that can be run to verify the node is correct check.

User-Defined Function (UDF) Scrubber

EAGO.Script.scrubFunction
scrub(f::Function, n::Int, inplace = false)

Replaces storage objects and circumvents assertions that present a UDF from being overloaded with subtype Real objects by creating a function which overdubs f in ScrubCtx.

EAGO.Script.scrub!Function
scrub!(d::_NLPData)

Applies scrub to every user-defined function in the a _NLPData structure.