diff --git a/docs/src/lib/internals/estimator.md b/docs/src/lib/internals/estimator.md new file mode 100644 index 0000000..d814d4a --- /dev/null +++ b/docs/src/lib/internals/estimator.md @@ -0,0 +1,11 @@ +# Models + +## Interface + +The interface that has to be implemented for an estimator. + +```@autodocs +Modules = [MetagraphOptimization] +Pages = ["models/estimator.jl"] +Order = [:type, :constant, :function] +``` diff --git a/src/MetagraphOptimization.jl b/src/MetagraphOptimization.jl index ac0b1ef..ddac405 100644 --- a/src/MetagraphOptimization.jl +++ b/src/MetagraphOptimization.jl @@ -121,6 +121,8 @@ include("task/compute.jl") include("task/print.jl") include("task/properties.jl") +include("estimator/interface.jl") + include("models/interface.jl") include("models/print.jl") diff --git a/src/estimator/interface.jl b/src/estimator/interface.jl new file mode 100644 index 0000000..5d66d4a --- /dev/null +++ b/src/estimator/interface.jl @@ -0,0 +1,25 @@ + +""" + AbstractEstimator + +Abstract base type for an estimator. An estimator estimates the cost of a graph or the difference an operation applied to a graph will make to its cost. + +Interface functions are +- [`graph_cost`](@ref) +- [`operation_effect`](@ref) +""" +abstract type AbstractEstimator end + +""" + graph_cost(estimator::AbstractEstimator, graph::DAG) + +Get the total estimated cost of the graph. The cost's data type can be chosen by the implementation, but should have usable comparison operators (<, <=, >, >=, ==) and basic math operators (+, -, *, /). +""" +function graph_cost end + +""" + operation_effect(estimator::AbstractEstimator, graph::DAG, operation::Operation) + +Get the estimated effect on the cost of the graph, such that `graph_cost(estimator, graph) + operation_effect(estimator, graph, operation) ~= graph_cost(estimator, graph_with_operation_applied)`. There is no hard requirement for this, but the better the estimate, the better an optimization algorithm will be. +""" +function operation_effect end