OptimizerOptions
- class nexus.OptimizerOptions
OptimizerOptions
for the used algorithms in theOptimizer
andFit
classes.For more information on the different solvers and their algorithms see:
- method
Method used by the
Optimizer
orFit
module. All methods take boundary constraints except theLineSearch
method. Default isLevMar
.Gradient-based LOCAL fitting - Ceres solver.
LevMar
- Levenberg-Marquardt algorithm.Dogleg
- Dogleg algorithm.SubDogleg
- Subspace Dogleg algorithm.LineSearch
- Linear search algorithm. No boundary constraints.
Gradient-free LOCAL fitting - NLopt or Pagmo solver.
Subplex
- Nelder-Mead algorithm on a sequence of subspaces (NLopt).Newuoa
- New Unconstrained Optimization with quadratic Approximation algorithm (NLopt).CompassSearch
- Compass Search algorithm (Pagmo).
Gradient-free GLOBAL fitting - Pagmo solver.
PagmoDiffEvol
- Self-adaptive Differential Evolution 1220 algorithm.AdaptiveDiffEvol
- Self-adaptive Differential Evolution algorithm.DiffEvol
- Differential Evolution algorithm.BeeColony
- Artificial Bee Colony algorithm.CMA-ES
- Covariance Matrix Adaptation Evolutionary Strategy algorithm.AntColony
- Extended Ant Colony Optimization algorithm.GreyWolf
- Grey Wolf Optimizer algorithm.ParticleSwarm
- Particle Swarm Optimization algorithm.ParticleSwarmGen
- Particle Swarm Optimization Generational algorithm.SimpleEvol
- (N+1)-ES Simple Evolutionary Algorithm.Genetic
- Simple Genetic Algorithm.Annealing
- Simulated Annealing algorithm.NaturalEvol
- Exponential Natural Evolution Strategies algorithm.BasinHopping
- Monotonic Basin Hopping with local algorithm.
- Type:
string
- local
A subsequent local solver following the method. If it is the same as method no second fit is performed. Default is
LevMar
.- Type:
string
- population
Initial population for global fit methods. When value is zero the population is set by the fit method. Default is 0.
- Type:
int
- iterations
Maximum of iterations of a solver. If set to zero the solver method will set a reasonable value. Default is 0.
- Type:
int
- max_time
Maximum run time of the ceres solver or the Nlopt solver (seconds). Default is 300.
- Type:
float
- output
Set output during fitting. Default is
True
.- Type:
bool
- report
Output of the ceres solver.
None
,Brief
orFull
. DefaultBrief
.- Type:
string
- function_tolerance
Tolerance of change of the cost value for termination of the solver \(|(\Delta cost) / cost|\). Only for methods that support this option. Default is 1.0e-10.
- Type:
float
- gradient_tolerance
Tolerance of change of the gradient for termination of the solver. Only for methods that support this option. Default is 1.0e-10.
- Type:
float
- parameter_tolerance
Tolerance of change of the parameter for termination of the solver. Only for methods that support this option. Default is 1.0e-4.
- Type:
float
- cost_relative_step_size
Relative step size for the numerical derivatives in the ceres solver. Default is 1e-6.
Changed in version 1.1.0: - Default changed from 0.01 to 1e-6.
- Type:
float
- file_output
Determines if an output file with the fit results is generated. The file is named after the id and each time a fit is run the filename is automatically increased in numbers.
New in version 1.1.0.
- Type:
bool
- error_method
Set the method of error calculations of the fit parameters.
Gradient
: Based on the gradient-based local algorithms from the ceres solver. The ceres solver will be called as last fit instance to determine the error estimates. Default.Bootstrap
: Bootstrap method for error analysis. A resampling strategy to determine errors of unknown distributions. This method is computationally expensive and might take quite long. SeeBootstrapOptions
for options on this method.None
: No error analysis.
New in version 1.1.0.
- Type:
string
- LineSearch
Options for the LineSearch method of the ceres solver.
- Type:
- DiffEvol
Options for all Differential Evolution algorithms.
- Type:
- CompassSearch
Options for the Compass Search algorithm.
- Type:
- BasinHopping
Options for the Basin Hopping algorithm.
- Type:
- Bootstrap
Options for the Bootstrap error analysis.
New in version 1.1.0.
- Type:
- class nexus.LineSearchOptions
LineSearchOptions
for the Line Search method. TheLineSearch
method does not support boundaries on the fit parameters.- line_search_type
Linear search type for the “LineSearch” method. Default is
LBFGS
.LBFGS
: Limited-memory Broyden Fletcher Goldfarb Shanno method.BFGS
: Broyden Fletcher Goldfarb Shanno method.SteepDes
: Steepest descent method.NonConGrag
: Non-linear conjugate gradient method.
- Type:
string
- max_num_line_search_step_size_iterations
Default is 20.
- Type:
int
- class nexus.CompassSearchOptions
CompassSearchOptions
for the Compass Search algorithm.If
options.iterations = 0
, the number of iterations is set to 500.
- start_range
In range (0,1]. Default is 0.1.
- Type:
double
- stop_range
In range (0,start_range]. Default is 0.05.
- Type:
double
- reduction_coeff
In range (0,1). Default is 0.5.
- Type:
double
- class nexus.DiffEvolOptions
DiffEvolOptions
for the Differential Evolution algorithms.The Adaptive Differential Evolution takes the
variant
and theadaptive_variant
into account. For the Pagmo Differential Evolution only theadaptive_variant
is used. For the classical Differential Evolution take the following into consideration:“The mutation factor F is a positive control parameter for scaling and controlling the amplification of the difference vector. Small values of F will lead to smaller mutation step sizes and as a result it will take longer for the algorithm to converge. Large values of F facilitate exploration, but can lead to the algorithm overshooting good optima. Thus, the value has to be small enough to enhance local exploration but also large enough to maintain diversity. The crossover probability CR has an influence on the diversity of DE, as it controls the number of elements that will change. Larger values of CR will lead to introducing more variation in the new population, therefore increasing it increases exploration.” from Manolis S. Georgioudakis and Vagelis Plevris, A Comparative Study of Differential Evolution Variants in Constrained Structural Optimization.
If
options.population = 0
, the population is set to \(10 (n+1)\), where \(n\) is the number of fit parameters. Default is0
. When you increase the population you should also decrease the weight F but typically not lower than 0.5.If
options.iterations = 0
, the number of iterations is set to 100.
- F
Differential weight F in the range [0,1]. Default is 0.8.
- Type:
double
- CR
Crossover probability CR in the range [0,1]. Default is 0.9.
- Type:
double
- variant
Variants of the mutation scheme, value is 1, 2, …, 10. Default is 2. Labeling: vector decision / number difference vectors / crossover strategy (binominal or exponential)
1 - best/1/exp
2 - rand/1/exp
3 - rand-to-best/1/exp
4 - best/2/exp
5 - rand/2/exp
6 - best/1/bin
7 - rand/1/bin
8 - rand-to-best/1/bin
9 - best/2/bin
10 - rand/2/bin
- Type:
int
- adaptive_variant
Self-adaptation variants, value is 1 or 2. Default is 1.
1 - jDE (Brest et al.)
2 - iDE (Elsayed at al.)
- Type:
int
- class nexus.BasinHoppingOptions
BasinHoppingOptions
for the Basin Hopping algorithm. This is a meta algorithm that uses another inner algorithm.CompassSearch
orSubplex
method can be used as inner algorithm.- inner
Inner algorithm. Either
Subplex
orCompass
. Default isCompass
.- Type:
string
- stop
Runs of the inner algorithm without improvement. Default is 5.
- Type:
int
- perturbation
Perturbation to be applied to each component of the decision vector of the best population. Default is 0.01.
- Type:
double
- class nexus.BootstrapOptions
BootstrapOptions
for the Bootstrap error analysis.New in version 1.1.0.
- method
Bootstrap method. Default is “Wild”.
Poisson
: Parametric bootstrap with Poisson statistics. The data points are resampled at each point from a Poisson distribution with an expectation value of the measured intensity.Gaussian
: Parametric bootstrap with Gaussian statistics. The data points are resampled at each point from a Gaussian distribution with a mean value of the measured intensity and a with of the square root of the intensity.Wild
: The residuals of the initial fit are reweighted by a Gaussian distribution with a variance of one to generate a new data set. This method should be applied for heteroscedastic data sets (varying variance of all data points, like Time spectra). Can also be used for homoscedastic data sets.Residuals
: The residuals of the initial fit are randomly redistributed over the fit curve to generate a new data set. This method should only be applied for homoscedastic data sets (same variance of all data, like typical Moessbauer spectra).Smoothed
: For each data point random noise is added from a Gaussian distribution kernel with variance of one scaled byh
. The smoothing parameter is the scaling factor of the data point, soh = smooting_parameter * data_point
.Smoothed_Uniform
: For each data point random noise is added from a uniform distribution kernel [-h, h]. The smoothing parameter is the scaling factor of the data point, soh = smooting_parameter * data_point
- Type:
string
- num_bootstrap
Number of evaluations for bootstrap error method. Default is 50.
- Type:
int
- smoothing_parameter
The smoothing parameter is the scaling factor of the data point. So, the distribution is scaled by
h = smooting_parameter * data_point
. The value determines how much noise is added to the data. Default is 0.01.- Type:
float