Changeset 678 for branches


Ignore:
Timestamp:
06/05/13 07:02:44 (3 years ago)
Author:
mmckerns
Message:

func_pickle not needed for MPI2 either, so commented it out;
added MM2 example, also modified MPI2 example to avoid OOB connection error

Location:
branches/UQ/math/examples
Files:
2 edited
1 copied
1 moved

Legend:

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

    r677 r678  
    6161def optimize(cost,lower,upper,nbins): 
    6262  from mystic.tools import random_seed 
    63   from pyina.launchers import Mpi as Pool 
     63  from pathos.multiprocessing import ProcessingPool as Pool 
    6464  random_seed(123) 
    6565 
     
    7272 
    7373  # build a grid of starting points 
    74   from MPI2_helper import local_optimize 
     74  from pool_helper import local_optimize 
    7575  from mystic.math.grid import gridpts 
    7676  initial_values = gridpts(bins) 
     
    105105####################################################################### 
    106106def UQ(start,end,lower,upper): 
    107   from pyina.launchers import Mpi as Pool 
    108   from MPI2_helper import func_pickle 
     107  from pathos.multiprocessing import ProcessingPool as Pool 
     108 #from pool_helper import func_pickle  # if fails to pickle, try using a helper 
    109109 
    110110  # run optimizer for each subdiameter  
     
    114114  for i in range(len(nb)): nb[i][-1] = nb[i][i] 
    115115  cf = [costFactory(i)     for i in range(start,end+1)] 
    116   cf = [func_pickle(i)     for i in cf] 
    117   cn = [cost.name          for cost in cf] 
     116 #cf = [func_pickle(i)     for i in cf] 
     117 #cf = [cost.name          for cost in cf] 
    118118  nnodes = len(lb) 
    119119 
    120120  #construct cost function and run optimizer 
    121   results = Pool(nnodes).map(optimize, cn,lb,ub,nb) 
     121  results = Pool(nnodes).map(optimize, cf,lb,ub,nb) 
    122122  #print "results = %s" % results 
    123123 
  • branches/UQ/math/examples/MPI2_surrogate_diam_batchgrid.py

    r677 r678  
    7272 
    7373  # build a grid of starting points 
    74   from MPI2_helper import local_optimize 
     74  from pool_helper import local_optimize 
    7575  from mystic.math.grid import gridpts 
    7676  initial_values = gridpts(bins) 
     
    105105####################################################################### 
    106106def UQ(start,end,lower,upper): 
    107   from pyina.launchers import Mpi as Pool 
    108   from MPI2_helper import func_pickle 
     107 #from pyina.launchers import Mpi as Pool 
     108  from pathos.multiprocessing import ProcessingPool as Pool 
     109 #from pool_helper import func_pickle  # if fails to pickle, try using a helper 
    109110 
    110111  # run optimizer for each subdiameter  
     
    114115  for i in range(len(nb)): nb[i][-1] = nb[i][i] 
    115116  cf = [costFactory(i)     for i in range(start,end+1)] 
    116   cf = [func_pickle(i)     for i in cf] 
    117   cn = [cost.name          for cost in cf] 
     117 #cf = [func_pickle(i)     for i in cf] 
     118 #cf = [cost.name          for cost in cf] 
    118119  nnodes = len(lb) 
    119120 
    120121  #construct cost function and run optimizer 
    121   results = Pool(nnodes).map(optimize, cn,lb,ub,nb) 
     122  results = Pool(nnodes).map(optimize, cf,lb,ub,nb) 
    122123  #print "results = %s" % results 
    123124 
  • branches/UQ/math/examples/QSUB2_surrogate_diam_batchgrid.py

    r677 r678  
    7373  # build a grid of starting points 
    7474  from mystic.math.grid import gridpts 
    75   from MPI2_helper import local_optimize 
    76   from MPI2_helper import nnodes, queue, timelimit 
     75  from pool_helper import local_optimize 
     76  from pool_helper import nnodes, queue, timelimit 
    7777  initial_values = gridpts(bins) 
    7878 
     
    106106def UQ(start,end,lower,upper): 
    107107  from pyina.launchers import Mpi as Pool 
    108   from MPI2_helper import func_pickle 
     108 #from pool_helper import func_pickle  # if fails to pickle, try using a helper 
    109109 
    110110  # run optimizer for each subdiameter  
     
    114114  for i in range(len(nb)): nb[i][-1] = nb[i][i] 
    115115  cf = [costFactory(i)     for i in range(start,end+1)] 
    116   cf = [func_pickle(i)     for i in cf] 
    117   cn = [cost.name          for cost in cf] 
     116 #cf = [func_pickle(i)     for i in cf] 
     117 #cn = [cost.name          for cost in cf] 
    118118  nnodes = len(lb) 
    119119 
    120120  #construct cost function and run optimizer 
    121   results = Pool(nnodes).map(optimize, cn,lb,ub,nb) 
     121  results = Pool(nnodes).map(optimize, cf,lb,ub,nb) 
    122122  #print "results = %s" % results 
    123123 
  • branches/UQ/math/examples/pool_helper.py

    r676 r678  
    2828  convergence_tol = 1e-4 
    2929 
    30   def func_unpickle(filename): 
    31     """ standard pickle.load of function from a File """ 
    32     import dill as pickle 
    33     return pickle.load(open(filename,'r')) 
     30 #def func_unpickle(filename): 
     31 #  """ standard pickle.load of function from a File """ 
     32 #  import dill as pickle 
     33 #  return pickle.load(open(filename,'r')) 
    3434 
    3535 #stepmon = VerboseMonitor(100) 
     
    4747 
    4848  tol = convergence_tol 
    49   cost = func_unpickle(cost)  #XXX: regenerate cost function from file 
     49 #cost = func_unpickle(cost)  #XXX: regenerate cost function from file 
    5050  solver.Solve(cost, termination=NCOG(tol)) 
    5151 
Note: See TracChangeset for help on using the changeset viewer.