Changeset 559
- Timestamp:
- 09/12/12 11:40:33 (4 years ago)
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HPCtut/optimize_helper.py
r534 r559 11 11 disp=disp, itermon=mon, handler=0) 12 12 # return: solution, energy, generations, fevals 13 return solved[0], solved[1], solved[ 3], solved[4]13 return solved[0], solved[1], solved[2], solved[3] 14 14 15 15 def diffev(cost, x0, full=1, disp=1, monitor=0): … … 23 23 disp=disp, itermon=mon, handler=0) 24 24 # return: solution, energy, generations, fevals 25 return solved[0], solved[1], solved[ 3], solved[4]25 return solved[0], solved[1], solved[2], solved[3] 26 26 27 27 -
branches/UQ/math/legacy/dirac_measure.py
r558 r559 1022 1022 if debug: stepmon = VerboseMonitor(10) #!!! 1023 1023 if npop: # use VTR 1024 _i = 2 #XXX: iter returned as results[2]1025 1024 results = diffev2(cost, guess, npop, ftol=ftol, gtol=gtol, bounds=bounds,\ 1026 1025 maxiter=maxiter, maxfun=maxfun, constraints=constraints,\ … … 1029 1028 full_output=1, disp=0, handler=False) 1030 1029 else: # use VTR 1031 _i = 3 #XXX: iter returned as results[3] (results[2] == direc)1032 1030 results = fmin_powell(cost, guess, ftol=ftol, gtol=gtol, bounds=bounds,\ 1033 1031 maxiter=maxiter, maxfun=maxfun, constraints=constraints,\ … … 1037 1035 pm = scenario() 1038 1036 pm.load(results[0], pts) # params: w,x,y 1039 1040 if debug and results[ _i] >= maxiter: # iterations1037 #if debug: print "final cost: %s" % results[1] 1038 if debug and results[2] >= maxiter: # iterations 1041 1039 print "Warning: constraints solver terminated at maximum iterations" 1042 #func_evals = results[ _i+1] # evaluation1040 #func_evals = results[3] # evaluation 1043 1041 return pm 1044 1042 … … 1154 1152 if debug: stepmon = VerboseMonitor(2) #!!! 1155 1153 if npop: # use VTR 1156 _i = 2 #XXX: iter returned as results[2]1157 1154 results = diffev2(cost, guess, npop, ftol=ftol, gtol=gtol, bounds=bounds,\ 1158 1155 maxiter=maxiter, maxfun=maxfun, constraints=constraints,\ … … 1161 1158 full_output=1, disp=0, handler=False) 1162 1159 else: # use VTR 1163 _i = 3 #XXX: iter returned as results[3] (results[2] == direc)1164 1160 results = fmin_powell(cost, guess, ftol=ftol, gtol=gtol, bounds=bounds,\ 1165 1161 maxiter=maxiter, maxfun=maxfun, constraints=constraints,\ … … 1170 1166 pm.load(results[0], pts) # params: w,x,y 1171 1167 #if debug: print "final cost: %s" % results[1] 1172 if debug and results[ _i] >= maxiter: # iterations1168 if debug and results[2] >= maxiter: # iterations 1173 1169 print "Warning: constraints solver terminated at maximum iterations" 1174 #func_evals = results[ _i+1] # evaluation1170 #func_evals = results[3] # evaluation 1175 1171 return pm 1176 1172 -
mystic/mystic/differential_evolution.py
r540 r559 335 335 #else: self._stepmon.info('STOP()') 336 336 337 337 ## code below here pushes output to scipy.optimize.fmin interface 338 338 fval = self.bestEnergy 339 339 #warnflag = 0 340 340 341 341 if self._fcalls[0] >= self._maxfun: 342 342 # warnflag = 1 343 343 if disp: 344 344 print "Warning: Maximum number of function evaluations has "\ 345 345 "been exceeded." 346 346 elif self.generations >= self._maxiter: 347 347 # warnflag = 2 348 348 if disp: 349 349 print "Warning: Maximum number of iterations has been exceeded" … … 558 558 #else: self._stepmon.info('STOP()') 559 559 560 560 ## code below here pushes output to scipy.optimize.fmin interface 561 561 fval = self.bestEnergy 562 562 #warnflag = 0 563 563 564 564 if self._fcalls[0] >= self._maxfun: 565 565 # warnflag = 1 566 566 if disp: 567 567 print "Warning: Maximum number of function evaluations has "\ 568 568 "been exceeded." 569 569 elif self.generations >= self._maxiter: 570 570 # warnflag = 2 571 571 if disp: 572 572 print "Warning: Maximum number of iterations has been exceeded" … … 739 739 constraints = kwds['constraints'] 740 740 solver.SetConstraints(constraints) 741 if bounds !=None:741 if bounds is not None: 742 742 minb,maxb = unpair(bounds) 743 743 solver.SetStrictRanges(minb,maxb) -
mystic/mystic/scipy_optimize.py
r540 r559 318 318 #else: self._stepmon.info('STOP()') 319 319 320 321 320 ## code below here is dead, unless disp!=0 321 #x = sim[0] 322 322 fval = min(fsim) 323 323 #warnflag = 0 324 324 325 325 if self._fcalls[0] >= self._maxfun: 326 326 # warnflag = 1 327 327 if disp: 328 328 print "Warning: Maximum number of function evaluations has "\ 329 329 "been exceeded." 330 330 elif iterations >= self._maxiter: 331 331 # warnflag = 2 332 332 if disp: 333 333 print "Warning: Maximum number of iterations has been exceeded" … … 340 340 341 341 342 343 344 345 346 347 348 349 342 #if full_output: 343 # retlist = x, fval, iterations, self._fcalls[0], warnflag 344 # if retall: 345 # retlist += (allvecs,) 346 #else: 347 # retlist = x 348 # if retall: 349 # retlist = (x, allvecs) 350 350 351 351 return #retlist … … 431 431 constraints = kwds['constraints'] 432 432 solver.SetConstraints(constraints) 433 if bounds !=None:433 if bounds is not None: 434 434 minb,maxb = unpair(bounds) 435 435 solver.SetStrictRanges(minb,maxb) … … 447 447 fcalls = len(evalmon.x) 448 448 iterations = len(stepmon.x) 449 allvecs = [] 450 for i in range(iterations): 451 #allvecs.append(list(stepmon.x[i])) 452 allvecs.append(stepmon.x[i]) 449 allvecs = stepmon.x 453 450 454 451 if fcalls >= solver._maxfun: … … 493 490 """ 494 491 AbstractSolver.__init__(self,dim) 495 self._direc = None # FIXME:this is the easy way to return 'direc'...492 self._direc = None # this is the easy way to return 'direc'... 496 493 497 494 … … 536 533 xtol=1e-4 #line-search error tolerance 537 534 if kwds.has_key('callback'): callback = kwds['callback'] 538 if kwds.has_key('direc'): direc = kwds['direc'] #XXX: best interface?535 if kwds.has_key('direc'): direc = kwds['direc'] 539 536 if kwds.has_key('xtol'): xtol = kwds['xtol'] 540 537 if kwds.has_key('disp'): disp = kwds['disp'] … … 661 658 #else: self._stepmon.info('STOP()') 662 659 663 664 660 ## code below here is dead, unless disp!=0 661 #warnflag = 0 665 662 666 663 if self._fcalls[0] >= self._maxfun: 667 664 # warnflag = 1 668 665 if disp: 669 666 print "Warning: Maximum number of function evaluations has "\ 670 667 "been exceeded." 671 668 elif iter >= self._maxiter: 672 669 # warnflag = 2 673 670 if disp: 674 671 print "Warning: Maximum number of iterations has been exceeded" … … 680 677 print " Function evaluations: %d" % self._fcalls[0] 681 678 682 683 684 685 686 687 688 689 690 691 679 #x = squeeze(x) 680 681 #if full_output: 682 # retlist = x, fval, direc, iter, self._fcalls[0], warnflag 683 # if retall: 684 # retlist += (allvecs,) 685 #else: 686 # retlist = x 687 # if retall: 688 # retlist = (x, allvecs) 692 689 693 690 return #retlist … … 738 735 the encoded constraints. 739 736 740 Returns: (xopt, {fopt, direc, iter, funcalls, warnflag}, {allvecs})737 Returns: (xopt, {fopt, iter, funcalls, warnflag, direc}, {allvecs}) 741 738 742 739 xopt -- ndarray - minimizer of function 743 740 fopt -- number - value of function at minimum: fopt = func(xopt) 744 direc -- current direction set745 741 iter -- number - number of iterations 746 742 funcalls -- number - number of function calls … … 748 744 1 : 'Maximum number of function evaluations.' 749 745 2 : 'Maximum number of iterations.' 746 direc -- current direction set 750 747 allvecs -- list - a list of solutions at each iteration 751 748 … … 784 781 constraints = kwds['constraints'] 785 782 solver.SetConstraints(constraints) 786 if bounds !=None:783 if bounds is not None: 787 784 minb,maxb = unpair(bounds) 788 785 solver.SetStrictRanges(minb,maxb) … … 801 798 fcalls = len(evalmon.x) 802 799 iterations = len(stepmon.x) - 1 803 allvecs = [] 804 for i in range(len(stepmon.x)): 805 #allvecs.append(list(stepmon.x[i])) 806 allvecs.append(stepmon.x[i]) 807 direc = solver._direc #FIXME: better way to get direc from Solve() ? 800 allvecs = stepmon.x 801 direc = solver._direc #XXX: need better way to return direc ? 808 802 809 803 if fcalls >= solver._maxfun: … … 815 809 816 810 if full_output: 817 retlist = x, fval, direc, iterations, fcalls, warnflag811 retlist = x, fval, iterations, fcalls, warnflag, direc 818 812 if retall: 819 813 retlist += (allvecs,)
Note: See TracChangeset
for help on using the changeset viewer.