-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
144 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from abc import ABC, abstractmethod | ||
|
||
|
||
class SpsStrategy(ABC): | ||
|
||
def __init__(self, algorithm_instance): | ||
self.algorithm = algorithm_instance | ||
|
||
@abstractmethod | ||
def get_sub_problems(self): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from moead_framework.core.sps_strategy.abstract_sps import SpsStrategy | ||
|
||
|
||
class SpsAllSubproblems(SpsStrategy): | ||
""" | ||
It is the classic SPS Strategy of MOEA/D, we visit all sub-problems at each generation | ||
""" | ||
def get_sub_problems(self): | ||
return range(self.algorithm.number_of_weight) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import random | ||
|
||
from moead_framework.core.sps_strategy.abstract_sps import SpsStrategy | ||
|
||
|
||
class SpsDra(SpsStrategy): | ||
""" | ||
Q. Zhang, W. Liu and H. Li, | ||
"The performance of a new version of MOEA/D on CEC09 unconstrained MOP test instances" | ||
2009 IEEE Congress on Evolutionary Computation | ||
Trondheim, 2009, pp. 203-208 | ||
doi: 10.1109/CEC.2009.4982949. | ||
""" | ||
def get_sub_problems(self): | ||
""" | ||
Select at first the indexes of the sub problems whose objectives are MOP | ||
individual objectives fi ([1, 0] and [0, 1] for example) | ||
and add sub problems by a 10-tournament | ||
:return: | ||
""" | ||
selection = [] | ||
|
||
for w in range(self.algorithm.number_of_weight): | ||
count_zero = 0 | ||
for o in self.algorithm.weights[w]: | ||
if o == 0: | ||
count_zero += 1 | ||
|
||
if count_zero == self.algorithm.number_of_objective - 1: | ||
selection.append(w) | ||
break | ||
|
||
xtrem_index = self.get_xtrem_index() | ||
|
||
# 10-tournament | ||
for i in range(int((self.algorithm.number_of_weight / 5) - self.algorithm.number_of_objective)): | ||
range_list = list(range(self.algorithm.number_of_weight)) | ||
random_indexes = random.sample(list(set(range_list) - set(xtrem_index)), 10) | ||
|
||
best_index = random_indexes[0] | ||
best_pi = self.algorithm.pi[random_indexes[0]] | ||
for index in random_indexes: | ||
if self.algorithm.pi[index] > best_pi: | ||
best_index = index | ||
best_pi = self.algorithm.pi[index] | ||
|
||
selection.append(best_index) | ||
|
||
return selection | ||
|
||
def get_xtrem_index(self): | ||
xtrem_index = [] | ||
for i in range(self.algorithm.number_of_weight): | ||
weight = self.algorithm.weights[i] | ||
for j in range(self.algorithm.number_of_objective): | ||
if weight[j] == 1: | ||
xtrem_index.append(i) | ||
break | ||
|
||
return xtrem_index |
36 changes: 36 additions & 0 deletions
36
moead_framework/core/sps_strategy/sps_random_and_boundaries.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import random | ||
|
||
from moead_framework.core.sps_strategy.abstract_sps import SpsStrategy | ||
|
||
|
||
class SpsRandomAndBoundaries(SpsStrategy): | ||
""" | ||
Pruvost, Geoffrey, et al. | ||
"On the Combined Impact of Population Size and Sub-problem Selection in MOEA/D." | ||
European Conference on Evolutionary Computation in Combinatorial Optimization (Part of EvoStar). | ||
Springer, Cham, 2020 | ||
""" | ||
def get_sub_problems(self): | ||
""" | ||
Select one random sub problems in each cluster | ||
:return: an array of sub problems | ||
""" | ||
range_list = list(range(self.algorithm.number_of_weight)) | ||
xtrem_index = self.get_xtrem_index() | ||
random_indexes = random.sample(list(set(range_list) - set(xtrem_index)), self.algorithm.number_of_subproblem) | ||
|
||
random_indexes = random_indexes + xtrem_index | ||
random.shuffle(random_indexes) | ||
|
||
return random_indexes | ||
|
||
def get_xtrem_index(self): | ||
xtrem_index = [] | ||
for i in range(self.algorithm.number_of_weight): | ||
weight = self.algorithm.weights[i] | ||
for j in range(self.algorithm.number_of_objective): | ||
if weight[j] == 1: | ||
xtrem_index.append(i) | ||
break | ||
|
||
return xtrem_index |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters