SearchModels
Provides a generic method for minimizing model errors using stochastic search, which is often used whenever the problem has no concept of derivative. This kind of problems rely on large exploration of combinatorial spaces based on error function.
SearchModels
rely on basic exploration functions that can be specified for many applications.
Due to its generic specification, other kind of optimization problems can be also solved, however, it could be easier and better to use other approaches.
Using SearchModels
The code idea is to describe a configuration space (solution space) for some model, that controls how the space is explored. The model is evaluated using an error function, and the resulting errors are used to navigate the solution space.
For this purpose SearchModels expect that some methods to work. As described below.
- All configuration spaces should be an specialization of the abstract type
AbstractSolutionSpace
. rand(space::AbstractSolutionSpace)
: Creates a random configuration sampling the given spacecombine(a, L::AbstractVector)
: Combines the a solution 'a' with the list of solutionsL
(an array of pairssolution => error
). By default it samplesL
for a compatible solution witha
and callscombine(c1, c2)
. A compatible solution is defined to share the sameconfig_type(a)
.combine(c1, c2)
: Combines two configurations into a single one; most applications should override this method.mutate(space::AbstractSolutionSpace, config, iter::Integer)
: Mutatesconfig
(a small perturbation, commonly following thespace
description). Theiter
value contains the iteration counter, it could be used to adjust the perturbation level.mutate(space::AbstractVector, c, iter)
: Dispatch of the applicable mutation function whenever space defines heterogeneous types.config_type(::T)
describes the type of T, it defaults toBase.typename(T)
but it could be any other value that makes sense for the application.eltype(::AbstractSolutionSpace)
: Defines what kind of objects are expected to be sampled from the solution space; it requires an specialization ofeltype
(i.e., to addimport Base: eltype
).
For complex enough configurations (solutions) you may need to define specialize hash
, and isequal
since the search process uses it to keep a track of the evalauted configurations.
Most of the work is made in search_models
function.