-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample_rmnk_moead.py
52 lines (40 loc) · 1.69 KB
/
example_rmnk_moead.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
49
50
51
from moead_framework.aggregation.tchebycheff import Tchebycheff
from moead_framework.algorithm.combinatorial.moead import Moead
from moead_framework.problem.combinatorial.rmnk import Rmnk
from moead_framework.tool.result import save_population
###############################
# Init the problem #
###############################
instance_file = "rmnk_0_2_100_1_0.dat"
rmnk = Rmnk(instance_file=instance_file)
###############################
# Init the algorithm #
###############################
number_of_objective = rmnk.function_numbers
number_of_weight = 10
number_of_weight_neighborhood = 20
number_of_crossover_points = 4
number_of_evaluations = 1000
weight_file = "SOBOL-" + str(number_of_objective) + "objs-" + str(number_of_weight) + "wei.ws"
###############################
# Execute the algorithm #
###############################
moead = Moead(problem=rmnk,
max_evaluation = number_of_evaluations,
number_of_objective=number_of_objective,
number_of_weight=number_of_weight,
number_of_weight_neighborhood=number_of_weight_neighborhood,
number_of_crossover_points=number_of_crossover_points,
weight_file=weight_file,
)
population = moead.run(g=Tchebycheff())
###############################
# Save the result #
###############################
save_file = "moead-rmnk" + str(number_of_objective) \
+ "-N" + str(number_of_weight) \
+ "-T" + str(number_of_weight_neighborhood) \
+ "-CP" + str(number_of_crossover_points) \
+ "-iter" + str(number_of_evaluations) \
+ ".txt"
save_population(save_file, population)