Пример #1
0
    def __init__(self,
                 npts=4,
                 retry=1,
                 tol=8,
                 memtol=1,
                 map=None,
                 archive=None,
                 sprayer=None,
                 seeker=None,
                 traj=False,
                 disp=False):

        #XXX: better not to use klepto as default? just dict and false cache?
        from klepto.archives import dict_archive as _archive
        from mystic.solvers import BuckshotSolver
        from mystic.solvers import PowellDirectionalSolver
        from mystic.pools import SerialPool as Pool
        from __builtin__ import map as _map
        self.archive = _archive(cached=False) if archive is None else archive
        self.sprayer = BuckshotSolver if sprayer is None else sprayer
        self.seeker = PowellDirectionalSolver if seeker is None else seeker
        self.map = Pool().map if map in (None, _map) else map
        self.traj = traj
        self.disp = disp

        self.npts = npts  # number of solvers
        self.retry = retry  # max consectutive retries w/o a cache 'miss'
        self.tol = tol  # rounding precision
        self.memtol = memtol  # memoization rounding precision
        self._allSolvers = []
        self._inv = False  # self-awareness: am I inverted (maximizing)?
        return
Пример #2
0
    def __init__(self,
                 npts=4,
                 retry=1,
                 tol=8,
                 memtol=1,
                 memsize=None,
                 map=None,
                 archive=None,
                 cache=None,
                 sprayer=None,
                 seeker=None,
                 traj=False,
                 disp=False,
                 repeat=0):
        """searcher, which searches for all minima of a response surface

        Input:
          npts - number of solvers in the ensemble
          retry - max consectutive retries w/o a cache 'miss'
          tol - rounding precision for the minima comparator
          memtol - rounding precision for memoization
          memsize - maximum size of cache to hold in memory
          map - map used for spawning solvers in the ensemble
          archive - the sampled point archive(s)
          cache - the trajectory cache(s)
          sprayer - the mystic.ensemble instance
          seeker - the mystic.solvers instance
          traj - if True, save the parameter trajectories
          disp - if True, be verbose
          repeat - number of times to repeat the search
        """
        #XXX: better not to use klepto as default? just dict and false cache?
        from klepto.archives import dict_archive as _archive
        from mystic.solvers import BuckshotSolver  #XXX: or SparsitySolver?
        from mystic.solvers import PowellDirectionalSolver
        from mystic.pools import SerialPool as Pool
        import sys
        if (sys.hexversion >= 0x30000f0):
            from builtins import map as _map
        else:
            from __builtin__ import map as _map
        del sys
        self.archive = _archive(cached=False) if archive is None else archive
        self.cache = _archive(cached=False) if cache is None else cache
        self.sprayer = BuckshotSolver if sprayer is None else sprayer
        self.seeker = PowellDirectionalSolver if seeker is None else seeker
        self.map = Pool().map if map in (None, _map) else map
        self.traj = traj
        self.disp = disp

        self.npts = npts  # number of solvers
        self.retry = retry  # max consectutive retries w/o a cache 'miss'
        self.repeat = repeat  # number of times to repeat the search
        self.tol = tol  # rounding precision
        self.memtol = memtol  # memoization rounding precision
        self.memsize = memsize  # max in-memory cache size
        self._allSolvers = []
        self._inv = False  # self-awareness: am I inverted (maximizing)?
        return
Пример #3
0
    solvers = [fmin_powell, fmin, diffev, diffev2]
    # test solver one-liners
    for solver in solvers:
        test_one_liner(solver)

    classes = [NelderMeadSimplexSolver, PowellDirectionalSolver, \
               DifferentialEvolutionSolver, DifferentialEvolutionSolver2]
    # nested solver one-liners (using inner solver class, not nested one-liner)
    for solver in classes:
        nested = BuckshotSolver
        test_nested_solver(nested, solver)

    # solver multi-line
    for solver in classes:
        test_multi_liner(solver)

    # nested solver multi-line
    for solver in classes:
        nested = BuckshotSolver
        test_inner_solver(nested, solver)

    # solver with mapper
#from pathos.pools import ProcessPool as Pool
    from mystic.pools import SerialPool as Pool
    map = Pool(5).map
    for solver in classes:
        nested = BuckshotSolver
        test_mapped_solver(nested, solver, map)

# EOF