Skip to content

Commit 7834695

Browse files
committed
Added documentation
1 parent 429d99d commit 7834695

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

src/SourceCodeMcCormick.jl

+28-5
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,35 @@ using SymbolicUtils.Code
66
using IfElse
77
using DocStringExtensions
88

9-
# TODO: Need to import Assignment and other stuff probably
10-
# Check out the functionality in ModelingToolkit.jl and Symbolics.jl
11-
9+
"""
10+
AbstractTransform
11+
12+
An abstract type holding possible transform options. Current options are:
13+
- `IntervalTransform`: Only lower/upper bounds, results in 2x as many expressions/equations
14+
(in simple cases)
15+
- `McCormickIntervalTransform`: Lower/upper bounds and convex/concave relaxations, results in
16+
4x as many expressions/equations (in simple cases)
17+
"""
1218
abstract type AbstractTransform end
1319

14-
# ADD documentation for generic function here
20+
"""
21+
transform_rule(::AbstractTransform, ::Equation)
22+
transform_rule(::AbstractTransform, ::Vector{Equation})
23+
transform_rule(::AbstractTransform, ::ModelingToolkit.ODESystem)
24+
transform_rule(::AbstractTransform, ::Num)
25+
26+
Apply the desired transformation to a given expression, equation, set of equations, or ODESystem.
27+
If the `AbstractTransform` is an `IntervalTransform`, all symbols are split into lower and upper
28+
bounds, and the number of expressions/equations is initially doubled. `SourceCodeMcCormick` uses
29+
the auxiliary variable method, so factorable expressions may be separated into multiple expressions
30+
through auxiliary variables. If a `McCormickIntervalTransform` is used, all symbols are split into
31+
lower and upper bounds and convex and concave relaxations. The number of expressions/equations
32+
will thus be initially multiplied by 4, though additional expressions with auxiliary variables will
33+
appear if the expression's complexity warrants it.
34+
35+
In either case, `shrink_eqs` can be used to progressively substitute expressions into one another
36+
to eliminate auxiliary variables and shrink the total number of equations.
37+
"""
1538
function transform_rule end
1639

1740

@@ -25,5 +48,5 @@ export apply_transform, extract_terms, genvar, genparam, get_name,
2548
factor!, binarize!, pull_vars, shrink_eqs, convex_evaluator,
2649
all_evaluators
2750

28-
51+
2952
end

0 commit comments

Comments
 (0)