Parcourir la source

Update CONTRIBUTING file

Jérôme BUISINE il y a 3 ans
Parent
commit
5908f2fb87

+ 137 - 0
CONTRIBUTING

@@ -0,0 +1,137 @@
+How to contribute
+=====================================
+
+<p align="center">
+    <img src="https://github.com/jbuisine/macop/blob/master/docs/source/_static/logo_macop.png" alt="" width="40%">
+</p>
+
+
+
+# Welcome !
+
+Thank you for taking the time to read this guide for the package's contribution. I'm glad to know that you may bring a lot to the **Macop** package. This document will show you the good development practices used in the project and how you can easily participate in its evolution!
+
+# Table of contents
+
+1. [Submission processes](#submission-process)
+
+    1.2. [Submit an issue](#submit-an-issue)
+
+    1.1. [Pull request](#pull-request)
+
+2. [Coding conventions](#coding-conventions)
+
+    2.1. [Python conventions](#python-conventions)
+
+    2.2. [Code documentation](#code-documentation)
+
+    2.3. [Testing](#test-implementation)
+
+
+# Submission process
+
+## Submit an issue
+
+Do not hesitate to report bug or issue in [https://github.com/jbuisine/macop/issues](https://github.com/jbuisine/macop/issues) with the common template header:
+
+```
+**Package version:** X.X.X
+**Issue label:** XXXXX
+**Targeted modules:** `macop.algorithms`, `macop.policies`
+**Operating System:** Manjaro Linux
+
+**Description:** XXXXX
+```
+
+## Pull request
+
+If you have made changes to the project you have forked, you can submit a pull request in [https://github.com/jbuisine/macop/pulls](https://github.com/jbuisine/macop/pulls) in order to have your changes added inside new version of the `Macop` package. A [GitHub documentation](https://help.github.com/articles/about-pull-requests/) about pull requests is available if necessary.
+
+To enhance the package, do not hesitate to fix bug or missing feature. To do that, just submit your pull request with this common template header:
+
+```
+**Package version:** X.X.X
+**Enhancements label:** XXXXX
+**Targeted modules:** `macop.algorithms`, `macop.policies`
+**New modules:** `macop.XXXX`, `macop.algorithms.XXXX`
+
+**Description:** XXXXX
+```
+
+**Note:** the code conventions required for the approval of your changes are described below.
+
+Whatever the problem reported, I will thank you for your contribution to this project. So do not hesitate.
+
+
+# Coding conventions
+
+## Python conventions
+
+This project follows the [coding conventions](http://google.github.io/styleguide/pyguide.html) implemented by Google. To help you to format **\*.py** files, it is possible to use the [yapf](https://github.com/google/yapf/) Python package developed by Google.
+
+```
+yapf -ir -vv macop
+```
+
+**Note:** you need at least Python version >=3.7.0.
+
+## Package modules conventions
+
+As you perhaps already saw, package contains multiples modules and submodules. It's really import to be well organized package and let it intuitive to access as possible to features.
+
+`Macop` is mainly decompose into discrete and continuous optimisation. Especially if you want to offer continuous optimisation problems, modules are already available for this purpose. You can refer to the [documentation](https://jbuisine.github.io/macop) if necessary.
+
+In order to facilitate the integration of new modules, do not hesitate to let me know the name it could have beforehand in your pull request.
+
+## Code documentation
+
+In order to allow quick access to the code, the project follows the documentation conventions (docstring) proposed by Google. Here an example:
+
+```python
+''' Binary integer solution class
+
+    - store solution as a binary array (example: [0, 1, 0, 1, 1])
+    - associated size is the size of the array
+    - mainly use for selecting or not an element in a list of valuable objects
+
+    Attributes:
+       data: {ndarray} --  array of binary values
+       size: {int} -- size of binary array values
+       score: {float} -- fitness score value
+'''
+```
+
+You can generate documentation and display updates using these following commands:
+
+```
+bash build.sh
+firefox docs/build/index.html
+```
+
+## Test implementation
+
+This project uses the [doctest](https://docs.python.org/3/library/doctest.html) package which enables to write tests into documentation as shown in example below:
+
+```python
+""" Initialise binary solution using specific data
+
+    Args:
+        data: {ndarray} --  array of binary values
+        size: {int} -- size of binary array values
+
+    Example:
+
+    >>> from macop.solutions.discrete import BinarySolution
+    >>> # build of a solution using specific data and size
+    >>> data = [0, 1, 0, 1, 1]
+    >>> solution = BinarySolution(data, len(data))
+    >>> # check data content
+    >>> sum(solution._data) == 3
+    True
+    >>> # clone solution
+    >>> solution_copy = solution.clone()
+    >>> all(solution_copy._data == solution._data)
+"""
+```
+
+Moreover, tests written are displayed into generated documentation and show examples of how to use the developed features.

+ 0 - 176
CONTRIBUTING.md

@@ -1,176 +0,0 @@
-Contribution guidelines
-=====================================
-
-<p align="center">
-    Minimalist And Customisable Optimisation Package
-</p>
-
-
-# Welcome !
-
-Thank you for taking the time to read this guide for the package's contribution. I'm glad to know that you may bring a lot to the **Macop** package. This document will show you the good development practices used in the project and how you can easily participate in its evolution!
-
-# Table of contents
-
-1. [Naming conventions](#naming-conventions)
-
-    1.1. [Git naming conventions](#git-naming-conventions)
-
-    1.2. [Package modules conventions](#package-modules-conventions)
-
-2. [Coding conventions](#coding-conventions)
-
-    2.1. [Python conventions](#python-conventions)
-
-    2.3. [Code documentation](#code-documentation)
-
-    2.2. [Test implementation](#test-implementation)
-
-3. [Submission process](#submission-process)
-
-    3.1. [Build package](#build-package)
-
-    3.2. [Pull request](#pull-request)
-
-4. [Request an enhancement or report a bug](#request-an-enhancement-or-report-a-bug)
-
-# Naming conventions
-
-## Git naming conventions
-
-This project uses the naming conventions of the git branches set up by the [git-flow](https://danielkummer.github.io/git-flow-cheatsheet/) interface. To make your contribution as easy as possible to inject into the project, you will need to name your git branch as follows:
-
-```bash
-git branch feature/YourFeatureBranchName
-```
-
-Using git-flow interface:
-
-```bash
-git flow feature start YourFeatureBranchName
-```
-
-## Package modules conventions
-
-As you perhaps already saw, package contains multiples modules and submodules. It's really import to be well organized package and let it intuitive to access as possible to features.
-
-For the moment there are no precise conventions on the naming of new modules or sub-modules, it must just in a first step respect the hierarchy already in place and avoid any redundancies.
-
-In order to facilitate the integration of new modules, do not hesitate to let me know the name it could have beforehand.
-
-# Coding conventions
-
-## Python conventions
-
-This project follows the [coding conventions](http://google.github.io/styleguide/pyguide.html) implemented by Google. To help you to format **\*.py** files, it is possible to use the [yapf](https://github.com/google/yapf/) package developed by Google.
-
-Note that the **yapf** package is used during build process of **macop** package to format the whole code following these conventions.
-
-## Code documentation
-
-In order to allow quick access to the code, the project follows the documentation conventions (docstring) proposed by Google. Here an example:
-
-```python
-''' Binary integer solution class
-
-    - store solution as a binary array (example: [0, 1, 0, 1, 1])
-    - associated size is the size of the array
-    - mainly use for selecting or not an element in a list of valuable objects
-
-    Attributes:
-       data: {ndarray} --  array of binary values
-       size: {int} -- size of binary array values
-       score: {float} -- fitness score value
-'''
-```
-
-You can generate documentation and display updates using these following commands:
-
-```
-bash build.sh
-firefox docs/index.html
-```
-
-Do not forget to generate new documentation output before doing a pull request.
-
-## Test implementation
-
-This project use the [doctest](https://docs.python.org/3/library/doctest.html) package which enables to write tests into documentation as shown in example below:
-
-# TODO : add custom example
-```python
-""" Initialise binary solution using specific data
-
-    Args:
-        data: {ndarray} --  array of binary values
-        size: {int} -- size of binary array values
-
-    Example:
-
-    >>> from macop.solutions.discrete import BinarySolution
-    >>> # build of a solution using specific data and size
-    >>> data = [0, 1, 0, 1, 1]
-    >>> solution = BinarySolution(data, len(data))
-    >>> # check data content
-    >>> sum(solution._data) == 3
-    True
-    >>> # clone solution
-    >>> solution_copy = solution.clone()
-    >>> all(solution_copy._data == solution._data)
-"""
-```
-
-Moreover, tests written are displayed into generated documentation and let examples of how to use the developed function.
-
-# Submission process
-
-## Build pakcage
-
-One thing to do before submit your feature is to build the package:
-
-```bash
-python setup.py build
-```
-
-This command do a lot of thing for you:
-  - Runs the tests from documentation and raise errors if there are.
-  - Formats all **\*.py** inside *macop* folder using **yapf**.
-
-Do not forget to build documentation as explained in section [2.3](#code-documentation).
-
-Or directly use bash script which runs all you need:
-
-```bash
-bash build.sh
-```
-
-## Pull request
-
-Once you have built the package following previous instructions. You can make a pull request using GitHub. A [documentation](https://help.github.com/articles/about-pull-requests/) about pull requests is available.
-
-# Request an enhancement or report a bug
-
-To enhance the package, do not hesitate to report bug or missing feature. To do that, just submit an issue using at one of this labels:
-
-- **feature** or **idea**: for new an enhancement to develop
-- **bug:** for a detected bug
-
-You can also add your own labels too or add priority label:
-
-- prio:**low**
-- prio:**normal**
-- prio:**high**
-
-Main common required issue header:
-
-```
-Package version: X.X.X
-Issue label: XXXXX
-Priority: prio:**level**
-Targeted modules: `macop.algorithms`, `macop.policies`
-Operating System: Manjaro Linux
-
-Description: XXXXX
-```
-
-Whatever the problem reported, I will thank you for your contribution to this project. So do not hesitate.

+ 2 - 1
README.md

@@ -1,6 +1,7 @@
 # Minimalist And Customisable Optimisation Package
 
-![](https://img.shields.io/github/workflow/status/jbuisine/macop/build?style=flat-square) ![](https://img.shields.io/pypi/v/macop?style=flat-square) ![](https://img.shields.io/pypi/dm/macop?style=flat-square)
+[![status](https://joss.theoj.org/papers/9ea7d55c4fa83808f96929cb87adff3e/status.svg)](https://joss.theoj.org/papers/9ea7d55c4fa83808f96929cb87adff3e) ![](https://img.shields.io/github/workflow/status/jbuisine/macop/build?style=flat-square) ![](https://img.shields.io/pypi/v/macop?style=flat-square) ![](https://img.shields.io/pypi/dm/macop?style=flat-square)
+
 
 <p align="center">
     <img src="https://github.com/jbuisine/macop/blob/master/docs/source/_static/logo_macop.png" alt="" width="50%">

+ 0 - 14
build.sh

@@ -1,14 +0,0 @@
-#! bin/bash
-
-# Format code
-echo "Use of yapf package to format code.."
-#yapf -ir -vv macop
-
-# Build rawls package
-echo "Build package..."
-python setup.py build
-python setup.py test
-
-echo "Build documentation..."
-rm -r docs/source/macop
-cd docs && make clean && make html

+ 16 - 9
macop/algorithms/base.py

@@ -127,7 +127,6 @@ class Algorithm():
         """
         self._parent = parent
 
-
     def initRun(self):
         """
         Initialize the current solution and best solution using the `initialiser` function
@@ -154,7 +153,6 @@ class Algorithm():
 
             current_algorithm._numberOfEvaluations += 1
             current_algorithm = current_algorithm._parent
-            
 
     def getGlobalEvaluation(self):
         """Get the global number of evaluation (if inner algorithm)
@@ -281,8 +279,9 @@ class Algorithm():
         else:
             self._numberOfEvaluations = 0
 
-        logging.info("Run %s with %s evaluations" %
-                     (self.__str__(), evaluations))
+        logging.info(
+            f"Run {self.__str__()} with {(self.__str__(), evaluations)} evaluations"
+        )
 
     def progress(self):
         """
@@ -293,19 +292,27 @@ class Algorithm():
                 callback.run()
 
         if self._verbose:
-            macop_progress(self, self.getGlobalEvaluation(), self.getGlobalMaxEvaluation())
+            macop_progress(self, self.getGlobalEvaluation(),
+                           self.getGlobalMaxEvaluation())
 
-        logging.info(f"-- {type(self).__name__} evaluation {self._numberOfEvaluations} of {self._maxEvaluations} ({((self._numberOfEvaluations / self._maxEvaluations) * 100):.2f}%) - BEST SCORE {self._bestSolution.fitness()}")
+        logging.info(
+            f"-- {type(self).__name__} evaluation {self._numberOfEvaluations} of {self._maxEvaluations} - BEST SCORE {self._bestSolution._score}"
+        )
 
     def end(self):
         """Display end message into `run` method
         """
-    
-        macop_text(self, f'({type(self).__name__}) Found after {self._numberOfEvaluations} evaluations \n   - {self._bestSolution}')
+
+        macop_text(
+            self,
+            f'({type(self).__name__}) Found after {self._numberOfEvaluations} evaluations \n   - {self._bestSolution}'
+        )
         macop_line(self)
 
     def information(self):
-        logging.info(f"-- Best {self._bestSolution} - SCORE {self._bestSolution.fitness()}")
+        logging.info(
+            f"-- Best {self._bestSolution} - SCORE {self._bestSolution.fitness()}"
+        )
 
     def __str__(self):
         return f"{type(self).__name__} using {type(self._bestSolution).__name__}"

+ 21 - 11
macop/algorithms/mono.py

@@ -93,7 +93,9 @@ class HillClimberFirstImprovment(Algorithm):
                 self.increaseEvaluation()
 
                 self.progress()
-                logging.info(f"---- Current {newSolution} - SCORE {newSolution.fitness()}")
+                logging.info(
+                    f"---- Current {newSolution} - SCORE {newSolution.fitness()}"
+                )
 
                 # stop algorithm if necessary
                 if self.stop():
@@ -102,8 +104,10 @@ class HillClimberFirstImprovment(Algorithm):
             # set new current solution using best solution found in this neighbor search
             self._currentSolution = self._bestSolution
 
-        logging.info(f"End of {type(self).__name__}, best solution found {self._bestSolution}")
-        
+        logging.info(
+            f"End of {type(self).__name__}, best solution found {self._bestSolution}"
+        )
+
         return self._bestSolution
 
 
@@ -191,7 +195,9 @@ class HillClimberBestImprovment(Algorithm):
                 self.increaseEvaluation()
 
                 self.progress()
-                logging.info(f"---- Current {newSolution} - SCORE {newSolution.fitness()}")
+                logging.info(
+                    f"---- Current {newSolution} - SCORE {newSolution.fitness()}"
+                )
 
                 # stop algorithm if necessary
                 if self.stop():
@@ -200,8 +206,10 @@ class HillClimberBestImprovment(Algorithm):
             # set new current solution using best solution found in this neighbor search
             self._currentSolution = self._bestSolution
 
-        logging.info(f"End of {type(self).__name__}, best solution found {self._bestSolution}")
-        
+        logging.info(
+            f"End of {type(self).__name__}, best solution found {self._bestSolution}"
+        )
+
         return self._bestSolution
 
 
@@ -268,15 +276,15 @@ class IteratedLocalSearch(Algorithm):
                  maximise=True,
                  parent=None,
                  verbose=True):
-        
-        super().__init__(initializer, evaluator, operators, policy, validator, maximise, parent, verbose)
+
+        super().__init__(initializer, evaluator, operators, policy, validator,
+                         maximise, parent, verbose)
 
         # specific local search associated with current algorithm
         self._localSearch = localSearch
         # need to attach current algorithm as parent
         self._localSearch.setParent(self)
 
-
     def run(self, evaluations, ls_evaluations=100):
         """
         Run the iterated local search algorithm using local search (EvE compromise)
@@ -319,8 +327,10 @@ class IteratedLocalSearch(Algorithm):
 
             self.information()
 
-        logging.info(f"End of {type(self).__name__}, best solution found {self._bestSolution}")
-        
+        logging.info(
+            f"End of {type(self).__name__}, best solution found {self._bestSolution}"
+        )
+
         self.end()
 
         return self._bestSolution

+ 37 - 16
macop/algorithms/multi.py

@@ -107,7 +107,7 @@ class MOEAD(Algorithm):
 
         if mu < T:
             raise ValueError('`mu` cannot be less than `T`')
-            
+
         if mu < T:
             raise ValueError('`mu` cannot be less than `T`')
 
@@ -141,14 +141,23 @@ class MOEAD(Algorithm):
         for i in range(self._mu):
 
             # compute weight sum from solution
-            sub_evaluator = WeightedSum(data={'evaluators': evaluator, 'weights': weights[i]})
+            sub_evaluator = WeightedSum(data={
+                'evaluators': evaluator,
+                'weights': weights[i]
+            })
 
             # intialize each sub problem
             # use copy of list to keep track for each sub problem
-            subProblem = MOSubProblem(i, weights[i],
-                                      initializer, sub_evaluator,
-                                      operators.copy(), policy, validator,
-                                      maximise, self, verbose=self._verbose)
+            subProblem = MOSubProblem(i,
+                                      weights[i],
+                                      initializer,
+                                      sub_evaluator,
+                                      operators.copy(),
+                                      policy,
+                                      validator,
+                                      maximise,
+                                      self,
+                                      verbose=self._verbose)
 
             self._subProblems.append(subProblem)
 
@@ -213,7 +222,8 @@ class MOEAD(Algorithm):
                 # for each neighbor of current sub problem update solution if better
                 improvment = False
                 for j in self._neighbors[i]:
-                    if spBestSolution.fitness() > self._subProblems[j]._bestSolution.fitness():
+                    if spBestSolution.fitness(
+                    ) > self._subProblems[j]._bestSolution.fitness():
 
                         # create new solution based on current new if better, computes fitness associated to new solution for sub problem
                         newSolution = spBestSolution.clone()
@@ -241,7 +251,9 @@ class MOEAD(Algorithm):
                 if self.stop():
                     break
 
-        logging.info(f"End of {type(self).__name__}, best solution found {self._population}")
+        logging.info(
+            f"End of {type(self).__name__}, best solution found {self._population}"
+        )
 
         self.end()
 
@@ -255,9 +267,12 @@ class MOEAD(Algorithm):
             for callback in self._callbacks:
                 callback.run()
 
-        macop_progress(self, self.getGlobalEvaluation(), self.getGlobalMaxEvaluation())
+        macop_progress(self, self.getGlobalEvaluation(),
+                       self.getGlobalMaxEvaluation())
 
-        logging.info(f"-- {type(self).__name__} evaluation {self._numberOfEvaluations} of {self._maxEvaluations} ({((self._numberOfEvaluations) / self._maxEvaluations * 100.):.2f}%)")
+        logging.info(
+            f"-- {type(self).__name__} evaluation {self._numberOfEvaluations} of {self._maxEvaluations} ({((self._numberOfEvaluations) / self._maxEvaluations * 100.):.2f}%)"
+        )
 
     def setNeighbors(self):
 
@@ -339,9 +354,12 @@ class MOEAD(Algorithm):
 
     def end(self):
         """Display end message into `run` method
-        """ 
+        """
 
-        macop_text(self, f'({type(self).__name__}) Found after {self._numberOfEvaluations} evaluations')
+        macop_text(
+            self,
+            f'({type(self).__name__}) Found after {self._numberOfEvaluations} evaluations'
+        )
 
         for i, solution in enumerate(self._pfPop):
             macop_text(self, f'  - [{i}] {solution._scores} : {solution}')
@@ -426,8 +444,8 @@ class MOSubProblem(Algorithm):
                  parent=None,
                  verbose=True):
 
-        super().__init__(initalizer, evaluator, operators, policy,
-                         validator, maximise, parent)
+        super().__init__(initalizer, evaluator, operators, policy, validator,
+                         maximise, parent)
 
         self._index = index
         self._weights = weights
@@ -477,8 +495,11 @@ class MOSubProblem(Algorithm):
             if self.stop():
                 break
 
-            logging.info(f"---- Current {newSolution} - SCORE {newSolution.fitness()}")
+            logging.info(
+                f"---- Current {newSolution} - SCORE {newSolution.fitness()}")
 
-            logging.info(f"End of {type(self).__name__}, best solution found {self._bestSolution}")
+            logging.info(
+                f"End of {type(self).__name__}, best solution found {self._bestSolution}"
+            )
 
         return self._bestSolution

+ 15 - 6
macop/callbacks/classicals.py

@@ -71,7 +71,8 @@ class BasicCheckpoint(Callback):
                 globalEvaluation = int(data[0])
 
                 if self._algo.getParent() is not None:
-                    self._algo.getParent()._numberOfEvaluations = globalEvaluation
+                    self._algo.getParent(
+                    )._numberOfEvaluations = globalEvaluation
                 else:
                     self._algo._numberOfEvaluations = globalEvaluation
 
@@ -83,12 +84,20 @@ class BasicCheckpoint(Callback):
 
                 self._algo._bestSolution._data = np.array(solutionData)
                 self._algo._bestSolution._score = float(data[2])
-      
+
             macop_line(self._algo)
-            macop_text(self._algo, f'Checkpoint found from `{self._filepath}` file.')
-            macop_text(self._algo, f'Restart algorithm from evaluation {self._algo._numberOfEvaluations}.')
+            macop_text(self._algo,
+                       f'Checkpoint found from `{self._filepath}` file.')
+            macop_text(
+                self._algo,
+                f'Restart algorithm from evaluation {self._algo._numberOfEvaluations}.'
+            )
         else:
-            macop_text(self._algo, 'No backup found... Start running algorithm from evaluation 0.')
-            logging.info("Can't load backup... Backup filepath not valid in Checkpoint")
+            macop_text(
+                self._algo,
+                'No backup found... Start running algorithm from evaluation 0.'
+            )
+            logging.info(
+                "Can't load backup... Backup filepath not valid in Checkpoint")
 
         macop_line(self._algo)

+ 24 - 8
macop/callbacks/multi.py

@@ -75,7 +75,8 @@ class MultiCheckpoint(Callback):
                         globalEvaluation = int(data[0])
 
                         if self._algo.getParent() is not None:
-                            self._algo.getParen()._numberOfEvaluations = globalEvaluation
+                            self._algo.getParen(
+                            )._numberOfEvaluations = globalEvaluation
                         else:
                             self._algo._numberOfEvaluations = globalEvaluation
 
@@ -93,11 +94,20 @@ class MultiCheckpoint(Callback):
                     self._algo._pfPop.append(self._algo._population[i])
 
             macop_line(self._algo)
-            macop_text(self._algo, f'Load of available population from `{self._filepath}`')
-            macop_text(self._algo, f'Restart algorithm from evaluation {self._algo._numberOfEvaluations}.')
+            macop_text(
+                self._algo,
+                f'Load of available population from `{self._filepath}`')
+            macop_text(
+                self._algo,
+                f'Restart algorithm from evaluation {self._algo._numberOfEvaluations}.'
+            )
         else:
-            macop_text(self._algo, 'No backup found... Start running algorithm from evaluation 0.')
-            logging.info("Can't load backup... Backup filepath not valid in Checkpoint")
+            macop_text(
+                self._algo,
+                'No backup found... Start running algorithm from evaluation 0.'
+            )
+            logging.info(
+                "Can't load backup... Backup filepath not valid in Checkpoint")
 
         macop_line(self._algo)
 
@@ -169,9 +179,15 @@ class ParetoCheckpoint(Callback):
                     self._algo._pfPop[i]._data = solutionData
                     self._algo._pfPop[i]._scores = scores
 
-            macop_text(self._algo, f'Load of available pareto front backup from `{ self._filepath}`')
-        else:           
-            macop_text(self._algo, 'No pareto front found... Start running algorithm with new pareto front population.')
+            macop_text(
+                self._algo,
+                f'Load of available pareto front backup from `{ self._filepath}`'
+            )
+        else:
+            macop_text(
+                self._algo,
+                'No pareto front found... Start running algorithm with new pareto front population.'
+            )
             logging.info("No pareto front backup used...")
 
         macop_line(self._algo)

+ 4 - 2
macop/callbacks/policies.py

@@ -75,8 +75,10 @@ class UCBCheckpoint(Callback):
                 self._algo._policy._occurences = [
                     float(f) for f in occurrencesLine.split(';')
                 ]
-            
-            macop_text(self._algo, f'Load of available UCB policy data from `{self._filepath}`')
+
+            macop_text(
+                self._algo,
+                f'Load of available UCB policy data from `{self._filepath}`')
         else:
             macop_text(self._algo, 'No UCB data found, use default UCB policy')
             logging.info("No UCB data found...")

+ 1 - 2
macop/evaluators/discrete/mono.py

@@ -28,7 +28,6 @@ class KnapsackEvaluator(Evaluator):
     >>> evaluator.compute(solution)
     40
     """
-
     def compute(self, solution):
         """Apply the computation of fitness from solution
 
@@ -42,4 +41,4 @@ class KnapsackEvaluator(Evaluator):
         for index, elem in enumerate(solution._data):
             fitness += self._data['worths'][index] * elem
 
-        return fitness
+        return fitness

+ 6 - 3
macop/evaluators/discrete/multi.py

@@ -35,7 +35,6 @@ class WeightedSum(Evaluator):
     >>> weighted_score
     50.8
     """
-
     def compute(self, solution):
         """Apply the computation of fitness from solution
 
@@ -48,9 +47,13 @@ class WeightedSum(Evaluator):
         Returns:
             {float} -- weighted-sum of the fitness scores
         """
-        scores = [evaluator.compute(solution) for evaluator in self._data['evaluators']]
+        scores = [
+            evaluator.compute(solution)
+            for evaluator in self._data['evaluators']
+        ]
 
         # associate objectives scores to solution
         solution._scores = scores
 
-        return sum([scores[i] * w for i, w in enumerate(self._data['weights'])])
+        return sum(
+            [scores[i] * w for i, w in enumerate(self._data['weights'])])

+ 1 - 2
macop/operators/base.py

@@ -51,7 +51,6 @@ class Mutation(Operator):
         raise NotImplementedError
 
 
-
 class Crossover(Operator):
     """Abstract crossover extend from Operator
 
@@ -62,4 +61,4 @@ class Crossover(Operator):
         self._kind = KindOperator.CROSSOVER
 
     def apply(self, solution1, solution2=None):
-        raise NotImplementedError
+        raise NotImplementedError

+ 0 - 1
macop/operators/continuous/crossovers.py

@@ -6,4 +6,3 @@ import sys
 
 # module imports
 from macop.operators.base import Crossover
-

+ 1 - 2
macop/policies/base.py

@@ -3,7 +3,6 @@
 import logging
 from abc import abstractmethod
 
-
 from macop.operators.base import KindOperator
 
 
@@ -51,7 +50,7 @@ class Policy():
         # avoid use of crossover if only one solution is passed
         if solution2 is None and operator._kind == KindOperator.CROSSOVER:
 
-            while operator._kind == KindOperator.CROSSOVER:            
+            while operator._kind == KindOperator.CROSSOVER:
                 operator = self.select()
 
         # apply operator on solution

+ 1 - 2
macop/policies/reinforcement.py

@@ -69,7 +69,6 @@ class UCBPolicy(Policy):
         self._C = C
         self._exp_rate = exp_rate
 
-
     def select(self):
         """Select using Upper Confidence Bound the next operator to use (using acquired rewards)
 
@@ -129,7 +128,7 @@ class UCBPolicy(Policy):
         # avoid use of crossover if only one solution is passed
         if solution2 is None and operator._kind == KindOperator.CROSSOVER:
 
-            while operator._kind == KindOperator.CROSSOVER:            
+            while operator._kind == KindOperator.CROSSOVER:
                 operator = self.select()
 
         # apply operator on solution

+ 1 - 1
macop/solutions/base.py

@@ -4,6 +4,7 @@
 from abc import abstractmethod
 from copy import deepcopy
 
+
 class Solution():
     """Base abstract solution class structure
     
@@ -11,7 +12,6 @@ class Solution():
     - get size (shape) of specific data representation
     - stores the score of the solution
     """
-
     def __init__(self, data, size):
         """
         Abstract solution class constructor

+ 1 - 2
macop/solutions/discrete.py

@@ -80,7 +80,6 @@ class BinarySolution(Solution):
         return f"Binary solution {self._data}"
 
 
-
 class CombinatoryIntegerSolution(Solution):
     """
     Combinatory integer solution class
@@ -221,4 +220,4 @@ class IntegerSolution(Solution):
         return solution
 
     def __str__(self):
-        return f"Integer solution {self._data}"
+        return f"Integer solution {self._data}"

Fichier diff supprimé car celui-ci est trop grand
+ 8 - 2
paper.md