Package parsimony :: Package algorithms :: Module utils :: Class Bisection
[hide private]
[frames] | no frames]

Class Bisection

source code

            object --+        
                     |        
   bases.BaseAlgorithm --+    
                         |    
   bases.ExplicitAlgorithm --+
                             |
                object --+   |
                         |   |
  bases.IterativeAlgorithm --+
                             |
                object --+   |
                         |   |
bases.InformationAlgorithm --+
                             |
                            Bisection

Finds a root of the function assumed to be on the line between two
points.

Assumes a function f(x) such that |f(x)|_2 < -eps if x is too small,
|f(x)|_2 > eps if x is too large and |f(x)|_2 <= eps if x is just right.

Parameters
----------
force_negative : Boolean. Default is False. Will try, by running more
        iterations, to make the result negative. It may fail, but that is
        unlikely.

eps : Positive float. A value such that |f(x)|_2 <= eps. Only guaranteed
        if |f(x)|_2 <= eps in less than max_iter iterations.

info : List or tuple of utils.Info. What, if any, extra run
        information should be stored. Default is an empty list, which means
        that no run information is computed nor returned.

max_iter : Non-negative integer. Maximum allowed number of iterations.

min_iter : Non-negative integer less than or equal to max_iter. Minimum
        number of iterations that must be performed. Default is 1.

Instance Methods [hide private]
 
__init__(self, force_negative=False, parameter_positive=True, parameter_negative=True, parameter_zero=True, eps=5e-08, info=[], max_iter=30, min_iter=1)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
run(self, function, *args, **kwargs)
Parameters ---------- function : Function.
source code

Inherited from bases.BaseAlgorithm: get_params, set_params

Inherited from bases.IterativeAlgorithm: iter_reset

Inherited from bases.InformationAlgorithm: check_info_compatibility, info_copy, info_get, info_provided, info_requested, info_reset, info_set

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Static Methods [hide private]

Inherited from bases.BaseAlgorithm: check_compatibility

Class Variables [hide private]
  INTERFACES = [properties.Function]
  INFO_PROVIDED = ['ok', 'num_iter', 'converged']
  __abstractmethods__ = frozenset([])

Inherited from bases.ExplicitAlgorithm: __metaclass__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, force_negative=False, parameter_positive=True, parameter_negative=True, parameter_zero=True, eps=5e-08, info=[], max_iter=30, min_iter=1)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

run(self, function, *args, **kwargs)

source code 

Parameters
----------
function : Function. The function for which a root is found.

x : A vector or tuple with two elements. The first element is the lower
        end of the interval for which |f(x[0])|_2 < -eps. The second
        element is the upper end of the interfal for which
        |f(x[1])|_2 > eps. If x is None, these values are found
        automatically. Finding them may be slow, though, if the
        function is expensive to evaluate.

Decorators:
  • @bases.force_reset
  • @bases.check_compatibility
Overrides: bases.ExplicitAlgorithm.run