Algorithms
Work in progress.
Parameters of an algorithm
From a user perspective, the algorithms are objects that contains a set of parameters.
The object must inherit from Coluna.AlgoAPI.AbstractAlgorithm
. We usually provide a keyword constructor to define default values for parameters and therefore ease the definition of the object.
struct MyCustomAlgorithm <: Coluna.AlgoAPI.AbstractAlgorithm
param1::Int
param2::Float64
child_algo::Coluna.AlgoAPI.AbstractAlgorithm
end
# Help the user to define the algorithm:
function MyCustomAlgorithm(;
param1 = 1,
param2 = 2,
child_algo = AnotherAlgorithm()
)
return MyCustomAlgorithm(param1, param2, child_algo)
end
Algorithms can use other algorithms. They are organized as a tree structure.
** Example for the TreeSearchAlgorithm **:
Coluna.AlgoAPI.AbstractAlgorithm
— TypeSupertype for algorithms parameters. Data structures that inherit from this type are intented for the users. The convention is to define the data structure together with a constructor that contains only kw args.
For instance:
struct MyAlgorithmParams <: AbstractAlgorithmParams
param1::Int
param2::Int
MyAlgorithmParams(; param1::Int = 1, param2::Int = 2) = new(param1, param2)
end
Init
Parameters checking
When Coluna starts, it initializes the algorithms chosen by the user. A most important step is to check the consistency of the parameters supplied by the user and the compatibility of the algorithms with the model that will be received (usually MathProg.Reformulation
). Algorithms usually have many parameters and are sometimes interdependent and nested. It is crucial to ensure that the user-supplied parameters are correct and give hints to fix them otherwise.
The entry-point of the parameter consistency checking is the following method:
Coluna.Algorithm.check_alg_parameters
— Functioncheck_alg_parameters(top_algo, reform) -> Vector{Tuple{Symbol, AbstractAlgorithm, Any}}
Checks the consistency of the parameters of the top algorithm and its children algorithms. Returns a vector of tuples (name of the parameter, algorithm, value of the parameter) that lists all the inconsistencies found in the algorithms tree.
Developer of an algorithm must implement the following methods:
Missing docstring for Coluna.Algorithm.check_parameter
. Check Documenter's build log for details.
Units usage
Missing docstring for Coluna.AlgoAPI.get_child_algorithms
. Check Documenter's build log for details.
Missing docstring for Coluna.AlgoAPI.get_units_usage
. Check Documenter's build log for details.
Run
Coluna.AlgoAPI.run!
— Functionrun!(algo::AbstractAlgorithm, env, model, input)
Default method to call an algorithm.