Skip to content

Commit 9cadc68

Browse files
benhidYevheniiSemendiakYebisumsteijaertbenhid
authored
jMetalPy v1.5.7 (#91)
* Add solution generator and evaluator for SA (#67) * Add warm startup for SA using population_generator. * Revert evaluator parametrization in SA. * Working on implementing a IntegerFloatSolution class * Update nsgaiii.py (#70) removed obsolete import * Fix conflict in file smpsorp_zdt4.py * Add new implementation of quality indicators. All of them receive a numpy array as a parameter instead of a list of solutions. * Refactor quality indicators. All of them receive as a parameter a numpy array instead of a list of solutions * Add file ZDT1.pf in the test folder (to be use to test quality indicators) * Feature/mixed solution (#73) * Working on implementing a IntegerFloatSolution class * Add unit test cases for class IntegerFloatProblem * Add class NMMin * Add class IntegerFloatSBXCrossover * Add test cases for SBXCrossover * Still working on implementing an approach for the IntegerFloatSolution class * Add user defined exceptiones in file checking.py * Working on the implementation of class CompositeSolution * Workon on class CompositeSolution * Class CompositeMutation implemented and tested * Fix a bug in class Neighborhood * Class CompositeCrossover implemented and tested * Add class * Add class * Rename file * Add problem ZDT1Modified * Add examples with NSGA-II * Add NSGA-II examples * Optimize imports * Minor changes * Changes on attribute name Co-authored-by: Yebisu <ajnebro@outlook.com> * Minor changes * Release v1.5.4 * Updating the MOEAD and variants examples * Minor changes * Add problem UF1 * Fix bug in ibea. * Refactor crossover and mutation operators * Refactor crossover and mutation operators * New minor version 1.5.5 * Adapt CXCrossover and ScrambleMutation to TSP (#80) * Added new minor version * Removed SyntaxWarning for with literals * Changed typing of frequency to int * Minor changes * Use of linters for catching errors and formatters to fix style * fix IntegerProblem cannot get upper bound value bug (#86) * optimise deepcopy for list (#87) * Added logging * Update __init__.py (#92) Export `RouletteWheelSelection` Co-authored-by: Antonio <makishinake@hotmail.com> * Minor changes * Python version 3.7 * Minor changes * Optimize imports * Minor changes * removing depricated functions (#118) * Fix #115 * fixing kursawe's function kursawe's f2 function must go through all variables * evaluate function for zdt6 class zdt6's f1 function is different from the others zdt functions * Fix style * Replace Travis with Github Actions * setup.py deprecated in favor of setup.cfg * Add develop branch for triggering options * Replace build badge Co-authored-by: Yevhenii Semendiak <32543098+YevheniiSemendiak@users.noreply.github.com> Co-authored-by: ajnebro <ajnebro@outlook.com> Co-authored-by: Marvin Steijaert <msteijaert@gmail.com> Co-authored-by: benhid <atbnhd@gmail.com> Co-authored-by: Sizhe Yuen <sizhe1007@gmail.com> Co-authored-by: Antonio J. Nebro <ajnebro@users.noreply.github.com> Co-authored-by: Yevhenii Semendiak <semendyak@gmail.com> Co-authored-by: Lingpho <bob.li.0718@gmail.com> Co-authored-by: Wojciech Lewicki <wojciech.lewicki@swmansion.com> Co-authored-by: root <root@9575ed024558> Co-authored-by: Arysson Oliveira <51703579+ASdOliveira@users.noreply.github.com> Co-authored-by: Isabela <63879870+isabelagabriely@users.noreply.github.com>
1 parent c3a7be2 commit 9cadc68

165 files changed

Lines changed: 4172 additions & 3380 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: CI
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
- develop
9+
pull_request:
10+
branches:
11+
- main
12+
- develop
13+
14+
jobs:
15+
test:
16+
runs-on: ubuntu-latest
17+
strategy:
18+
matrix:
19+
py: [ 3.9, 3.8, 3.7 ]
20+
steps:
21+
- uses: actions/checkout@v2
22+
- name: Install Python ${{ matrix.py }}
23+
uses: actions/setup-python@v2
24+
with:
25+
python-version: ${{ matrix.py }}
26+
- name: Get full Python version
27+
shell: bash
28+
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
29+
- name: Install dependencies
30+
shell: bash
31+
run: |
32+
python -m pip install --upgrade pip
33+
python -m pip install -e .[test]
34+
- name: Run unittest
35+
shell: bash
36+
run: python -m unittest discover -q

.github/workflows/release.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: release
2+
3+
on:
4+
push:
5+
tags:
6+
- '*.*.*'
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
- name: Install Python 3.7
14+
uses: actions/setup-python@v2
15+
with:
16+
python-version: 3.7
17+
- name: Get full Python version
18+
shell: bash
19+
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
20+
- name: Build project for distribution
21+
shell: bash
22+
run: |
23+
python -m pip install -q build
24+
python -m build
25+
- name: Create Release
26+
uses: ncipollo/release-action@v1
27+
with:
28+
artifacts: "dist/*"
29+
token: ${{ secrets.GITHUB_TOKEN }}
30+
draft: false
31+
prerelease: steps.check-version.outputs.prerelease == 'true'

.gitignore

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,5 @@ dask-worker-space
112112
# osx
113113
.DS_Store
114114

115-
# R
116-
.RData
117-
.Rhistory
115+
# Github codespaces
116+
pythonenv3.8

.travis.yml

Lines changed: 0 additions & 6 deletions
This file was deleted.

Makefile

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,20 @@
1-
# Minimal makefile for Sphinx documentation
2-
#
1+
install:
2+
@python setup.py build install
33

4-
# You can set these variables from the command line.
5-
SPHINXOPTS =
6-
SPHINXBUILD = sphinx-build
7-
SPHINXPROJ = jMetalPy
8-
SOURCEDIR = docs/source
9-
BUILDDIR = build
4+
install-dependencies:
5+
@python -m pip install -e .[all]
106

11-
# Put it first so that "make" without argument is like "make help".
12-
help:
13-
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
7+
clean:
8+
@rm -rf build dist .eggs *.egg-info
9+
@find . -type d -name '.mypy_cache' -exec rm -rf {} +
10+
@find . -type d -name '__pycache__' -exec rm -rf {} +
1411

15-
.PHONY: help Makefile
12+
black: clean
13+
@isort --profile black jmetal/ examples/
14+
@black jmetal/ examples/
1615

17-
# "make github" option to build gh-pages
18-
github:
19-
@make html
20-
@cp -a $(BUILDDIR)/html/. docs
21-
@rm -r $(BUILDDIR)
16+
lint:
17+
@mypy jmetal/ examples/ --show-error-codes
2218

23-
# Catch-all target: route all unknown targets to Sphinx using the new
24-
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
25-
%: Makefile
26-
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
19+
tests:
20+
@python -m unittest discover -q

README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
![jMetalPy](docs/source/jmetalpy.png)
22

3-
[![Build Status](https://img.shields.io/travis/jMetal/jMetalPy/master.svg?style=flat-square)](https://travis-ci.org/jMetal/jMetalPy)
4-
[![Documentation](https://img.shields.io/badge/docs-online-success?style=flat-square)](https://jmetal.github.io/jMetalPy/index.html)
5-
[![PyPI License](https://img.shields.io/pypi/l/jMetalPy.svg?style=flat-square)]()
6-
[![PyPI version](https://img.shields.io/pypi/v/jMetalPy.svg?style=flat-square)]()
7-
[![PyPI Python version](https://img.shields.io/pypi/pyversions/jMetalPy.svg?style=flat-square)]()
3+
[![CI](https://github.com/jMetal/jMetalPy/actions/workflows/ci.yml/badge.svg)](https://github.com/jMetal/jMetalPy/actions/workflows/ci.yml)
4+
[![PyPI Python version](https://img.shields.io/pypi/pyversions/jMetalPy.svg)]()
5+
[![DOI](https://img.shields.io/badge/DOI-10.1016%2Fj.swevo.2019.100598-blue)](https://doi.org/10.1016/j.swevo.2019.100598)
6+
[![PyPI License](https://img.shields.io/pypi/l/jMetalPy.svg)]()
7+
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
88

99
A paper introducing jMetalPy is available at: https://doi.org/10.1016/j.swevo.2019.100598
1010

@@ -43,7 +43,7 @@ pip install "jmetalpy[core]"
4343
Other supported commands are listed next:
4444

4545
```console
46-
pip install "jmetalpy[docs]" # Install requirements for building docs
46+
pip install "jmetalpy[dev]" # Install requirements for development
4747
pip install "jmetalpy[distributed]" # Install requirements for parallel/distributed computing
4848
pip install "jmetalpy[complete]" # Install all requirements
4949
```
@@ -100,7 +100,7 @@ plot_front.plot(front, label='NSGAII-ZDT1', filename='NSGAII-ZDT1', format='png'
100100
<img src=docs/source/_static/NSGAII-ZDT1.png width=450 alt="Pareto front approximation">
101101

102102
## Features
103-
The current release of jMetalPy (v1.5.5) contains the following components:
103+
The current release of jMetalPy (v1.5.7) contains the following components:
104104

105105
* Algorithms: local search, genetic algorithm, evolution strategy, simulated annealing, random search, NSGA-II, NSGA-III, SMPSO, OMOPSO, MOEA/D, MOEA/D-DRA, MOEA/D-IEpsilon, GDE3, SPEA2, HYPE, IBEA. Preference articulation-based algorithms (G-NSGA-II, G-GDE3, G-SPEA2, SMPSO/RP); Dynamic versions of NSGA-II, SMPSO, and GDE3.
106106
* Parallel computing based on Apache Spark and Dask.
@@ -118,9 +118,12 @@ The current release of jMetalPy (v1.5.5) contains the following components:
118118

119119
## Changelog
120120

121+
* [v1.5.7] Use of linters for catching errors and formatters to fix style, minor bug fixes.
122+
* [v1.5.6] Removed warnings when using Python 3.8.
121123
* [v1.5.5] Minor bug fixes.
122124
* [v1.5.4] Refactored quality indicators to accept numpy array as input parameter.
123125
* [v1.5.4] Added [CompositeSolution](https://github.com/jMetal/jMetalPy/blob/master/jmetal/core/solution.py#L111) class to support mixed combinatorial problems. [#69](https://github.com/jMetal/jMetalPy/issues/69)
124126

125127
## License
128+
126129
This project is licensed under the terms of the MIT - see the [LICENSE](LICENSE) file for details.

docs/source/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import os
44
import sys
5+
56
sys.path.insert(0, os.path.abspath('../../'))
67

78
# -- Project information -----------------------------------------------------

examples/experiment/comparison.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@ def configure_experiment(problems: dict, n_run: int):
2121
problem=problem,
2222
population_size=100,
2323
offspring_population_size=100,
24-
mutation=PolynomialMutation(probability=1.0 / problem.number_of_variables,
25-
distribution_index=20),
24+
mutation=PolynomialMutation(
25+
probability=1.0 / problem.number_of_variables, distribution_index=20
26+
),
2627
crossover=SBXCrossover(probability=1.0, distribution_index=20),
27-
termination_criterion=StoppingByEvaluations(max_evaluations=max_evaluations)
28+
termination_criterion=StoppingByEvaluations(max_evaluations=max_evaluations),
2829
),
29-
algorithm_tag='NSGAII',
30+
algorithm_tag="NSGAII",
3031
problem_tag=problem_tag,
3132
run=run,
3233
)
@@ -38,9 +39,9 @@ def configure_experiment(problems: dict, n_run: int):
3839
population_size=100,
3940
cr=0.5,
4041
f=0.5,
41-
termination_criterion=StoppingByEvaluations(max_evaluations=max_evaluations)
42+
termination_criterion=StoppingByEvaluations(max_evaluations=max_evaluations),
4243
),
43-
algorithm_tag='GDE3',
44+
algorithm_tag="GDE3",
4445
problem_tag=problem_tag,
4546
run=run,
4647
)
@@ -50,12 +51,13 @@ def configure_experiment(problems: dict, n_run: int):
5051
algorithm=SMPSO(
5152
problem=problem,
5253
swarm_size=100,
53-
mutation=PolynomialMutation(probability=1.0 / problem.number_of_variables,
54-
distribution_index=20),
54+
mutation=PolynomialMutation(
55+
probability=1.0 / problem.number_of_variables, distribution_index=20
56+
),
5557
leaders=CrowdingDistanceArchive(100),
56-
termination_criterion=StoppingByEvaluations(max_evaluations=max_evaluations)
58+
termination_criterion=StoppingByEvaluations(max_evaluations=max_evaluations),
5759
),
58-
algorithm_tag='SMPSO',
60+
algorithm_tag="SMPSO",
5961
problem_tag=problem_tag,
6062
run=run,
6163
)
@@ -64,19 +66,19 @@ def configure_experiment(problems: dict, n_run: int):
6466
return jobs
6567

6668

67-
if __name__ == '__main__':
69+
if __name__ == "__main__":
6870
# Configure the experiments
69-
jobs = configure_experiment(problems={'ZDT1': ZDT1(), 'ZDT2': ZDT2(), 'ZDT3': ZDT3()}, n_run=25)
71+
jobs = configure_experiment(problems={"ZDT1": ZDT1(), "ZDT2": ZDT2(), "ZDT3": ZDT3()}, n_run=25)
7072

7173
# Run the study
72-
output_directory = 'data'
74+
output_directory = "data"
7375

7476
experiment = Experiment(output_dir=output_directory, jobs=jobs)
7577
experiment.run()
7678

7779
# Generate summary file
7880
generate_summary_from_experiment(
7981
input_dir=output_directory,
80-
reference_fronts='resources/reference_front',
81-
quality_indicators=[GenerationalDistance(), EpsilonIndicator(), HyperVolume([1.0, 1.0])]
82+
reference_fronts="resources/reference_front",
83+
quality_indicators=[GenerationalDistance(), EpsilonIndicator(), HyperVolume([1.0, 1.0])],
8284
)
Lines changed: 47 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,75 @@
1-
from jmetal.lab.experiment import generate_boxplot, generate_latex_tables, compute_mean_indicator, compute_wilcoxon
1+
from jmetal.lab.experiment import (
2+
compute_mean_indicator,
3+
compute_wilcoxon,
4+
generate_boxplot,
5+
generate_latex_tables,
6+
)
27
from jmetal.lab.statistical_test.bayesian import *
38
from jmetal.lab.statistical_test.functions import *
49
from jmetal.lab.visualization import CDplot, plot_posterior
510

6-
if __name__ == '__main__':
11+
if __name__ == "__main__":
712
# Generate Median & IQR tables
8-
generate_latex_tables(filename='QualityIndicatorSummary.csv')
13+
generate_latex_tables(filename="QualityIndicatorSummary.csv")
914

1015
# Generate boxplots
11-
generate_boxplot(filename='QualityIndicatorSummary.csv')
16+
generate_boxplot(filename="QualityIndicatorSummary.csv")
1217

1318
# Wilcoxon
14-
compute_wilcoxon(filename='QualityIndicatorSummary.csv')
19+
compute_wilcoxon(filename="QualityIndicatorSummary.csv")
1520

1621
# Statistical lab
1722

18-
avg = compute_mean_indicator(filename='QualityIndicatorSummary.csv', indicator_name='HV')
23+
avg = compute_mean_indicator(filename="QualityIndicatorSummary.csv", indicator_name="HV")
1924
print(avg)
2025

2126
# Non-parametric test
22-
print('-------- Sign Test --------')
23-
print(sign_test(avg[['NSGAII', 'SMPSO']]))
24-
print('-------- Friedman Test --------')
27+
print("-------- Sign Test --------")
28+
print(sign_test(avg[["NSGAII", "SMPSO"]]))
29+
print("-------- Friedman Test --------")
2530
print(friedman_test(avg))
26-
print('-------- Friedman Aligned Rank Test --------')
31+
print("-------- Friedman Aligned Rank Test --------")
2732
print(friedman_aligned_rank_test(avg))
28-
print('-------- Quade Test --------')
33+
print("-------- Quade Test --------")
2934
print(quade_test(avg))
3035

3136
# Post-hoc tests
32-
print('-------- Friedman Post-Hoc Test --------')
33-
z, p_val, adj_pval = friedman_ph_test(avg, control=0, apv_procedure='Bonferroni')
34-
print('z values \n', z)
35-
print('p-values \n', p_val)
36-
print('adjusted p-values \n', adj_pval)
37-
print('-------- Friedman Aligned Rank Post-Hoc Test --------')
38-
z, p_val, adj_pval = friedman_aligned_ph_test(avg, apv_procedure='Shaffer')
39-
print('z values \n', z)
40-
print('p-values \n', p_val)
41-
print('adjusted p-values \n', adj_pval)
42-
print('-------- QuadeTest Post-Hoc Test --------')
43-
z, p_val, adj_pval = quade_ph_test(avg, apv_procedure='Holm')
44-
print('z values \n', z)
45-
print('p-values \n', p_val)
46-
print('adjusted p-values \n', adj_pval)
37+
print("-------- Friedman Post-Hoc Test --------")
38+
z, p_val, adj_pval = friedman_ph_test(avg, control=0, apv_procedure="Bonferroni")
39+
print("z values \n", z)
40+
print("p-values \n", p_val)
41+
print("adjusted p-values \n", adj_pval)
42+
print("-------- Friedman Aligned Rank Post-Hoc Test --------")
43+
z, p_val, adj_pval = friedman_aligned_ph_test(avg, apv_procedure="Shaffer")
44+
print("z values \n", z)
45+
print("p-values \n", p_val)
46+
print("adjusted p-values \n", adj_pval)
47+
print("-------- QuadeTest Post-Hoc Test --------")
48+
z, p_val, adj_pval = quade_ph_test(avg, apv_procedure="Holm")
49+
print("z values \n", z)
50+
print("p-values \n", p_val)
51+
print("adjusted p-values \n", adj_pval)
4752

4853
# Plot critical distance
4954

5055
CDplot(avg.T, alpha=0.15, higher_is_better=True)
5156

52-
print('-------- Bayesian Sign Test --------')
53-
bst, DProcess = bayesian_sign_test(avg[['NSGAII', 'SMPSO']], rope_limits=[-0.002, 0.002],
54-
prior_strength=0.5, return_sample=True)
55-
plot_posterior(DProcess, higher_is_better=True, alg_names=['NSGAII', 'SMPSO'])
57+
print("-------- Bayesian Sign Test --------")
58+
bst, DProcess = bayesian_sign_test(
59+
avg[["NSGAII", "SMPSO"]], rope_limits=[-0.002, 0.002], prior_strength=0.5, return_sample=True
60+
)
61+
plot_posterior(DProcess, higher_is_better=True, alg_names=["NSGAII", "SMPSO"])
5662

57-
print('Pr(NSGAII < SMPSO) = %.3f' % bst[0])
58-
print('Pr(NSGAII ~= SMPSO) = %.3f' % bst[1])
59-
print('Pr(NSGAII > SMPSO) = %.3f' % bst[2])
63+
print("Pr(NSGAII < SMPSO) = %.3f" % bst[0])
64+
print("Pr(NSGAII ~= SMPSO) = %.3f" % bst[1])
65+
print("Pr(NSGAII > SMPSO) = %.3f" % bst[2])
6066

61-
print('-------- Bayesian Signed Rank Test --------')
62-
bst, DProcess = bayesian_signed_rank_test(avg[['NSGAII', 'SMPSO']], rope_limits=[-0.002, 0.002],
63-
prior_strength=0.5, return_sample=True)
64-
plot_posterior(DProcess, higher_is_better=True, alg_names=['NSGAII', 'SMPSO'])
67+
print("-------- Bayesian Signed Rank Test --------")
68+
bst, DProcess = bayesian_signed_rank_test(
69+
avg[["NSGAII", "SMPSO"]], rope_limits=[-0.002, 0.002], prior_strength=0.5, return_sample=True
70+
)
71+
plot_posterior(DProcess, higher_is_better=True, alg_names=["NSGAII", "SMPSO"])
6572

66-
print('Pr(NSGAII < SMPSO) = %.3f' % bst[0])
67-
print('Pr(NSGAII ~= SMPSO) = %.3f' % bst[1])
68-
print('Pr(NSGAII > SMPSO) = %.3f' % bst[2])
73+
print("Pr(NSGAII < SMPSO) = %.3f" % bst[0])
74+
print("Pr(NSGAII ~= SMPSO) = %.3f" % bst[1])
75+
print("Pr(NSGAII > SMPSO) = %.3f" % bst[2])

0 commit comments

Comments
 (0)