Changeset 372


Ignore:
Timestamp:
08/04/10 12:44:55 (6 years ago)
Author:
mmckerns
Message:

marker toggleable on log_reader; all=False is default on Sows

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/multilogger/log_reader.py

    r352 r372  
    11import sys 
     2if '--dots' in sys.argv: 
     3  mark = 'o' 
     4  sys.argv.remove('--dots') 
     5else: 
     6  mark = '' 
     7 
    28try: 
    39  filename = sys.argv[1] 
     
    8187  for i in range(len(conv)): 
    8288    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) 
    8490plt.legend() 
    8591 
     
    8793for i in range(len(conv)): 
    8894  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) 
    9096plt.legend() 
    9197 
  • mystic/mystic/differential_evolution.py

    r296 r372  
    277277                    self.bestEnergy = trialEnergy 
    278278                    self.bestSolution[:] = self.trialSolution[:] 
    279                              
     279 
    280280        self.energy_history.append(self.bestEnergy) 
    281281        StepMonitor(self.bestSolution[:], self.bestEnergy, id) 
     
    307307                        self.bestEnergy = trialEnergy 
    308308                        self.bestSolution[:] = self.trialSolution[:] 
    309                              
     309 
    310310            self.energy_history.append(self.bestEnergy) 
    311311            StepMonitor(self.bestSolution[:], self.bestEnergy, id) 
     
    486486                    self.bestEnergy = trialEnergy[candidate] 
    487487                    self.bestSolution[:] = trialPop[candidate][:] 
    488                          
     488 
    489489        self.energy_history.append(self.bestEnergy) 
    490490       #FIXME: StepMonitor works for 'pp'? 
     
    528528                        self.bestEnergy = trialEnergy[candidate] 
    529529                        self.bestSolution[:] = trialPop[candidate][:] 
    530                              
     530 
    531531            self.energy_history.append(self.bestEnergy) 
    532532           #FIXME: StepMonitor works for 'pp'? 
  • mystic/mystic/scipy_optimize.py

    r296 r372  
    207207            allvecs = [sim[0]] 
    208208        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] 
    210210 
    211211        #--- ensure initial simplex is within bounds --- 
     
    228228        self.popEnergy = fsim 
    229229        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] 
    231231 
    232232        iterations = 1 
     
    296296            self.popEnergy = fsim 
    297297            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] 
    299299 
    300300        self.generations = iterations 
     
    591591            self.population[0] = x    #XXX: pointless 
    592592            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 
    594594     
    595595        self.generations = iter 
  • mystic/mystic/tools.py

    r370 r372  
    164164    """ 
    165165    import numpy 
    166     def __init__(self, interval = 10, xinterval = numpy.inf, all=False): 
     166    def __init__(self, interval = 10, xinterval = numpy.inf, all=True): 
    167167        super(VerboseSow,self).__init__() 
    168168        self._step = 0 
     
    209209    """ 
    210210    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): 
    212212        import datetime 
    213213        super(LoggingSow,self).__init__() 
  • mystic/tests/test_SOW.py

    r370 r372  
    4747def test2(monitor, diffenv=None): 
    4848  if diffenv == True: 
    49     from mystic.differential_evolution import DifferentialEvolutionSolver as DE 
    50    #from mystic.differential_evolution import DifferentialEvolutionSolver2 as DE 
     49   #from mystic.differential_evolution import DifferentialEvolutionSolver as DE 
     50    from mystic.differential_evolution import DifferentialEvolutionSolver2 as DE 
    5151  elif diffenv == False: 
    5252    from mystic.scipy_optimize import NelderMeadSimplexSolver as noDE 
     
    6262  ndim = len(lb) 
    6363  npop = 5 
    64   maxiter = 5 
     64  maxiter = 10 
    6565  maxfun = 1e+6 
    6666  convergence_tol = 1e-10; ngen = 100 
     
    8181 
    8282  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) 
    8485 
    8586  solved = solver.Solution() 
     
    9192if __name__ == '__main__': 
    9293 
    93   from mystic import Sow, VerboseSow 
    94   monitor = Sow() 
     94  from mystic import Sow, VerboseSow, LoggingSow 
     95 #monitor = Sow() 
     96 #monitor = Sow(all=True) 
    9597 #monitor = Sow(all=False) 
    9698 #monitor = VerboseSow(1,1)  
    9799 #monitor = VerboseSow(1,1, all=True)  
    98  #monitor = LoggingSow(1) 
     100 #monitor = VerboseSow(1,1, all=False)  
     101  monitor = LoggingSow(1) 
    99102 #monitor = LoggingSow(1, all=True) 
     103 #monitor = LoggingSow(1, all=False) 
    100104 
    101105 #test0(monitor) 
    102   test1(monitor) 
    103  #test2(monitor)                 # r340 is like test0; desired is like test1 
    104  #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 []) 
    105109 #test2(monitor, diffenv=True) 
    106110 
    107111  # these are for "SowPlotter(s)"; need to adapt log.py plotters for test1 
    108112  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') 
    115114 
    116115# EOF 
Note: See TracChangeset for help on using the changeset viewer.