|
ADS
Algorithms and Data Structures
|
The general schemes of the techniques of design of algorithms, beyond the book, as functions of the parts that make a technique concrete. More...
#include "ADS/Contract.h"#include <optional>#include <utility>#include <vector>#include "ADS/algorithm/impl/Paradigms.tpp"Go to the source code of this file.
Namespaces | |
| namespace | ADS |
Functions | |
| template<class Z, class Next, class Last, class A, class O> | |
| auto | ADS::enumerateSearch (Z z, Next &&next, Last &&last, A &&a, O &&o) -> std::optional< decltype(o(z)) > |
| the enumerative search from the first object \( z \): the answer \( o( z ) \) of the first \( z \) with \( a( z ) \), next( z ) after \( z \) until last( z ) holds; nothing if none | |
| template<class Z, class Next, class Last, class A, class O, class M, class B> | |
| auto | ADS::enumerateOptimize (Z z, Next &&next, Last &&last, A &&a, O &&o, M &&m, B &&better) -> std::optional< decltype(o(z)) > |
| the enumerative optimization: the answer of an admissible object of \( Z \) with no admissible one better, i.e., with no \( y \) such that better( m( y ) , m( x ) ), or nothing | |
| template<class N, class C, class P, class L, class V> | |
| bool | ADS::backtrack (const N &node, C &&children, P &&prune, L &&leaf, V &&visit) |
| the backtracking from the node \( N \): prune( N ) rejects \( N \) and its subtree, a leaf goes to visit( N ), which returns true to stop, children( N ) gives the children of a node that is not a leaf; true if stopped | |
| template<class X, class Cand, class Best> | |
| std::vector< X > | ADS::greedy (int k, Cand &&candidates, Best &&best) |
| the greedy scheme: for each of \( k \) stages, the best of the values candidates( i , x ) admissible after the partial solution \( x \) is appended to \( x \), the stage skipped if there is none | |
| template<class X, class S, class D, class V, class C> | |
| auto | ADS::divideEtImpera (const X &x, S &&small, D &&direct, V &÷, C &&combine) -> decltype(direct(x)) |
| divide et impera: direct( x ) if small( x ), else the combination of the solutions of the instances that divide( x ) gives | |
| template<class T, class B> | |
| std::vector< T > | ADS::maximal (const std::vector< T > &X, B &&better) |
| the elements of \( X \) that are maximal for the partial order better( a , b ), i.e., \( a \) strictly better than \( b \) | |
The general schemes of the techniques of design of algorithms, beyond the book, as functions of the parts that make a technique concrete.
A problem is a quintuple \( \langle I , S , R , O , Q \rangle \): the instances \( I \), the solutions \( S \), the relation \( R \) between them, the answers \( O \) and the function \( Q \) that gives the answer of an instance. In a problem of search the answer is a solution \( s \) with \( \langle i , s \rangle \in R \), or none (written \( \bot \)); in one of decision it is whether such an \( s \) exists, and it may be found with the search (the constructive method) or not; in one of optimization it is a solution that is best for a measure \( m \) with values in an ordered set, or none. A search space \( Z \) of an instance is a set of objects with a function of admissibility \( a \) and one of answer \( o \), such that \( a( z ) \) holds if and only if \( o( z ) \) is a solution; for a problem of optimization \( Z \) must also contain an optimal solution.
The functions are defined in Paradigms.tpp.