Changeset 675 for branches


Ignore:
Timestamp:
06/03/13 19:30:49 (3 years ago)
Author:
mmckerns
Message:

updated UQ branch to use new pathos/pyina Pools

Location:
branches/UQ/math
Files:
12 edited

Legend:

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

    r486 r675  
    6060####################################################################### 
    6161def optimize(cost,lb,ub): 
    62   from pathos.mp_map import mp_map 
     62  from pathos.multiprocessing import ProcessingPool as Pool 
    6363  from mystic.solvers import DifferentialEvolutionSolver2 
    6464  from mystic.termination import CandidateRelativeTolerance as CRT 
     
    8181  solver.SetEvaluationMonitor(evalmon) 
    8282  solver.SetGenerationMonitor(stepmon) 
    83   solver.SetMapper(mp_map) 
     83  solver.SetMapper(Pool().map) 
    8484 
    8585  tol = convergence_tol 
  • branches/UQ/math/examples/MPI2_surrogate_diam_batchgrid.py

    r465 r675  
    6161def optimize(cost,lower,upper,nbins): 
    6262  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 
    6564  random_seed(123) 
    6665 
     
    8382 
    8483  # 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) 
    8785  #print "results = %s" % results 
    8886 
     
    106104####################################################################### 
    107105def 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 
    110107  from MPI2_helper import func_pickle 
    111108 
     
    122119  #construct cost function and run optimizer 
    123120  #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) 
    125122  #print "results = %s" % results 
    126123 
  • branches/UQ/math/examples/MPI_surrogate_diam.py

    r471 r675  
    1313crossover = 0.9 
    1414percent_change = 0.9 
    15  
    16 # MPI config 
    17 nnodes = 4   # = npop 
    1815 
    1916 
     
    6360####################################################################### 
    6461def 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 
    6863  from mystic.solvers import DifferentialEvolutionSolver2 
    6964  from mystic.termination import CandidateRelativeTolerance as CRT 
     
    8176 
    8277  solver = DifferentialEvolutionSolver2(ndim,npop) 
    83   solver.SetMapper(ez_map, equalportion_mapper) 
    84   solver.SetLauncher(mpirun_launcher, nnodes) 
    8578  solver.SetRandomInitialPoints(min=lb,max=ub) 
    8679  solver.SetStrictRanges(min=lb,max=ub) 
     
    8881  solver.SetEvaluationMonitor(evalmon) 
    8982  solver.SetGenerationMonitor(stepmon) 
     83  solver.SetMapper(Pool().map) 
    9084 
    9185  tol = convergence_tol 
  • branches/UQ/math/examples/MPI_surrogate_diam_batchgrid.py

    r471 r675  
    153153def optimize(cost,lower,upper): 
    154154  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 
    157156  random_seed(123) 
    158157 
     
    172171  cf = [cost for i in range(len(initial_values))] 
    173172  # 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) 
    176174  #print "results = %s" % results 
    177175 
  • branches/UQ/math/examples/MPI_surrogate_diam_scatter.py

    r471 r675  
    136136def optimize(cost,lower,upper): 
    137137  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 
    140139  random_seed(123) 
    141140 
     
    148147  cf = [cost for i in range(len(initial_values))] 
    149148  # 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) 
    152150  #print "results = %s" % results 
    153151 
  • branches/UQ/math/examples/MSUB_surrogate_diam_batchgrid.py

    r471 r675  
    157157def optimize(cost,lower,upper): 
    158158  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 
    162160  random_seed(123) 
    163161 
     
    177175  cf = [cost for i in range(len(initial_values))] 
    178176  # 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) 
    182179  #print "results = %s" % results 
    183180 
  • branches/UQ/math/examples/QSUB2_surrogate_diam_batchgrid.py

    r465 r675  
    6161def optimize(cost,lower,upper): 
    6262  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 
    6664  random_seed(123) 
    6765 
     
    8381  cf = [cost for i in range(len(initial_values))] 
    8482  # 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) 
    8885  #print "results = %s" % results 
    8986 
     
    107104####################################################################### 
    108105def 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 
    111107  from MPI2_helper import func_pickle 
    112108 
     
    123119  #construct cost function and run optimizer 
    124120  #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) 
    126122  #print "results = %s" % results 
    127123 
  • branches/UQ/math/examples/QSUB_surrogate_diam_batchgrid.py

    r471 r675  
    157157def optimize(cost,lower,upper): 
    158158  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 
    162160  random_seed(123) 
    163161 
     
    177175  cf = [cost for i in range(len(initial_values))] 
    178176  # 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) 
    182179  #print "results = %s" % results 
    183180 
  • branches/UQ/math/legacy/MM_OUQ_StAlData.py

    r585 r675  
    3131####################################################################### 
    3232def optimize(cost,_bounds,_constraints): 
    33   from pathos.mp_map import mp_map 
     33  from pathos.multiprocessing import ProcessingPool as Pool 
    3434  from mystic.solvers import DifferentialEvolutionSolver2 
    3535  from mystic.termination import ChangeOverGeneration as COG 
     
    5454  solver.SetGenerationMonitor(stepmon) 
    5555  solver.SetConstraints(_constraints) 
    56   solver.SetMapper(mp_map) 
     56  solver.SetMapper(Pool().map) 
    5757 
    5858  tol = convergence_tol 
  • branches/UQ/math/legacy/envelope/Driver_BoLiSurr_Cy.py

    r592 r675  
    3838  # with multiprocessing  
    3939##nodes = 7 #len(runs) 
    40 ##from pathos.mp_map import mp_map as map  # multiprocessing 
    41 ##results = map(looper, runs, nproc=nodes) 
     40##from pathos.multiprocessing import ProcessingPool as Pool 
     41##results = Pool(nodes).map(looper, runs) 
    4242  # with MPI 
    4343# nodes = 7 #len(runs) 
    44 # from pyina.ez_map import ez_map2 as map  # mpi4py 
    45 # results = map(looper, runs, nnodes=nodes) 
     44# from pyina.launchers import Mpi as Pool 
     45# results = Pool(nodes).map(looper, runs) 
    4646  # 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) 
    5350 
    5451 
  • branches/UQ/math/legacy/envelope/Looper_BoLiSurr_Cy.py

    r621 r675  
    7171  solver.SetConstraints(_constraints) 
    7272 #ALTERNATE: multiprocessing map of cost function 
    73 ##from pathos.mp_map import mp_map as map  # multiprocessing 
    74 ##solver.SetMapper(map) 
     73##from pathos.multiprocessing import ProcessingPool as Pool 
     74##solver.SetMapper(Pool().map) 
    7575 #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) 
    8381  tol = convergence_tol 
    8482  solver.Solve(cost,termination=COG(tol,ngen),strategy=Best1Exp, \ 
     
    381379  # with multiprocessing  
    382380##nodes = 7 #len(runs) 
    383 ##from pathos.mp_map import mp_map as map  # multiprocessing 
    384 ##results = map(looper, runs, nproc=nodes) 
     381##from pathos.multiprocessing import ProcessingPool as Pool 
     382##results = Pool(nodes).map(looper, runs) 
    385383 
    386384 
  • branches/UQ/math/legacy/envelope/envelope.py

    r601 r675  
    230230# results = np_map(model_sausage, runs) 
    231231  # 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) 
    234235  # with MPI 
    235236# nodes = 4 #len(runs) 
    236 # from pyina.ez_map import ez_map2 as map  # mpi4py 
    237 # results = map(model_sausage, runs, nnodes=nodes) 
     237# from pyina.launchers import Mpi as Pool 
     238# results = Pool(nodes).map(model_sausage, runs) 
    238239  # with MPI on a cluster 
    239240# nodes = '25:ppn=2' 
    240241# queue = 'weekdayQ' 
    241242# 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) 
    249246 
    250247  if verbose: print "yl yo yu:\n", asarray(results) 
Note: See TracChangeset for help on using the changeset viewer.