Add estimator interface

This commit is contained in:
Rubydragon 2023-10-17 19:22:05 +02:00 committed by Anton Reinhard
parent 2709eeb3dc
commit 61b6541b81
3 changed files with 38 additions and 0 deletions

View File

@ -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]
```

View File

@ -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")

View File

@ -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