Changeset 227


Ignore:
Timestamp:
05/13/10 16:09:30 (6 years ago)
Author:
mmckerns
Message:

allow "SetMapper?" to set the map function and the map strategy

File:
1 edited

Legend:

Unmodified
Added
Removed
  • mystic/mystic/abstract_map_solver.py

    r226 r227  
    3737    >>> from pyina.launchers import mpirun_launcher 
    3838    >>> from pyina.mappers import equalportion_mapper 
     39    >>> from pyina.ez_map import ez_map 
    3940    >>> NNODES = 4 
    4041    >>> 
     
    4344    >>> solver = NelderMeadSimplexMapSolver(len(x0)) 
    4445    >>> solver.SetInitialPoints(x0)            #FIXME: use batchgrid w/ bounds 
    45     >>> solver.SetMapStrategy(equalportion_mapper) 
     46    >>> solver.SetMapper(ez_map, equalportion_mapper) 
    4647    >>> solver.SetLauncher(mpirun_launcher, NNODES) 
    4748    >>> solver.Solve(rosen, CRT(), StepMonitor=stepmon) 
     
    150151#       return 
    151152 
    152     def SetMapper(self, strategy): #XXX: should use strategy+format ? 
    153         """Set the mapping strategy. 
    154  
    155 Description: 
    156  
     153    def SetMapper(self, map, strategy=None): #XXX: use strategy+format ? 
     154        """Set the map function and the mapping strategy. 
     155 
     156Description: 
     157 
     158    Sets a mapping function to perform the map-reduce algorithm. 
    157159    Uses a mapping strategy to provide the algorithm for distributing 
    158160    the work list of optimization jobs across available resources. 
    159161 
    160162Inputs: 
    161     mapper -- mapper function (see pyina.mappers)  [DEFAULT: carddealer_mapper] 
    162         """ 
    163         #XXX: allow python's 'map' to be passed 
    164         self._mapper = strategy 
     163    map -- the mapping function [DEFAULT: python_map] 
     164    strategy -- map strategy (see pyina.mappers) [DEFAULT: carddealer_mapper] 
     165        """ 
     166        self._map = map 
     167        if strategy: 
     168          self._mapper = strategy 
    165169        #FIXME: not a true mapping function... just a dummy interface to a str 
    166170        # a real mapper has map(func,*args) interface... this expects map(). 
Note: See TracChangeset for help on using the changeset viewer.