Changeset 372
- Timestamp:
- 08/04/10 12:44:55 (6 years ago)
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/multilogger/log_reader.py
r352 r372 1 1 import sys 2 if '--dots' in sys.argv: 3 mark = 'o' 4 sys.argv.remove('--dots') 5 else: 6 mark = '' 7 2 8 try: 3 9 filename = sys.argv[1] … … 81 87 for i in range(len(conv)): 82 88 tag = "%d,%d" % (i,j) 83 ax1.plot(iter_conv[i],conv[i][j],label="%s" % tag,marker= 'o')89 ax1.plot(iter_conv[i],conv[i][j],label="%s" % tag,marker=mark) 84 90 plt.legend() 85 91 … … 87 93 for i in range(len(conv)): 88 94 tag = "%d" % i 89 ax2.plot(iter_conv[i],cost_conv[i],label='cost %s' % tag,marker= 'o')95 ax2.plot(iter_conv[i],cost_conv[i],label='cost %s' % tag,marker=mark) 90 96 plt.legend() 91 97 -
mystic/mystic/differential_evolution.py
r296 r372 277 277 self.bestEnergy = trialEnergy 278 278 self.bestSolution[:] = self.trialSolution[:] 279 279 280 280 self.energy_history.append(self.bestEnergy) 281 281 StepMonitor(self.bestSolution[:], self.bestEnergy, id) … … 307 307 self.bestEnergy = trialEnergy 308 308 self.bestSolution[:] = self.trialSolution[:] 309 309 310 310 self.energy_history.append(self.bestEnergy) 311 311 StepMonitor(self.bestSolution[:], self.bestEnergy, id) … … 486 486 self.bestEnergy = trialEnergy[candidate] 487 487 self.bestSolution[:] = trialPop[candidate][:] 488 488 489 489 self.energy_history.append(self.bestEnergy) 490 490 #FIXME: StepMonitor works for 'pp'? … … 528 528 self.bestEnergy = trialEnergy[candidate] 529 529 self.bestSolution[:] = trialPop[candidate][:] 530 530 531 531 self.energy_history.append(self.bestEnergy) 532 532 #FIXME: StepMonitor works for 'pp'? -
mystic/mystic/scipy_optimize.py
r296 r372 207 207 allvecs = [sim[0]] 208 208 fsim[0] = func(x0) 209 StepMonitor(sim[0], fsim[0], id) # sim = all values; "best" is sim[0]209 StepMonitor(sim[0], fsim[0], id) # sim = all; "best" is sim[0] 210 210 211 211 #--- ensure initial simplex is within bounds --- … … 228 228 self.popEnergy = fsim 229 229 self.energy_history.append(self.bestEnergy) 230 StepMonitor(sim[0], fsim[0], id) # sim = all values; "best" is sim[0]230 StepMonitor(sim[0], fsim[0], id) # sim = all; "best" is sim[0] 231 231 232 232 iterations = 1 … … 296 296 self.popEnergy = fsim 297 297 self.energy_history.append(self.bestEnergy) 298 StepMonitor(sim[0], fsim[0],id) # sim = all values; "best" is sim[0]298 StepMonitor(sim[0], fsim[0],id) # sim = all; "best" is sim[0] 299 299 300 300 self.generations = iterations … … 591 591 self.population[0] = x #XXX: pointless 592 592 self.popEnergy[0] = fval #XXX: pointless 593 StepMonitor(x, fval, id) # get ith values ; #XXX: should be [x],[fval] ?593 StepMonitor(x, fval, id) # get ith values 594 594 595 595 self.generations = iter -
mystic/mystic/tools.py
r370 r372 164 164 """ 165 165 import numpy 166 def __init__(self, interval = 10, xinterval = numpy.inf, all= False):166 def __init__(self, interval = 10, xinterval = numpy.inf, all=True): 167 167 super(VerboseSow,self).__init__() 168 168 self._step = 0 … … 209 209 """ 210 210 import numpy 211 def __init__(self, interval=1, filename='log.txt', new=False, all= False):211 def __init__(self, interval=1, filename='log.txt', new=False, all=True): 212 212 import datetime 213 213 super(LoggingSow,self).__init__() -
mystic/tests/test_SOW.py
r370 r372 47 47 def test2(monitor, diffenv=None): 48 48 if diffenv == True: 49 50 #from mystic.differential_evolution import DifferentialEvolutionSolver2 as DE49 #from mystic.differential_evolution import DifferentialEvolutionSolver as DE 50 from mystic.differential_evolution import DifferentialEvolutionSolver2 as DE 51 51 elif diffenv == False: 52 52 from mystic.scipy_optimize import NelderMeadSimplexSolver as noDE … … 62 62 ndim = len(lb) 63 63 npop = 5 64 maxiter = 564 maxiter = 10 65 65 maxfun = 1e+6 66 66 convergence_tol = 1e-10; ngen = 100 … … 81 81 82 82 tol = convergence_tol 83 solver.Solve(cost, termination=COG(tol,ngen), StepMonitor=monitor) 83 #solver.Solve(cost, termination=COG(tol,ngen), StepMonitor=monitor) 84 solver.Solve(cost, termination=COG(tol,ngen), EvaluationMonitor=monitor) 84 85 85 86 solved = solver.Solution() … … 91 92 if __name__ == '__main__': 92 93 93 from mystic import Sow, VerboseSow 94 monitor = Sow() 94 from mystic import Sow, VerboseSow, LoggingSow 95 #monitor = Sow() 96 #monitor = Sow(all=True) 95 97 #monitor = Sow(all=False) 96 98 #monitor = VerboseSow(1,1) 97 99 #monitor = VerboseSow(1,1, all=True) 98 #monitor = LoggingSow(1) 100 #monitor = VerboseSow(1,1, all=False) 101 monitor = LoggingSow(1) 99 102 #monitor = LoggingSow(1, all=True) 103 #monitor = LoggingSow(1, all=False) 100 104 101 105 #test0(monitor) 102 103 #test2(monitor) # r340 is like test0; desired is like test1104 #test2(monitor, diffenv=False) # ... (for Powell, add enclosing [])106 #test1(monitor) 107 test2(monitor) # StepMonitor works like test0 108 #test2(monitor, diffenv=False) # (to make like test1, add enclosing []) 105 109 #test2(monitor, diffenv=True) 106 110 107 111 # these are for "SowPlotter(s)"; need to adapt log.py plotters for test1 108 112 write_support_file(monitor,'paramlog1.py') 109 write_converge_file(monitor,'paramlog2.py') 110 111 # also need "LogPlotter(s)" for log.txt from test1 all=True & all=False data 112 # all Plotters for all=True should take "best=True" to draw only 'best' data 113 114 # when using "best=True", find ChiSq[i] that is least, take corresponding x ?? 113 #write_converge_file(monitor,'paramlog2.py') 115 114 116 115 # EOF
Note: See TracChangeset
for help on using the changeset viewer.