Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[joss-reviews#2974] Code duplication #18

Closed
chkoar opened this issue Feb 6, 2021 · 4 comments · Fixed by #67
Closed

[joss-reviews#2974] Code duplication #18

chkoar opened this issue Feb 6, 2021 · 4 comments · Fixed by #67
Assignees

Comments

@chkoar
Copy link
Contributor

chkoar commented Feb 6, 2021

Related: openjournals/joss-reviews#2974

If I am not mistaken, the following code blocks are exactly the same. Consider a refactoring.

numerical/moead.py (48–91)
combinatorial/moead.py (52–95)

@geoffreyp
Copy link
Contributor

Thank you!
Commit 2b55994

@chkoar
Copy link
Contributor Author

chkoar commented May 31, 2021

moead_framework/core/sps_strategy/sps_dra.py [54:68]:

    def get_xtrem_index(self):
        """
        get boundaries sub-problems

        :return: {list<integer>} indexes of sub-problems
        """
        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

moead_framework/core/sps_strategy/sps_random_and_boundaries.py [32:46]:

    def get_xtrem_index(self):
        """
        get boundaries sub-problems

        :return: {list<integer>} indexes of sub-problems
        """
        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

@chkoar
Copy link
Contributor Author

chkoar commented May 31, 2021

moead_framework/algorithm/abstract_moead.py [106:112]:

  self.update_current_sub_problem(sub_problem=i)
  self.mating_pool = self.mating_pool_selection(sub_problem=i)[:]
  y = self.generate_offspring(population=self.mating_pool)
  y = self.repair(solution=y)
  self.update_z(solution=y)
  self.update_solutions(solution=y, aggregation_function=self.aggregation_function, sub_problem=i)
  self.current_eval += 1

moead_framework/algorithm/combinatorial/moead_dra.py [72:78]:

  self.update_current_sub_problem(sub_problem=i)
  self.mating_pool = self.mating_pool_selection(sub_problem=i)[:]
  y = self.generate_offspring(population=self.mating_pool)
  y = self.repair(solution=y)
  self.update_z(solution=y)
  self.update_solutions(solution=y, aggregation_function=self.aggregation_function, sub_problem=i)
  self.current_eval += 1

@geoffreyp
Copy link
Contributor

Pull request #67

@geoffreyp geoffreyp assigned geoffreyp and chkoar and unassigned geoffreyp Jun 2, 2021
@geoffreyp geoffreyp linked a pull request Jun 2, 2021 that will close this issue
@chkoar chkoar closed this as completed Jun 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants