- Timestamp:
- 06/03/13 19:30:49 (3 years ago)
- Location:
- branches/UQ/math
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/UQ/math/examples/MM_surrogate_diam.py
r486 r675 60 60 ####################################################################### 61 61 def optimize(cost,lb,ub): 62 from pathos.m p_map import mp_map62 from pathos.multiprocessing import ProcessingPool as Pool 63 63 from mystic.solvers import DifferentialEvolutionSolver2 64 64 from mystic.termination import CandidateRelativeTolerance as CRT … … 81 81 solver.SetEvaluationMonitor(evalmon) 82 82 solver.SetGenerationMonitor(stepmon) 83 solver.SetMapper( mp_map)83 solver.SetMapper(Pool().map) 84 84 85 85 tol = convergence_tol -
branches/UQ/math/examples/MPI2_surrogate_diam_batchgrid.py
r465 r675 61 61 def optimize(cost,lower,upper,nbins): 62 62 from mystic.tools import random_seed 63 from pyina.ez_map import ez_map2 as map 64 from pyina.launchers import mpirun_launcher 63 from pyina.launchers import Mpi as Pool 65 64 random_seed(123) 66 65 … … 83 82 84 83 # map:: params, energy, func_evals = local_optimize(cost,x0,lb,ub) 85 results = map(local_optimize, cf, initial_values, lb, ub, \ 86 nnodes=nnodes, launcher=mpirun_launcher) 84 results = Pool(nnodes).map(local_optimize, cf, initial_values, lb, ub) 87 85 #print "results = %s" % results 88 86 … … 106 104 ####################################################################### 107 105 def UQ(start,end,lower,upper): 108 from pyina.ez_map import ez_map2 as map 109 from pyina.launchers import mpirun_launcher 106 from pyina.launchers import Mpi as Pool 110 107 from MPI2_helper import func_pickle 111 108 … … 122 119 #construct cost function and run optimizer 123 120 #subdiameter, func_evals = optimize(cost.name,lb,ub) #XXX: no init_condition 124 results = map(optimize, cn,lb,ub,nb, nnodes=nnodes, launcher=mpirun_launcher)121 results = Pool(nnodes).map(optimize, cn,lb,ub,nb) 125 122 #print "results = %s" % results 126 123 -
branches/UQ/math/examples/MPI_surrogate_diam.py
r471 r675 13 13 crossover = 0.9 14 14 percent_change = 0.9 15 16 # MPI config17 nnodes = 4 # = npop18 15 19 16 … … 63 60 ####################################################################### 64 61 def optimize(cost,lb,ub): 65 from pyina.ez_map import ez_map2 as ez_map 66 from pyina.launchers import mpirun_launcher 67 from pyina.mappers import equalportion_mapper 62 from pyina.launchers import Mpi as Pool 68 63 from mystic.solvers import DifferentialEvolutionSolver2 69 64 from mystic.termination import CandidateRelativeTolerance as CRT … … 81 76 82 77 solver = DifferentialEvolutionSolver2(ndim,npop) 83 solver.SetMapper(ez_map, equalportion_mapper)84 solver.SetLauncher(mpirun_launcher, nnodes)85 78 solver.SetRandomInitialPoints(min=lb,max=ub) 86 79 solver.SetStrictRanges(min=lb,max=ub) … … 88 81 solver.SetEvaluationMonitor(evalmon) 89 82 solver.SetGenerationMonitor(stepmon) 83 solver.SetMapper(Pool().map) 90 84 91 85 tol = convergence_tol -
branches/UQ/math/examples/MPI_surrogate_diam_batchgrid.py
r471 r675 153 153 def optimize(cost,lower,upper): 154 154 from mystic.tools import random_seed 155 from pyina.ez_map import ez_map2 as map 156 from pyina.launchers import mpirun_launcher 155 from pyina.launchers import Mpi as Pool 157 156 random_seed(123) 158 157 … … 172 171 cf = [cost for i in range(len(initial_values))] 173 172 # map:: params, energy, func_evals = local_optimize(cost,x0,lb,ub) 174 results = map(local_optimize, cf, initial_values, lb, ub, \ 175 nnodes=nnodes, launcher=mpirun_launcher) 173 results = Pool(nnodes).map(local_optimize, cf, initial_values, lb, ub) 176 174 #print "results = %s" % results 177 175 -
branches/UQ/math/examples/MPI_surrogate_diam_scatter.py
r471 r675 136 136 def optimize(cost,lower,upper): 137 137 from mystic.tools import random_seed 138 from pyina.ez_map import ez_map2 as map 139 from pyina.launchers import mpirun_launcher 138 from pyina.launchers import Mpi as Pool 140 139 random_seed(123) 141 140 … … 148 147 cf = [cost for i in range(len(initial_values))] 149 148 # map:: params, energy, func_evals = local_optimize(cost,x0,lb,ub) 150 results = map(local_optimize, cf, initial_values, lb, ub, \ 151 nnodes=nnodes, launcher=mpirun_launcher) 149 results = Pool(nnodes).map(local_optimize, cf, initial_values, lb, ub) 152 150 #print "results = %s" % results 153 151 -
branches/UQ/math/examples/MSUB_surrogate_diam_batchgrid.py
r471 r675 157 157 def optimize(cost,lower,upper): 158 158 from mystic.tools import random_seed 159 from pyina.ez_map import ez_map2 as map 160 from pyina.launchers import srun_launcher 161 from pyina.schedulers import moab_scheduler 159 from pyina.launchers import MoabSlurm as Pool 162 160 random_seed(123) 163 161 … … 177 175 cf = [cost for i in range(len(initial_values))] 178 176 # map:: params, energy, func_evals = local_optimize(cost,x0,lb,ub) 179 results = map(local_optimize, cf, initial_values, lb, ub, \ 180 launcher=srun_launcher, scheduler=moab_scheduler, \ 181 nnodes=nnodes, queue=queue, timelimit=timelimit) 177 config = {'queue':queue, 'timelimit':timelimit} 178 results = Pool(nnodes, **config).map(local_optimize,cf,initial_values,lb,ub) 182 179 #print "results = %s" % results 183 180 -
branches/UQ/math/examples/QSUB2_surrogate_diam_batchgrid.py
r465 r675 61 61 def optimize(cost,lower,upper): 62 62 from mystic.tools import random_seed 63 from pyina.ez_map import ez_map2 as map 64 from pyina.launchers import mpirun_launcher 65 from pyina.schedulers import torque_scheduler 63 from pyina.launchers import TorqueMpi as Pool 66 64 random_seed(123) 67 65 … … 83 81 cf = [cost for i in range(len(initial_values))] 84 82 # map:: params, energy, func_evals = local_optimize(cost,x0,lb,ub) 85 results = map(local_optimize, cf, initial_values, lb, ub, \ 86 launcher=mpirun_launcher, scheduler=torque_scheduler, \ 87 nnodes=nnodes, queue=queue, timelimit=timelimit) 83 config = {'queue':queue, 'timelimit':timelimit} 84 results = Pool(nnodes, **config).map(local_optimize,cf,initial_values,lb,ub) 88 85 #print "results = %s" % results 89 86 … … 107 104 ####################################################################### 108 105 def UQ(start,end,lower,upper): 109 from pyina.ez_map import ez_map2 as map 110 from pyina.launchers import mpirun_launcher 106 from pyina.launchers import Mpi as Pool 111 107 from MPI2_helper import func_pickle 112 108 … … 123 119 #construct cost function and run optimizer 124 120 #subdiameter, func_evals = optimize(cost.name,lb,ub) #XXX: no init_condition 125 results = map(optimize, cn,lb,ub,nb, nnodes=nnodes, launcher=mpirun_launcher)121 results = Pool(nnodes).map(optimize, cn,lb,ub,nb) 126 122 #print "results = %s" % results 127 123 -
branches/UQ/math/examples/QSUB_surrogate_diam_batchgrid.py
r471 r675 157 157 def optimize(cost,lower,upper): 158 158 from mystic.tools import random_seed 159 from pyina.ez_map import ez_map2 as map 160 from pyina.launchers import mpirun_launcher 161 from pyina.schedulers import torque_scheduler 159 from pyina.launchers import TorqueMpi as Pool 162 160 random_seed(123) 163 161 … … 177 175 cf = [cost for i in range(len(initial_values))] 178 176 # map:: params, energy, func_evals = local_optimize(cost,x0,lb,ub) 179 results = map(local_optimize, cf, initial_values, lb, ub, \ 180 launcher=mpirun_launcher, scheduler=torque_scheduler, \ 181 nnodes=nnodes, queue=queue, timelimit=timelimit) 177 config = {'queue':queue, 'timelimit':timelimit} 178 results = Pool(nnodes, **config).map(local_optimize,cf,initial_values,lb,ub) 182 179 #print "results = %s" % results 183 180 -
branches/UQ/math/legacy/MM_OUQ_StAlData.py
r585 r675 31 31 ####################################################################### 32 32 def optimize(cost,_bounds,_constraints): 33 from pathos.m p_map import mp_map33 from pathos.multiprocessing import ProcessingPool as Pool 34 34 from mystic.solvers import DifferentialEvolutionSolver2 35 35 from mystic.termination import ChangeOverGeneration as COG … … 54 54 solver.SetGenerationMonitor(stepmon) 55 55 solver.SetConstraints(_constraints) 56 solver.SetMapper( mp_map)56 solver.SetMapper(Pool().map) 57 57 58 58 tol = convergence_tol -
branches/UQ/math/legacy/envelope/Driver_BoLiSurr_Cy.py
r592 r675 38 38 # with multiprocessing 39 39 ##nodes = 7 #len(runs) 40 ##from pathos.m p_map import mp_map as map # multiprocessing41 ##results = map(looper, runs, nproc=nodes)40 ##from pathos.multiprocessing import ProcessingPool as Pool 41 ##results = Pool(nodes).map(looper, runs) 42 42 # with MPI 43 43 # nodes = 7 #len(runs) 44 # from pyina. ez_map import ez_map2 as map # mpi4py45 # results = map(looper, runs, nnodes=nodes)44 # from pyina.launchers import Mpi as Pool 45 # results = Pool(nodes).map(looper, runs) 46 46 # with MPI on a cluster 47 from pyina.ez_map import ez_map2 as map # mpi4py 48 from pyina.launchers import mpirun_launcher, torque_launcher 49 from pyina.mappers import carddealer_mapper, equalportion_mapper 50 from pyina.schedulers import torque_scheduler 51 results = map(looper, runs, nnodes=nodes, queue=queue, timelimit=timelimit, \ 52 launcher=mpirun_launcher, scheduler=torque_scheduler) 47 from pyina.launchers import TorqueMpi as Pool 48 config = {'queue':queue, 'timelimit':timelimit} 49 results = Pool(nodes, **config).map(looper, runs) 53 50 54 51 -
branches/UQ/math/legacy/envelope/Looper_BoLiSurr_Cy.py
r621 r675 71 71 solver.SetConstraints(_constraints) 72 72 #ALTERNATE: multiprocessing map of cost function 73 ##from pathos.m p_map import mp_map as map # multiprocessing74 ##solver.SetMapper( map)73 ##from pathos.multiprocessing import ProcessingPool as Pool 74 ##solver.SetMapper(Pool().map) 75 75 #ALTERNATE: MPI map of cost function 76 ##from pyina.ez_map import ez_map2 as map # mpi4py 77 ##from pyina.launchers import mpirun_launcher, torque_launcher 78 ##from pyina.mappers import carddealer_mapper, equalportion_mapper 79 ##from pyina.schedulers import torque_scheduler 80 ##solver.SetMapper(map, equalportion_mapper) 81 ##solver.SetLauncher(mpirun_launcher, nodes) 82 ##solver.SelectScheduler(torque_scheduler, queue, timelimit) 76 ##from pyina.launchers import Mpi as Pool 77 ##solver.SetMapper(Pool(nodes).map) 78 ##from pyina.launchers import TorqueMpi as Pool 79 ##config = {'queue':queue, 'timelimit':timelimit} 80 ##solver.SetMapper(Pool(nodes, **config).map) 83 81 tol = convergence_tol 84 82 solver.Solve(cost,termination=COG(tol,ngen),strategy=Best1Exp, \ … … 381 379 # with multiprocessing 382 380 ##nodes = 7 #len(runs) 383 ##from pathos.m p_map import mp_map as map # multiprocessing384 ##results = map(looper, runs, nproc=nodes)381 ##from pathos.multiprocessing import ProcessingPool as Pool 382 ##results = Pool(nodes).map(looper, runs) 385 383 386 384 -
branches/UQ/math/legacy/envelope/envelope.py
r601 r675 230 230 # results = np_map(model_sausage, runs) 231 231 # with multiprocessing 232 # from pathos.mp_map import mp_map as map # multiprocessing 233 # results = map(model_sausage, runs)#, nproc=nodes) 232 # nodes = 4 #len(runs) 233 # from pathos.multiprocessing import ProcessingPool as Pool 234 # results = Pool(nodes).map(model_sausage, runs) 234 235 # with MPI 235 236 # nodes = 4 #len(runs) 236 # from pyina. ez_map import ez_map2 as map # mpi4py237 # results = map(model_sausage, runs, nnodes=nodes)237 # from pyina.launchers import Mpi as Pool 238 # results = Pool(nodes).map(model_sausage, runs) 238 239 # with MPI on a cluster 239 240 # nodes = '25:ppn=2' 240 241 # queue = 'weekdayQ' 241 242 # timelimit = '11:59:59' 242 # from pyina.ez_map import ez_map2 as map # mpi4py 243 # from pyina.launchers import mpirun_launcher, torque_launcher 244 # from pyina.mappers import carddealer_mapper, equalportion_mapper 245 # from pyina.schedulers import torque_scheduler 246 # results = map(model_sausage, runs, nnodes=nodes, queue=queue, \ 247 # timelimit=timelimit, launcher=mpirun_launcher, \ 248 # scheduler=torque_scheduler) 243 from pyina.launchers import TorqueMpi as Pool 244 config = {'queue':queue, 'timelimit':timelimit} 245 results = Pool(nodes, **config).map(model_sausage, runs) 249 246 250 247 if verbose: print "yl yo yu:\n", asarray(results)
Note: See TracChangeset
for help on using the changeset viewer.