Changeset 462
- Timestamp:
- 06/21/11 12:12:23 (5 years ago)
- Location:
- mystic
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
mystic/examples/test_rosenbrock.py
r219 r462 36 36 37 37 solution = solver.Solution() 38 #print "Current function value: %s" % solver.bestEnergy 39 #print "Iterations: %s" % solver.generations 40 #print "Function evaluations: %s" % solver.evaluations 38 41 39 42 print solution … … 82 85 sol = solver.Solution() 83 86 print sol 87 #print "Current function value: %s" % solver.bestEnergy 88 #print "Iterations: %s" % solver.generations 89 #print "Function evaluations: %s" % solver.evaluations 84 90 85 91 times.append(time.time() - start) -
mystic/examples/test_rosenbrock2.py
r422 r462 39 39 solver.Solve(rosen,termination=CRT(xtol=4e-5),StepMonitor=stepmon,disp=1) 40 40 print solver.Solution() 41 #print "Current function value: %s" % solver.bestEnergy 42 #print "Iterations: %s" % solver.generations 43 #print "Function evaluations: %s" % solver.evaluations 41 44 42 45 times.append(time.time() - start) -
mystic/examples/test_rosenbrock3.py
r454 r462 43 43 solver.Solve(rosen,termination=NCOG(tolerance=1e-4),StepMonitor=stepmon,disp=1, constraints=constrain) 44 44 print solver.Solution() 45 #print "Current function value: %s" % solver.bestEnergy 46 #print "Iterations: %s" % solver.generations 47 #print "Function evaluations: %s" % solver.evaluations 45 48 46 49 times.append(time.time() - start) -
mystic/mystic/abstract_map_solver.py
r456 r462 93 93 nDim, nPop = dim, npop 94 94 generations - an iteration counter. 95 evaluations - an evaluation counter. 95 96 bestEnergy - current best energy. 96 97 bestSolution - current best parameter set. [size = dim] -
mystic/mystic/abstract_nested_solver.py
r296 r462 99 99 nDim, nPop = dim, npop 100 100 generations - an iteration counter. 101 evaluations - an evaluation counter. 101 102 bestEnergy - current best energy. 102 103 bestSolution - current best parameter set. [size = dim] -
mystic/mystic/abstract_solver.py
r440 r462 96 96 nDim, nPop = dim, npop 97 97 generations - an iteration counter. 98 evaluations - an evaluation counter. 98 99 bestEnergy - current best energy. 99 100 bestSolution - current best parameter set. [size = dim] … … 106 107 if kwds.has_key('npop'): NP = kwds['npop'] 107 108 109 self._fcalls = [0] 108 110 self.nDim = dim 109 111 self.nPop = NP … … 136 138 """return the best solution""" 137 139 return self.bestSolution 140 141 def __evaluations(self): 142 """get the number of function calls""" 143 return self._fcalls[0] 138 144 139 145 def SetStrictRanges(self, min=None, max=None): … … 321 327 raise NotImplementedError, "must be overwritten..." 322 328 329 # extensions to the solver interface 330 evaluations = property(__evaluations ) 331 pass 332 323 333 324 334 -
mystic/mystic/differential_evolution.py
r456 r462 245 245 self._EARLYEXIT = False 246 246 247 fcalls, costfunction = wrap_function(costfunction, ExtraArgs, EvaluationMonitor)247 self._fcalls, costfunction = wrap_function(costfunction, ExtraArgs, EvaluationMonitor) 248 248 if self._useStrictRange: 249 249 for i in range(self.nPop): … … 291 291 #run for generations <= maxiter 292 292 for generation in range(self._maxiter - self.generations): 293 if fcalls[0] >= self._maxfun: break293 if self._fcalls[0] >= self._maxfun: break 294 294 for candidate in range(self.nPop): 295 295 # generate trialSolution (within valid range) … … 323 323 warnflag = 0 324 324 325 if fcalls[0] >= self._maxfun:325 if self._fcalls[0] >= self._maxfun: 326 326 warnflag = 1 327 327 if disp: … … 337 337 print " Current function value: %f" % fval 338 338 print " Iterations: %d" % self.generations 339 print " Function evaluations: %d" % fcalls[0]339 print " Function evaluations: %d" % self._fcalls[0] 340 340 341 341 return … … 442 442 from python_map import python_map 443 443 if self._map != python_map: 444 fcalls = [0] #FIXME: temporary patch for removing the following line444 self._fcalls = [0] #FIXME: temporary patch for removing the following line 445 445 else: 446 fcalls, costfunction = wrap_function(costfunction, ExtraArgs, EvaluationMonitor)446 self._fcalls, costfunction = wrap_function(costfunction, ExtraArgs, EvaluationMonitor) 447 447 if self._useStrictRange: 448 448 for i in range(self.nPop): … … 502 502 #run for generations <= maxiter 503 503 for generation in range(self._maxiter - self.generations): 504 if fcalls[0] >= self._maxfun: break504 if self._fcalls[0] >= self._maxfun: break 505 505 for candidate in range(self.nPop): 506 506 # generate trialSolution (within valid range) … … 546 546 warnflag = 0 547 547 548 if fcalls[0] >= self._maxfun:548 if self._fcalls[0] >= self._maxfun: 549 549 warnflag = 1 550 550 if disp: … … 560 560 print " Current function value: %f" % fval 561 561 print " Iterations: %d" % self.generations 562 print " Function evaluations: %d" % fcalls[0]562 print " Function evaluations: %d" % self._fcalls[0] 563 563 564 564 return -
mystic/mystic/scipy_optimize.py
r455 r462 177 177 self._EARLYEXIT = False 178 178 179 fcalls, func = wrap_function(func, args, EvaluationMonitor)179 self._fcalls, func = wrap_function(func, args, EvaluationMonitor) 180 180 if self._useStrictRange: 181 181 x0 = self._clipGuessWithinRangeBoundary(x0) … … 239 239 iterations = 1 240 240 241 while ( fcalls[0] < self._maxfun and iterations < self._maxiter):241 while (self._fcalls[0] < self._maxfun and iterations < self._maxiter): 242 242 if self._EARLYEXIT or termination(self): 243 243 break … … 316 316 warnflag = 0 317 317 318 if fcalls[0] >= self._maxfun:318 if self._fcalls[0] >= self._maxfun: 319 319 warnflag = 1 320 320 if disp: … … 330 330 print " Current function value: %f" % fval 331 331 print " Iterations: %d" % iterations 332 print " Function evaluations: %d" % fcalls[0]332 print " Function evaluations: %d" % self._fcalls[0] 333 333 334 334 335 335 if full_output: 336 retlist = x, fval, iterations, fcalls[0], warnflag336 retlist = x, fval, iterations, self._fcalls[0], warnflag 337 337 if retall: 338 338 retlist += (allvecs,) … … 515 515 self._EARLYEXIT = False 516 516 517 fcalls, func = wrap_function(func, args, EvaluationMonitor)517 self._fcalls, func = wrap_function(func, args, EvaluationMonitor) 518 518 if self._useStrictRange: 519 519 x0 = self._clipGuessWithinRangeBoundary(x0) … … 584 584 self.energy_history.append(fval) #XXX: the 'best' for now... 585 585 if self._EARLYEXIT or termination(self): CONTINUE = False #break 586 elif fcalls[0] >= self._maxfun: CONTINUE = False #break586 elif self._fcalls[0] >= self._maxfun: CONTINUE = False #break 587 587 elif iter >= self._maxiter: CONTINUE = False #break 588 588 … … 621 621 warnflag = 0 622 622 623 if fcalls[0] >= self._maxfun:623 if self._fcalls[0] >= self._maxfun: 624 624 warnflag = 1 625 625 if disp: … … 635 635 print " Current function value: %f" % fval 636 636 print " Iterations: %d" % iter 637 print " Function evaluations: %d" % fcalls[0]637 print " Function evaluations: %d" % self._fcalls[0] 638 638 639 639 x = squeeze(x) 640 640 641 641 if full_output: 642 retlist = x, fval, direc, iter, fcalls[0], warnflag642 retlist = x, fval, direc, iter, self._fcalls[0], warnflag 643 643 if retall: 644 644 retlist += (allvecs,)
Note: See TracChangeset
for help on using the changeset viewer.