package knights_tour
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=770624ae4e35d5a58188a1f25e16730d186df8bc4397827fe9a798ea5ca574e3
sha512=b6c7b2473ddf321afaac6b668f9c6820fb8cc872abc494b69edfdff4101c6b660645837b04801e2917c38dd9f19f79bb0a7b029d59a58ddf1e3a235659bab099
doc/knights_tour.searchspace/Stochastic_estimator/index.html
Module Stochastic_estimator
Source
Interface for stochastic estimation functions
type decision = {
chosen : int;
(*A number between
*)0
inclusive andchoices
exclusive, indicating which choice was madechoices : int;
(*A number >=
*)2
indicating the number of available choices at a decision point.
}
a decision
represents a choice that has been made at a decision point
A rng
is a function that accepts a positive integer as an argument and returns a random integer between 0 (inclusive) and that integer (exclusive)
random_walk
searchspace walks a random path in the search space. Every time a decision point is reached, a random choice is made among the available options. The decisions are recorded and returned along with the final result.
Selector functions for choosing among children at a fork.
Uses a uniform random choice among available children.
Prefers to select children that have been sampled less often.
Prefers to select children that have a higher number of descendants.
type estimates = {
nodes : float;
(*The estimated number of nodes in the search space.
*)fails : float;
(*The estimated number of leaf nodes in the search space that represent failures.
*)solutions : float;
(*The estimated number of leaf nodes in the search space that represent solutions.
*)materialized_nodes : int;
(*The number of nodes that were actually materialized during the estimation process.
*)
}
estimate n searchspace
performs n
random walks in the given search space and uses the results to produce an estimate of the total number of nodes, fails and solutions in the search space. The estimate is returned as a record of type estimates
. The number of materialized nodes is also reported.
The optional selector
argument can be used to influence how choices are made at decision points. By default, the undersampled_selector
is used. Other strategies are available in this module.
type stats = {
nodes : int;
(*The exact number of nodes in the search space.
*)forks : int;
(*The exact number of fork nodes in the search space.
*)fails : int;
(*The exact number of leaf nodes in the search space that represent failures.
*)solutions : int;
(*The exact number of leaf nodes in the search space that represent solutions.
*)
}
calculate_true_values searchspace
fully explores the given search space and returns the exact counts of nodes, fails and solutions as an estimates
record.
This function is useful for validating the accuracy of estimates produced by the estimate
function. It should only be used on small search spaces where a full exploration is feasible.
An incremental estimator for a search space.
create ?selector searchspace
creates a new incremental estimator for the given search space, optionally using a custom selector.
sample n est
performs n
additional samples, updating the estimator's statistics.