Changeset 698


Ignore:
Timestamp:
07/08/13 15:15:46 (3 years ago)
Author:
mmckerns
Message:

fix: Solve does not recompute when Step has been already called

Location:
mystic/mystic
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • mystic/mystic/abstract_solver.py

    r679 r698  
    604604        return settings 
    605605 
    606     def Solve(self, cost, termination=None, sigint_callback=None, 
    607                                             ExtraArgs=(), **kwds): 
     606    def Solve(self, cost=None, termination=None, sigint_callback=None, 
     607                                                 ExtraArgs=None, **kwds): 
    608608        """Minimize a 'cost' function with given termination conditions. 
    609609 
     
    629629        the current parameter vector.  [default = None] 
    630630    disp -- non-zero to print convergence messages. 
    631         """ #FIXME: edit so "Solve" can be called anytime to "finish" the solve 
    632         #FIXME: needs to respect when evals/iters have been done already 
     631        """ 
     632        # HACK to enable not explicitly calling _RegisterObjective 
     633        cost = self._bootstrap_decorate(cost, ExtraArgs) 
    633634        # process and activate input settings 
    634635        settings = self._process_inputs(kwds) 
     
    642643        if self._handle_sigint: signal.signal(signal.SIGINT, self.signal_handler) 
    643644 
    644         # decorate cost function with bounds, penalties, monitors, etc 
    645         self._RegisterObjective(cost, ExtraArgs)    #XXX: SetObjective ? 
     645       ## decorate cost function with bounds, penalties, monitors, etc 
     646       #self._RegisterObjective(cost, ExtraArgs)    #XXX: SetObjective ? 
    646647        # register termination function 
    647648        if termination is not None: 
     
    649650 
    650651        # the initital optimization iteration 
    651         self.Step() 
    652         if callback is not None: 
    653             callback(self.bestSolution) 
     652        if not len(self._stepmon): # do generation = 0 
     653            self.Step() 
     654            if callback is not None: 
     655                callback(self.bestSolution) 
    654656          
    655         # initialize termination conditions, if needed 
    656         self._termination(self) 
     657            # initialize termination conditions, if needed 
     658            self._termination(self) #XXX: call at generation 0 or always? 
    657659        # impose the evaluation limits 
    658660        self._SetEvaluationLimits() 
  • mystic/mystic/differential_evolution.py

    r683 r698  
    264264        return settings 
    265265 
    266     def Solve(self, cost, termination=None, sigint_callback=None, 
    267                                             ExtraArgs=(), **kwds): 
     266    def Solve(self, cost=None, termination=None, sigint_callback=None, 
     267                                                 ExtraArgs=None, **kwds): 
    268268        """Minimize a function using differential evolution. 
    269269 
     
    411411        return settings 
    412412 
    413     def Solve(self, cost, termination=None, sigint_callback=None, 
    414                                             ExtraArgs=(), **kwds): 
     413    def Solve(self, cost=None, termination=None, sigint_callback=None, 
     414                                                 ExtraArgs=None, **kwds): 
    415415        """Minimize a function using differential evolution. 
    416416 
  • mystic/mystic/nested.py

    r680 r698  
    5353#       return 
    5454 
     55    #FIXME: should take cost=None, ExtraArgs=None... and utilize Step 
    5556    def Solve(self, cost, termination=None, sigint_callback=None, 
    5657                                            ExtraArgs=(), **kwds): 
  • mystic/mystic/scipy_optimize.py

    r696 r698  
    255255        return settings 
    256256 
    257     def Solve(self, cost, termination=None, sigint_callback=None, 
    258                                             ExtraArgs=(), **kwds): 
     257    def Solve(self, cost=None, termination=None, sigint_callback=None, 
     258                                                 ExtraArgs=None, **kwds): 
    259259        """Minimize a function using the downhill simplex algorithm. 
    260260 
     
    569569        return settings 
    570570 
    571     def Solve(self, cost, termination=None, sigint_callback=None, 
    572                                             ExtraArgs=(), **kwds): 
     571    def Solve(self, cost=None, termination=None, sigint_callback=None, 
     572                                                 ExtraArgs=None, **kwds): 
    573573        """Minimize a function using modified Powell's method. 
    574574 
Note: See TracChangeset for help on using the changeset viewer.