Package mystic :: Module abstract_map_solver

Module abstract_map_solver

source code

This module contains the base class for mystic solvers that utilize a parallel "map" function to enable parallel computing. This module describes the map solver interface. As with the AbstractSolver, the "Solve" method must be overwritte with the derived solver's optimization algorithm. Additionally, for the AbstractMapSolver, a call to is required. In many cases, a minimal function call interface for a derived solver is provided along with the derived class. See the following for an example.

The default map API settings are provided within mystic, while distributed and high-performance computing mappers and launchers can be obtained within the "pathos" package, found here:



A typical call to a 'map' solver will roughly follow this example:

>>> # the function to be minimized and the initial values
>>> from mystic.models import rosen
>>> lb = [0.0, 0.0, 0.0]
>>> ub = [2.0, 2.0, 2.0]
>>> # get monitors and termination condition objects
>>> from import Sow
>>> stepmon = Sow()
>>> from mystic.termination import CandidateRelativeTolerance as CRT
>>> # select the parallel launch configuration
>>> from pyina.launchers import mpirun_launcher
>>> from pyina.mappers import equalportion_mapper
>>> from pyina.ez_map import ez_map2
>>> NNODES = 4
>>>> npts = 20
>>> # instantiate and configure the solver
>>> from mystic.nested import ScattershotSolver
>>> solver = ScattershotSolver(len(lb), npts)
>>> solver.SetMapper(ez_map2, equalportion_mapper)
>>> solver.SetLauncher(mpirun_launcher, NNODES)
>>> solver.Solve(rosen, CRT(), StepMonitor=stepmon)
>>> # obtain the solution
>>> solution = solver.Solution()


All solvers packaged with mystic include a signal handler that provides the following options:

   sol: Print current best solution.
   cont: Continue calculation.
   call: Executes sigint_callback, if provided.
   exit: Exits with current best solution.

Handlers are enabled with the 'enable_signal_handler' method, and are configured through the solver's 'Solve' method. Handlers trigger when a signal interrupt (usually, Ctrl-C) is given while the solver is running. ***NOTE: The handler currently is disabled when the solver has been launched in parallel.***

AbstractMapSolver base class for mystic optimizers that utilize parallel map.