optunity.solvers.NelderMead module¶
-
class
optunity.solvers.NelderMead.
NelderMead
(ftol=0.0001, max_iter=None, **kwargs)[source]¶ Bases:
optunity.solvers.util.Solver
Please refer to Nelder-Mead simplex for details about this algorithm.
>>> s = NelderMead(x=1, y=1, xtol=1e-8) >>> best_pars, _ = s.optimize(lambda x, y: -x**2 - y**2) >>> [math.fabs(best_pars['x']) < 1e-8, math.fabs(best_pars['y']) < 1e-8] [True, True]
Initializes the solver with a tuple indicating parameter values.
>>> s = NelderMead(x=1, ftol=2) >>> s.start {'x': 1} >>> s.ftol 2
Warning
This solver is not explicitly constrained. The box constraints that are given are used for initialization, but solver may leave the specified region during iterations. If this is unacceptable, you must manually constrain the domain of the objective function prior to using this solver (cfr. Domain constraints).
-
desc_brief
= 'simplex method for unconstrained optimization'¶
-
desc_full
= ['Simplex method for unconstrained optimization', ' ', 'The simplex algorithm is a simple way to optimize a fairly well-behaved function.', 'The function is assumed to be convex. If not, this solver may yield poor solutions.', ' ', 'This solver requires the following arguments:', '- start :: starting point for the solver (through kwargs)', '- ftol :: accuracy up to which to optimize the function (default 1e-4)']¶
-
ftol
¶ Returns the tolerance.
-
max_iter
¶ Returns the maximum number of iterations.
-
maximize
(f, pmap=<built-in function map>)¶ Maximizes f.
Parameters: - f (callable) – the objective function
- pmap (callable) – the map() function to use
Returns: - the arguments which optimize
f
- an optional solver report, can be None
-
minimize
(f, pmap=<built-in function map>)¶ Minimizes
f
.Parameters: - f (callable) – the objective function
- pmap (callable) – the map() function to use
Returns: - the arguments which optimize
f
- an optional solver report, can be None
-
name
= 'nelder-mead'¶
-
optimize
(f, maximize=True, pmap=<built-in function map>)[source]¶ Optimizes
f
.Parameters: - f (callable) – the objective function
- maximize (boolean) – do we want to maximizes?
- pmap (callable) – the map() function to use
Returns: - the arguments which optimize
f
- an optional solver report, can be None
-
start
¶ Returns the starting point.
-