Changeset 228
- Timestamp:
- 05/13/10 20:02:01 (6 years ago)
- Files:
-
- 5 deleted
- 2 edited
- 6 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/mpimystic/examples/Make.mm
r224 r228 24 24 #EXPORT_PYTHON_MODULES = \ 25 25 EXPORT_BINS = \ 26 ezmap_desolve.py \27 ezmap_desolve_rosen.py \28 chebyshev8.py \29 chebyshev8b.py \30 rosen.py \31 26 32 27 -
mystic/examples/Make.mm
r133 r228 40 40 example11.py \ 41 41 example12.py \ 42 ezmap_desolve.py \ 43 ezmap_desolve_rosen.py \ 42 44 forward_model.py \ 43 45 # gplot_test_ffit.py \ 44 46 ## metropolis.py \ 45 47 mpl_corana.py \ 48 raw_chebyshev8.py \ 49 raw_chebyshev8b.py \ 50 raw_rosen.py \ 46 51 rosetta_parabola.py \ 47 52 rosetta_mogi.py \ -
mystic/examples/ezmap_desolve.py
r224 r228 1 1 #!/usr/bin/env python 2 #Adapted from parallel_desolve.py by mmckerns@caltech.edu 2 3 3 """ 4 Adapted from parallel_desolve.py by mmckerns@caltech.edu 4 __doc__ = """ 5 # Tests MPI version of Storn and Price's Polynomial 'Fitting' Problem. 6 # 7 # Exact answer: Chebyshev Polynomial of the first kind. T8(x) 8 9 # Reference: 10 # 11 # [1] Storn, R. and Price, K. Differential Evolution - A Simple and Efficient 12 # Heuristic for Global Optimization over Continuous Spaces. Journal of Global 13 # Optimization 11: 341-359, 1997. 5 14 6 Tests MPI version of Storn and Price's Polynomial 'Fitting' Problem. 7 8 Exact answer: Chebyshev Polynomial of the first kind. T8(x) 9 10 Reference: 11 12 [1] Storn, R. and Price, K. Differential Evolution - A Simple and Efficient 13 Heuristic for Global Optimization over Continuous Spaces. Journal of Global 14 Optimization 11: 341-359, 1997. 15 # To run in parallel: (must install 'pyina') 16 mpipython.exe ezmap_desolve.py 15 17 """ 16 18 17 import pyina.launchers as launchers 19 try: 20 import pyina.launchers as launchers 21 from pyina.launchers import mpirun_launcher 22 from pyina.mappers import equalportion_mapper 23 from pyina.ez_map import ez_map2 as ez_map 24 except: 25 print __doc__ 18 26 19 doc = __doc__ + """20 27 21 %(launchers)s 22 """ % { 'file' : __file__, 'launchers' : launchers.getstr({'file':__file__, 'timelimit':'00:05'}) } 23 24 from mystic.differential_evolution import DifferentialEvolutionSolver2 as DESolve 25 from mpimystic.differential_evolution_ezmap import ezDESolver as pDESolve 26 from pyina.launchers import mpirun_launcher 27 from pyina.mappers import equalportion_mapper 28 from mystic.differential_evolution import DifferentialEvolutionSolver2 28 29 from mystic.termination import ChangeOverGeneration, VTR 29 30 from mystic.strategy import Best1Exp … … 31 32 from mystic.models.poly import poly1d 32 33 33 from chebyshev8 import chebyshev8cost as ChebyshevCost# no globals34 #from chebyshev8b import chebyshev8cost as ChebyshevCost# use globals34 from raw_chebyshev8 import chebyshev8cost as ChebyshevCost # no globals 35 #from raw_chebyshev8b import chebyshev8cost as ChebyshevCost # use globals 35 36 #from mystic.models.poly import chebyshev8cost as ChebyshevCost # no helper 36 37 … … 44 45 45 46 if __name__=='__main__': 46 import pyina47 pyina.ensure_mpi(doc)48 49 47 def print_solution(func): 50 48 print poly1d(func) … … 56 54 random_seed(seed) 57 55 print "first sequential..." 58 solver = D ESolve(ND,NP) #XXX: sequential DESolver56 solver = DifferentialEvolutionSolver2(ND,NP) #XXX: sequential 59 57 solver.SetRandomInitialPoints(min=[-100.0]*ND, max=[100.0]*ND) 60 58 solver.SetEvaluationLimits(maxiter=MAX_GENERATIONS) … … 68 66 random_seed(seed) 69 67 print "\n and now parallel..." 70 solver = pDESolve(ND,NP) #XXX: parallel DESolver71 solver .SetMapper(equalportion_mapper)72 solver .SetLauncher(mpirun_launcher, NNODES)73 solver .SetRandomInitialPoints(min=[-100.0]*ND, max=[100.0]*ND)74 solver .SetEvaluationLimits(maxiter=MAX_GENERATIONS)75 solver .Solve(ChebyshevCost, VTR(0.01), strategy=Best1Exp, \76 StepMonitor=psow, CrossProbability=1.0, ScalingFactor=0.9, \77 disp=1)68 solver2 = DifferentialEvolutionSolver2(ND,NP) #XXX: parallel 69 solver2.SetMapper(ez_map, equalportion_mapper) 70 solver2.SetLauncher(mpirun_launcher, NNODES) 71 solver2.SetRandomInitialPoints(min=[-100.0]*ND, max=[100.0]*ND) 72 solver2.SetEvaluationLimits(maxiter=MAX_GENERATIONS) 73 solver2.Solve(ChebyshevCost, VTR(0.01), strategy=Best1Exp, \ 74 StepMonitor=psow, CrossProbability=1.0, ScalingFactor=0.9, \ 75 disp=1) 78 76 print "" 79 print_solution( solver .Solution() )77 print_solution( solver2.Solution() ) 80 78 #''' 81 79 -
mystic/examples/ezmap_desolve_rosen.py
r224 r228 1 1 #!/usr/bin/env python 2 #Adapted from parallel_desolve.py by mmckerns@caltech.edu 2 3 3 """ 4 Adapted from parallel_desolve.py by mmckerns@caltech.edu 4 __doc__ = """ 5 # Tests MPI version of Storn and Price's Polynomial 'Fitting' Problem. 6 # 7 # Exact answer: [1,1,1] 8 9 # Reference: 10 # 11 # [1] Storn, R. and Price, K. Differential Evolution - A Simple and Efficient 12 # Heuristic for Global Optimization over Continuous Spaces. Journal of Global 13 # Optimization 11: 341-359, 1997. 5 14 6 Tests MPI version of Storn and Price's Polynomial 'Fitting' Problem. 7 8 Exact answer: [1,1,1] 9 10 Reference: 11 12 [1] Storn, R. and Price, K. Differential Evolution - A Simple and Efficient 13 Heuristic for Global Optimization over Continuous Spaces. Journal of Global 14 Optimization 11: 341-359, 1997. 15 # To run in parallel: (must install 'pyina') 16 mpipython.exe ezmap_desolve_rosen.py 15 17 """ 16 18 17 import pyina.launchers as launchers 19 try: 20 import pyina.launchers as launchers 21 from pyina.launchers import mpirun_launcher 22 from pyina.mappers import equalportion_mapper 23 from pyina.ez_map import ez_map2 as ez_map 24 except: 25 print __doc__ 18 26 19 doc = __doc__ + """20 27 21 %(launchers)s 22 """ % { 'file' : __file__, 'launchers' : launchers.getstr({'file':__file__, 'timelimit':'00:05'}) } 23 24 from mystic.differential_evolution import DifferentialEvolutionSolver2 as DESolve 25 from mpimystic.differential_evolution_ezmap import ezDESolver as pDESolve 26 from pyina.launchers import mpirun_launcher 27 from pyina.mappers import equalportion_mapper 28 from mystic.differential_evolution import DifferentialEvolutionSolver2 28 29 from mystic.termination import ChangeOverGeneration, VTR 29 30 from mystic.strategy import Best1Exp 30 31 from mystic.tools import VerboseSow, random_seed 31 32 32 #from r osen import rosen as myCost# ez_map needs a helper function33 #from raw_rosen import rosen as myCost # ez_map needs a helper function 33 34 from mystic.models import rosen as myCost # ez_map2 doesn't require help 34 35 … … 45 46 46 47 if __name__=='__main__': 47 import pyina48 pyina.ensure_mpi(doc)49 50 48 def print_solution(func): 51 49 print func … … 57 55 random_seed(seed) 58 56 print "first sequential..." 59 solver = D ESolve(ND,NP) #XXX: sequential DESolver57 solver = DifferentialEvolutionSolver2(ND,NP) #XXX: sequential 60 58 solver.SetRandomInitialPoints(min=[-100.0]*ND, max=[100.0]*ND) 61 59 solver.SetEvaluationLimits(maxiter=MAX_GENERATIONS) … … 68 66 random_seed(seed) 69 67 print "\n and now parallel..." 70 solver = pDESolve(ND,NP) #XXX: parallel DESolver71 solver .SetMapper(equalportion_mapper)72 solver .SetLauncher(mpirun_launcher, NNODES)73 solver .SetRandomInitialPoints(min=[-100.0]*ND, max=[100.0]*ND)74 solver .SetEvaluationLimits(maxiter=MAX_GENERATIONS)75 solver .Solve(myCost, VTR(TOL), strategy=Best1Exp, \68 solver2 = DifferentialEvolutionSolver2(ND,NP) #XXX: parallel 69 solver2.SetMapper(ez_map, equalportion_mapper) 70 solver2.SetLauncher(mpirun_launcher, NNODES) 71 solver2.SetRandomInitialPoints(min=[-100.0]*ND, max=[100.0]*ND) 72 solver2.SetEvaluationLimits(maxiter=MAX_GENERATIONS) 73 solver2.Solve(myCost, VTR(TOL), strategy=Best1Exp, \ 76 74 StepMonitor=psow, CrossProbability=CROSS, ScalingFactor=SCALE, \ 77 75 disp=1) 78 76 print "" 79 print_solution( solver .Solution() )77 print_solution( solver2.Solution() ) 80 78 81 79 # end of file
Note: See TracChangeset
for help on using the changeset viewer.