Changeset 677 for branches


Ignore:
Timestamp:
06/04/13 19:54:18 (3 years ago)
Author:
mmckerns
Message:

updated solver docs to use Pool; nested solver examples use ProcessingPool?;
removed use of serialization helpers (no longer necessary) in UQ examples

Location:
branches/UQ/math/examples
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/UQ/math/examples/MPI2_surrogate_diam_batchgrid.py

    r676 r677  
    119119 
    120120  #construct cost function and run optimizer 
    121   #subdiameter, func_evals = optimize(cost.name,lb,ub) #XXX: no init_condition 
    122121  results = Pool(nnodes).map(optimize, cn,lb,ub,nb) 
    123122  #print "results = %s" % results 
  • branches/UQ/math/examples/MPI_surrogate_diam_batchgrid.py

    r676 r677  
    11#!/usr/bin/env python 
    22 
    3 def func_pickle(func, suffix='.pik', dir='.'): 
    4     """ standard pickle.dump of function to a NamedTemporaryFile """ 
    5     from dill.temp import dump 
    6     return dump(func, suffix=suffix, dir=dir) 
    7  
    83from mystic.math.grid import gridpts 
    9  
    104 
    115####################################################################### 
     
    7872  maxfun = 1e+6 
    7973  convergence_tol = 1e-4 
    80  
    81   def func_unpickle(filename): 
    82     """ standard pickle.load of function from a File """ 
    83     import dill as pickle 
    84     return pickle.load(open(filename,'r')) 
    8574 
    8675 #stepmon = VerboseMonitor(100) 
     
    9887 
    9988  tol = convergence_tol 
    100   cost = func_unpickle(cost)  #XXX: regenerate cost function from file 
    10189  solver.Solve(cost, termination=NCOG(tol)) 
    10290 
     
    164152    #construct cost function and run optimizer 
    165153    cost = costFactory(i) 
    166     cost = func_pickle(cost)  #XXX: allows an import to __globals__ 
    167     subdiameter, func_evals = optimize(cost.name,lb,ub) #XXX: no init_condition 
     154    subdiameter, func_evals = optimize(cost,lb,ub) #XXX: no init_condition 
    168155 
    169156    function_evaluations.append(func_evals) 
  • branches/UQ/math/examples/MPI_surrogate_diam_scatter.py

    r676 r677  
    11#!/usr/bin/env python 
    22 
    3 def func_pickle(func, suffix='.pik', dir='.'): 
    4     """ standard pickle.dump of function to a NamedTemporaryFile """ 
    5     from dill.temp import dump 
    6     return dump(func, suffix=suffix, dir=dir) 
    7  
    83from mystic.math.grid import samplepts 
    9  
    104 
    115####################################################################### 
     
    7872  maxfun = 1e+6 
    7973  convergence_tol = 1e-4 
    80  
    81   def func_unpickle(filename): 
    82     """ standard pickle.load of function from a File """ 
    83     import dill as pickle 
    84     return pickle.load(open(filename,'r')) 
    8574 
    8675 #stepmon = VerboseMonitor(100) 
     
    9887 
    9988  tol = convergence_tol 
    100   cost = func_unpickle(cost)  #XXX: regenerate cost function from file 
    10189  solver.Solve(cost, termination=NCOG(tol)) 
    10290 
     
    156144    #construct cost function and run optimizer 
    157145    cost = costFactory(i) 
    158     cost = func_pickle(cost)  #XXX: allows an import to __globals__ 
    159     subdiameter, func_evals = optimize(cost.name,lb,ub) #XXX: no init_condition 
     146    subdiameter, func_evals = optimize(cost,lb,ub) #XXX: no init_condition 
    160147 
    161148    function_evaluations.append(func_evals) 
  • branches/UQ/math/examples/MSUB_surrogate_diam_batchgrid.py

    r676 r677  
    11#!/usr/bin/env python 
    22 
    3 def func_pickle(func, suffix='.pik', dir='.'): 
    4     """ standard pickle.dump of function to a NamedTemporaryFile """ 
    5     from dill.temp import dump 
    6     return dump(func, suffix=suffix, dir=dir) 
    7  
    83from mystic.math.grid import gridpts 
    9  
    104 
    115####################################################################### 
     
    7872  from mystic.termination import NormalizedChangeOverGeneration as NCOG 
    7973  from mystic.monitors import VerboseMonitor, Monitor 
    80   from mystic.tools import getch 
    8174 
    8275  maxiter = 1000 
    8376  maxfun = 1e+6 
    8477  convergence_tol = 1e-4 
    85  
    86   def func_unpickle(filename): 
    87     """ standard pickle.load of function from a File """ 
    88     import dill as pickle 
    89     return pickle.load(open(filename,'r')) 
    9078 
    9179 #stepmon = VerboseMonitor(100) 
     
    10391 
    10492  tol = convergence_tol 
    105   cost = func_unpickle(cost)  #XXX: regenerate cost function from file 
    10693  solver.Solve(cost, termination=NCOG(tol)) 
    10794 
     
    170157    #construct cost function and run optimizer 
    171158    cost = costFactory(i) 
    172     cost = func_pickle(cost)  #XXX: allows an import to __globals__ 
    173     subdiameter, func_evals = optimize(cost.name,lb,ub) #XXX: no init_condition 
     159    subdiameter, func_evals = optimize(cost,lb,ub) #XXX: no init_condition 
    174160 
    175161    function_evaluations.append(func_evals) 
  • branches/UQ/math/examples/QSUB2_surrogate_diam_batchgrid.py

    r676 r677  
    119119 
    120120  #construct cost function and run optimizer 
    121   #subdiameter, func_evals = optimize(cost.name,lb,ub) #XXX: no init_condition 
    122121  results = Pool(nnodes).map(optimize, cn,lb,ub,nb) 
    123122  #print "results = %s" % results 
  • branches/UQ/math/examples/QSUB_surrogate_diam_batchgrid.py

    r676 r677  
    11#!/usr/bin/env python 
    22 
    3 def func_pickle(func, suffix='.pik', dir='.'): 
    4     """ standard pickle.dump of function to a NamedTemporaryFile """ 
    5     from dill.temp import dump 
    6     return dump(func, suffix=suffix, dir=dir) 
    7  
    83from mystic.math.grid import gridpts 
    9  
    104 
    115####################################################################### 
     
    8276  maxfun = 1e+6 
    8377  convergence_tol = 1e-4 
    84  
    85   def func_unpickle(filename): 
    86     """ standard pickle.load of function from a File """ 
    87     import dill as pickle 
    88     return pickle.load(open(filename,'r')) 
    8978 
    9079 #stepmon = VerboseMonitor(100) 
     
    10291 
    10392  tol = convergence_tol 
    104   cost = func_unpickle(cost)  #XXX: regenerate cost function from file 
    10593  solver.Solve(cost, termination=NCOG(tol)) 
    10694 
     
    169157    #construct cost function and run optimizer 
    170158    cost = costFactory(i) 
    171     cost = func_pickle(cost)  #XXX: allows an import to __globals__ 
    172     subdiameter, func_evals = optimize(cost.name,lb,ub) #XXX: no init_condition 
     159    subdiameter, func_evals = optimize(cost,lb,ub) #XXX: no init_condition 
    173160 
    174161    function_evaluations.append(func_evals) 
Note: See TracChangeset for help on using the changeset viewer.