- Timestamp:
- 02/17/15 10:30:50 (15 months ago)
- Location:
- mystic/mystic
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
mystic/mystic/abstract_solver.py
r781 r782 542 542 if termination is None: 543 543 termination = self._termination 544 # ensure evaluation limits have been imposed 545 self._SetEvaluationLimits() 544 546 # check for termination messages 545 547 msg = termination(self, info=True) … … 704 706 # set up signal handler 705 707 import signal 706 self._EARLYEXIT = False 708 self._EARLYEXIT = False #XXX: why not use EARLYEXIT singleton? 707 709 self._generateHandler(sigint_callback) 708 if self._handle_sigint: signal.signal(signal.SIGINT, 710 if self._handle_sigint: signal.signal(signal.SIGINT,self.signal_handler) 709 711 710 712 ## decorate cost function with bounds, penalties, monitors, etc … … 716 718 # the initital optimization iteration 717 719 if not len(self._stepmon): # do generation = 0 718 self.Step() 719 if callback is not None: 720 callback(self.bestSolution) 721 722 # initialize termination conditions, if needed 723 self._termination(self) #XXX: call at generation 0 or always? 724 # impose the evaluation limits 725 self._SetEvaluationLimits() 720 self.Step(callback=callback) 726 721 727 722 # the main optimization loop 728 723 while not self.CheckTermination() and not self._EARLYEXIT: 729 self.Step(**settings) 730 if callback is not None: 731 callback(self.bestSolution) 724 self.Step(**settings) # includes settings['callback'] 732 725 else: self._exitMain() 733 726 -
mystic/mystic/differential_evolution.py
r781 r782 222 222 cost = self._bootstrap_objective(cost, ExtraArgs) 223 223 # process and activate input settings 224 kwds['strategy'] = strategy # override default strategy with None224 kwds['strategy'] = strategy # override default strategy 225 225 settings = self._process_inputs(kwds) 226 226 for key in settings: 227 227 exec "%s = settings['%s']" % (key,key) 228 228 229 init = False # flag to do 0th iteration 'post-initialization' 230 229 231 if not len(self._stepmon): # do generation = 0 232 init = True 230 233 self.population[0] = asfarray(self.population[0]) 231 234 # decouple bestSolution from population and bestEnergy from popEnergy … … 267 270 # if savefrequency matches, then save state 268 271 self._AbstractSolver__save_state() 272 273 # do callback 274 if callback is not None: callback(self.bestSolution) 275 # initialize termination conditions, if needed 276 if init: self._termination(self) #XXX: at generation 0 or always? 269 277 return #XXX: call CheckTermination ? 270 278 … … 379 387 cost = self._bootstrap_objective(cost, ExtraArgs) 380 388 # process and activate input settings 381 kwds['strategy'] = strategy # override default strategy with None389 kwds['strategy'] = strategy # override default strategy 382 390 settings = self._process_inputs(kwds) 383 391 for key in settings: 384 392 exec "%s = settings['%s']" % (key,key) 385 393 394 init = False # flag to do 0th iteration 'post-initialization' 395 386 396 if not len(self._stepmon): # do generation = 0 397 init = True 387 398 self.population[0] = asfarray(self.population[0]) 388 399 # decouple bestSolution from population and bestEnergy from popEnergy … … 429 440 # if savefrequency matches, then save state 430 441 self._AbstractSolver__save_state() 442 443 # do callback 444 if callback is not None: callback(self.bestSolution) 445 # initialize termination conditions, if needed 446 if init: self._termination(self) #XXX: at generation 0 or always? 431 447 return #XXX: call CheckTermination ? 432 448 -
mystic/mystic/scipy_optimize.py
r781 r782 152 152 153 153 rho = 1; chi = 2; psi = 0.5; sigma = 0.5; 154 init = False # flag to do 0th iteration 'post-initialization' 154 155 155 156 if not len(self._stepmon): # do generation = 0 157 init = True 156 158 x0 = self.population[0] 157 159 x0 = asfarray(x0).flatten() … … 252 254 # if savefrequency matches, then save state 253 255 self._AbstractSolver__save_state() 256 257 # do callback 258 if callback is not None: callback(self.bestSolution) 259 # initialize termination conditions, if needed 260 if init: self._termination(self) #XXX: at generation 0 or always? 254 261 return #XXX: call CheckTermination ? 255 262 … … 469 476 fval = self.popEnergy[0] # bestEnergy 470 477 x1, fx, bigind, delta = self.__internals 478 init = False # flag to do 0th iteration 'post-initialization' 471 479 472 480 if not len(self._stepmon): # do generation = 0 481 init = True 473 482 x = asfarray(x).flatten() 474 483 x = asfarray(self._constraints(x)) … … 558 567 self.population[0] = x # bestSolution 559 568 self.popEnergy[0] = fval # bestEnergy 569 570 # do callback 571 if callback is not None: callback(self.bestSolution) 572 # initialize termination conditions, if needed 573 if init: self._termination(self) #XXX: at generation 0 or always? 560 574 return #XXX: call CheckTermination ? 561 575
Note: See TracChangeset
for help on using the changeset viewer.