-
Notifications
You must be signed in to change notification settings - Fork 8
/
example_rmnk_moead.py
58 lines (48 loc) · 2.23 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
52
53
54
55
56
57
58
from moead_framework.aggregation import Tchebycheff
from moead_framework.algorithm.combinatorial import Moead
from moead_framework.problem.combinatorial import Rmnk
from moead_framework.tool.result import save_population
###############################
# Initialize the problem #
###############################
# The file is available here : https://github.com/moead-framework/data/blob/master/problem/RMNK/Instances/rmnk_0_2_100_1_0.dat
# Others instances are available here : https://github.com/moead-framework/data/tree/master/problem/RMNK/Instances
instance_file = "moead_framework/test/data/instances/rmnk_0_2_100_1_0.dat"
rmnk = Rmnk(instance_file=instance_file)
#####################################
# Initialize the algorithm #
#####################################
number_of_weight = 10
number_of_weight_neighborhood = 2
number_of_evaluations = 1000
# The file is available here : https://github.com/moead-framework/data/blob/master/weights/SOBOL-2objs-10wei.ws
# Others weights files are available here : https://github.com/moead-framework/data/tree/master/weights
weight_file = "moead_framework/test/data/weights/SOBOL-" + str(rmnk.number_of_objective) + "objs-" + str(number_of_weight) + "wei.ws"
###############################
# Execute the algorithm #
###############################
moead = Moead(problem=rmnk,
max_evaluation=number_of_evaluations,
number_of_weight_neighborhood=number_of_weight_neighborhood,
weight_file=weight_file,
aggregation_function=Tchebycheff,
)
population = moead.run()
###############################
# Save the result #
###############################
save_file = "moead-rmnk" + str(rmnk.number_of_objective) \
+ "-N" + str(number_of_weight) \
+ "-T" + str(number_of_weight_neighborhood) \
+ "-iter" + str(number_of_evaluations) \
+ ".txt"
save_population(save_file, population)
###############################
# Extract the Pareto set #
# and the Pareto front #
###############################
pareto_front = []
pareto_set = []
for solution_object in population:
pareto_front.append(solution_object.F)
pareto_set.append(solution_object.decision_vector)