Suggests values for the parameters of [QGA()] that control convergence (`thetainit`, `thetaend`, `restart_iters`, `restart_strength`, `attractor_type`, ...) given the number of generations, the size of the genome and the kind of problem. The suggestions follow the guidelines of the vignette "Avoiding local optima":
- a qubit always rotated in the same direction saturates after about (pi/4)/theta generations (the *saturation time*); the angles are chosen so that the saturation time is about `generation_max / 40` when restarts are used, and `generation_max / 10` otherwise, never faster than the default angles (about 6.7 generations); - `restart_iters` is a multiple of the saturation time (1.5 times for deceptive problems, 3 times when the problem is unknown, 6 times for problems with many local optima), not a fraction of `generation_max`; - `restart_strength = 0.5`; `restart_theta` and `epsilon` are left off.
These are starting points, derived from benchmarks on two test problems: always compare a few configurations on several seeds.
parameters_hint(
generation_max,
Genome,
nvalues_sol,
popsize = 20,
problem_type = c("unknown", "deceptive", "multimodal", "unimodal"),
stop_iters = FALSE,
eval_seconds = NULL,
verbose = TRUE
)Integer. Number of generations of the run.
Integer. Number of genes (decision variables).
Integer. Number of values of each gene.
Integer. Population size. Default 20.
Character. Kind of problem: `"unknown"` (default), `"deceptive"` (good partial solutions lead away from the optimum), `"multimodal"` (many local optima scattered in the search space), `"unimodal"` (a single optimum, no traps).
Logical. If TRUE, a value for `stop_iters` compatible with the restarts is suggested too. Default FALSE.
Numeric or NULL. Average time (seconds) of one fitness evaluation, used to estimate the duration of the run. Default NULL.
Logical. If TRUE (default), the suggestions are printed with their motivation.
Invisibly, a named list of parameter values that can be passed to [QGA()], e.g. `do.call(QGA, c(list(...), hint))`.
[QGA()], `vignette("local_optima", package = "QGA")`
hint <- parameters_hint(generation_max = 300, Genome = 48, nvalues_sol = 2,
problem_type = "deceptive")
#>
#> QGA parameters hint
#> -------------------
#> problem_type: deceptive; genome of 48 genes x 1 bits = 48 qubits; 300 generations
#> saturation time (pi/4)/theta: about 7.5 generations
#>
#> thetainit = 0.1396 (= 0.0444 * pi)
#> thetaend = 0.0698 (= 0.0222 * pi)
#> restart_iters = 11 (1.5 x saturation time)
#> restart_strength = 0.5
#> restart_theta = FALSE (experimental)
#> epsilon = 0
#> attractor_type = "generation"
#>
#> fitness evaluations: up to 6020
#> These are starting points: compare a few configurations on several seeds.
# out <- do.call(QGA, c(list(popsize = 20, generation_max = 300,
# nvalues_sol = 2, Genome = 48,
# eval_fitness = f, eval_func_inputs = NULL),
# hint))