-
Notifications
You must be signed in to change notification settings - Fork 2
/
four_peaks_problem.py
48 lines (40 loc) · 2.15 KB
/
four_peaks_problem.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import numpy as np
from mlrose import mlrose
fitness = mlrose.FourPeaks(t_pct=0.1)
problem = mlrose.DiscreteOpt(length=100, fitness_fn=fitness, maximize=True, max_val=2)
rhc = mlrose.RHCRunner(problem=problem,
experiment_name="RCH_final",
output_directory="/Users/matthieudivet/Desktop/GaTech/Classes/ML/Assignments/Randomized_optimization/four_peaks_problem",
seed=None,
iteration_list=2 ** np.arange(24),
max_attempts=1000,
restart_list=[0])
rhc_run_stats, rhc_run_curves = rhc.run()
sa = mlrose.SARunner(problem=problem,
experiment_name="SA_final",
output_directory="/Users/matthieudivet/Desktop/GaTech/Classes/ML/Assignments/Randomized_optimization/four_peaks_problem",
seed=None,
iteration_list=2 ** np.arange(13),
max_attempts=1000,
temperature_list=[250],
decay_list=[mlrose.ExpDecay])
sa_run_stats, sa_run_curves = sa.run()
ga = mlrose.GARunner(problem=problem,
experiment_name="GA_final",
output_directory="/Users/matthieudivet/Desktop/GaTech/Classes/ML/Assignments/Randomized_optimization/four_peaks_problem",
seed=None,
iteration_list=2 ** np.arange(13),
max_attempts=1000,
population_sizes=[200],
mutation_rates=[0.3])
ga_run_stats, ga_run_curves = ga.run()
mimic = mlrose.MIMICRunner(problem=problem,
experiment_name="MIMIC_final",
output_directory="/Users/matthieudivet/Desktop/GaTech/Classes/ML/Assignments/Randomized_optimization/four_peaks_problem",
seed=None,
iteration_list=2 ** np.arange(13),
population_sizes=[200],
max_attempts=500,
keep_percent_list=[0.2],
use_fast_mimic=True)
mimic_run_stats, mimic_run_curves = mimic.run()