Changeset 793


Ignore:
Timestamp:
06/11/15 08:27:52 (11 months ago)
Author:
mmckerns
Message:

add scale to wrap_function, enable wrap_function in diffev2 and ensemble

Location:
mystic/mystic
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • mystic/mystic/differential_evolution.py

    r792 r793  
    378378        from python_map import python_map 
    379379        if self._map != python_map: 
    380             pass #FIXME: EvaluationMonitor fails for MPI, throws error for 'pp' 
    381         else: fcalls, cost = wrap_function(cost, ExtraArgs, self._evalmon) 
     380            #FIXME: EvaluationMonitor fails for MPI, throws error for 'pp' 
     381            from mystic.monitors import Null 
     382            evalmon = Null() 
     383        else: evalmon = self._evalmon 
     384        fcalls, cost = wrap_function(cost, ExtraArgs, evalmon) 
    382385        if self._useStrictRange: 
    383386            for i in range(self.nPop): 
  • mystic/mystic/ensemble.py

    r792 r793  
    9595        from python_map import python_map 
    9696        if self._map != python_map: 
    97             pass #FIXME: EvaluationMonitor fails for MPI, throws error for 'pp' 
    98         else: fcalls, cost = wrap_function(cost, ExtraArgs, self._evalmon) 
     97            #FIXME: EvaluationMonitor fails for MPI, throws error for 'pp' 
     98            from mystic.monitors import Null 
     99            evalmon = Null() 
     100        else: evalmon = self._evalmon 
     101        fcalls, cost = wrap_function(cost, ExtraArgs, evalmon) 
    99102 
    100103        # set up signal handler 
     
    289292        from python_map import python_map 
    290293        if self._map != python_map: 
    291             pass #FIXME: EvaluationMonitor fails for MPI, throws error for 'pp' 
    292         else: fcalls, cost = wrap_function(cost, ExtraArgs, self._evalmon) 
     294            #FIXME: EvaluationMonitor fails for MPI, throws error for 'pp' 
     295            from mystic.monitors import Null 
     296            evalmon = Null() 
     297        else: evalmon = self._evalmon 
     298        fcalls, cost = wrap_function(cost, ExtraArgs, evalmon) 
    293299 
    294300        # set up signal handler 
  • mystic/mystic/tools.py

    r791 r793  
    329329 
    330330# slight break to backward compatability: renamed 'args' to 'extra_args' 
    331 def wrap_function(the_function, extra_args, EvaluationMonitor): 
     331def wrap_function(the_function, extra_args, EvaluationMonitor, scale=1): 
    332332    """bind an EvaluationMonitor and evaluation counter to a function object""" 
     333    # scale=-1 intended to seek min(-f) == -max(f) 
    333334    ncalls = [0] 
    334335    from numpy import array 
     
    337338        fval = the_function(x, *extra_args) 
    338339        EvaluationMonitor(x, fval) 
    339         return fval 
     340        return scale*fval 
    340341    return ncalls, function_wrapper 
    341342 
Note: See TracChangeset for help on using the changeset viewer.