niapy.util
¶
niapy.util.argparser
¶
Argparser class.
- niapy.util.argparser._optimization_type(x)[source]¶
Get OptimizationType from string.
- Parameters
x (str) – String representing optimization type.
- Returns
Optimization type based on type that is defined as enum.
- Return type
- niapy.util.argparser.get_argparser()[source]¶
Create/Make parser for parsing string.
- Parser:
- -a or –algorithm (str):
Name of algorithm to use. Default value is jDE.
- -p or –problem (str):
Name of problem to use. Default values is Ackley.
- -d or –dimension (int):
Number of dimensions/components used by problem. Default values is 10.
- –max-evals (int):
Number of maximum function evaluations. Default values is inf.
- –max-iters (int):
Number of maximum algorithm iterations/generations. Default values is inf.
- -n or –population-size (int):
Number of individuals in population. Default values is 43.
- -r or –run-type (str);
- Run type of run. Value can be:
‘’: No output during the run. Output is shown only at the end of algorithm run.
log: Output is shown every time new global best solution is found
plot: Output is shown only at the end of run. Output is shown as graph plotted in matplotlib. Graph represents convergence of algorithm over run time of algorithm.
Default value is ‘’.
- –seed (list of int or int):
Set the starting seed of algorithm run. If multiple runs, user can provide list of ints, where each int usd use at new run. Default values is None.
- –opt-type (str):
- Optimization type of the run. Values can be:
min: For minimization problems
max: For maximization problems
Default value is min.
- Returns
Parser for parsing arguments from string.
- Return type
ArgumentParser
See also
ArgumentParser
ArgumentParser.add_argument()
niapy.util.array
¶
niapy.util.distances
¶
niapy.util.factory
¶
Factory functions for getting algorithms and problems by name.
niapy.util.random
¶
niapy.util.repair
¶
- niapy.util.repair.limit(x, lower, upper, **_kwargs)[source]¶
Repair solution and put the solution in the random position inside of the bounds of problem.
- Parameters
x (numpy.ndarray) – Solution to check and repair if needed.
lower (numpy.ndarray) – Lower bounds of search space.
upper (numpy.ndarray) – Upper bounds of search space.
- Returns
Solution in search space.
- Return type
numpy.ndarray
- niapy.util.repair.limit_inverse(x, lower, upper, **_kwargs)[source]¶
Repair solution and put the solution in the random position inside of the bounds of problem.
- Parameters
x (numpy.ndarray) – Solution to check and repair if needed.
lower (numpy.ndarray) – Lower bounds of search space.
upper (numpy.ndarray) – Upper bounds of search space.
- Returns
Solution in search space.
- Return type
numpy.ndarray
- niapy.util.repair.rand(x, lower, upper, rng=None, **_kwargs)[source]¶
Repair solution and put the solution in the random position inside of the bounds of problem.
- Parameters
x (numpy.ndarray) – Solution to check and repair if needed.
lower (numpy.ndarray) – Lower bounds of search space.
upper (numpy.ndarray) – Upper bounds of search space.
rng (numpy.random.Generator) – Random generator.
- Returns
Fixed solution.
- Return type
numpy.ndarray
- niapy.util.repair.reflect(x, lower, upper, **_kwargs)[source]¶
Repair solution and put the solution in search space with reflection of how much the solution violates a bound.
- Parameters
x (numpy.ndarray) – Solution to be fixed.
lower (numpy.ndarray) – Lower bounds of search space.
upper (numpy.ndarray) – Upper bounds of search space.
- Returns
Fix solution.
- Return type
numpy.ndarray
- niapy.util.repair.wang(x, lower, upper, **_kwargs)[source]¶
Repair solution and put the solution in the random position inside of the bounds of problem.
- Parameters
x (numpy.ndarray) – Solution to check and repair if needed.
lower (numpy.ndarray) – Lower bounds of search space.
upper (numpy.ndarray) – Upper bounds of search space.
- Returns
Solution in search space.
- Return type
numpy.ndarray