- Timestamp:
- 06/05/13 07:02:44 (3 years ago)
- 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 61 61 def optimize(cost,lower,upper,nbins): 62 62 from mystic.tools import random_seed 63 from p yina.launchers import Mpias Pool63 from pathos.multiprocessing import ProcessingPool as Pool 64 64 random_seed(123) 65 65 … … 72 72 73 73 # build a grid of starting points 74 from MPI2_helper import local_optimize74 from pool_helper import local_optimize 75 75 from mystic.math.grid import gridpts 76 76 initial_values = gridpts(bins) … … 105 105 ####################################################################### 106 106 def UQ(start,end,lower,upper): 107 from p yina.launchers import Mpias Pool108 from MPI2_helper import func_pickle107 from pathos.multiprocessing import ProcessingPool as Pool 108 #from pool_helper import func_pickle # if fails to pickle, try using a helper 109 109 110 110 # run optimizer for each subdiameter … … 114 114 for i in range(len(nb)): nb[i][-1] = nb[i][i] 115 115 cf = [costFactory(i) for i in range(start,end+1)] 116 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] 118 118 nnodes = len(lb) 119 119 120 120 #construct cost function and run optimizer 121 results = Pool(nnodes).map(optimize, c n,lb,ub,nb)121 results = Pool(nnodes).map(optimize, cf,lb,ub,nb) 122 122 #print "results = %s" % results 123 123 -
branches/UQ/math/examples/MPI2_surrogate_diam_batchgrid.py
r677 r678 72 72 73 73 # build a grid of starting points 74 from MPI2_helper import local_optimize74 from pool_helper import local_optimize 75 75 from mystic.math.grid import gridpts 76 76 initial_values = gridpts(bins) … … 105 105 ####################################################################### 106 106 def 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 109 110 110 111 # run optimizer for each subdiameter … … 114 115 for i in range(len(nb)): nb[i][-1] = nb[i][i] 115 116 cf = [costFactory(i) for i in range(start,end+1)] 116 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] 118 119 nnodes = len(lb) 119 120 120 121 #construct cost function and run optimizer 121 results = Pool(nnodes).map(optimize, c n,lb,ub,nb)122 results = Pool(nnodes).map(optimize, cf,lb,ub,nb) 122 123 #print "results = %s" % results 123 124 -
branches/UQ/math/examples/QSUB2_surrogate_diam_batchgrid.py
r677 r678 73 73 # build a grid of starting points 74 74 from mystic.math.grid import gridpts 75 from MPI2_helper import local_optimize76 from MPI2_helper import nnodes, queue, timelimit75 from pool_helper import local_optimize 76 from pool_helper import nnodes, queue, timelimit 77 77 initial_values = gridpts(bins) 78 78 … … 106 106 def UQ(start,end,lower,upper): 107 107 from pyina.launchers import Mpi as Pool 108 from MPI2_helper import func_pickle108 #from pool_helper import func_pickle # if fails to pickle, try using a helper 109 109 110 110 # run optimizer for each subdiameter … … 114 114 for i in range(len(nb)): nb[i][-1] = nb[i][i] 115 115 cf = [costFactory(i) for i in range(start,end+1)] 116 117 116 #cf = [func_pickle(i) for i in cf] 117 #cn = [cost.name for cost in cf] 118 118 nnodes = len(lb) 119 119 120 120 #construct cost function and run optimizer 121 results = Pool(nnodes).map(optimize, c n,lb,ub,nb)121 results = Pool(nnodes).map(optimize, cf,lb,ub,nb) 122 122 #print "results = %s" % results 123 123 -
branches/UQ/math/examples/pool_helper.py
r676 r678 28 28 convergence_tol = 1e-4 29 29 30 31 32 33 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')) 34 34 35 35 #stepmon = VerboseMonitor(100) … … 47 47 48 48 tol = convergence_tol 49 49 #cost = func_unpickle(cost) #XXX: regenerate cost function from file 50 50 solver.Solve(cost, termination=NCOG(tol)) 51 51
Note: See TracChangeset
for help on using the changeset viewer.