Skip to content

Commit

Permalink
jMetalPy v1.5.7 (#91)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

* 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 <[email protected]>

* 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 <[email protected]>
Co-authored-by: ajnebro <[email protected]>
Co-authored-by: Marvin Steijaert <[email protected]>
Co-authored-by: benhid <[email protected]>
Co-authored-by: Sizhe Yuen <[email protected]>
Co-authored-by: Antonio J. Nebro <[email protected]>
Co-authored-by: Yevhenii Semendiak <[email protected]>
Co-authored-by: Lingpho <[email protected]>
Co-authored-by: Wojciech Lewicki <[email protected]>
Co-authored-by: root <root@9575ed024558>
Co-authored-by: Arysson Oliveira <[email protected]>
Co-authored-by: Isabela <[email protected]>
  • Loading branch information
13 people authored Feb 4, 2022
1 parent c3a7be2 commit 9cadc68
Show file tree
Hide file tree
Showing 165 changed files with 4,172 additions and 3,380 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: CI

on:
workflow_dispatch:
push:
branches:
- main
- develop
pull_request:
branches:
- main
- develop

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
py: [ 3.9, 3.8, 3.7 ]
steps:
- uses: actions/checkout@v2
- name: Install Python ${{ matrix.py }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.py }}
- name: Get full Python version
shell: bash
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
- name: Install dependencies
shell: bash
run: |
python -m pip install --upgrade pip
python -m pip install -e .[test]
- name: Run unittest
shell: bash
run: python -m unittest discover -q
31 changes: 31 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: release

on:
push:
tags:
- '*.*.*'

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Python 3.7
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Get full Python version
shell: bash
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
- name: Build project for distribution
shell: bash
run: |
python -m pip install -q build
python -m build
- name: Create Release
uses: ncipollo/release-action@v1
with:
artifacts: "dist/*"
token: ${{ secrets.GITHUB_TOKEN }}
draft: false
prerelease: steps.check-version.outputs.prerelease == 'true'
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,5 @@ dask-worker-space
# osx
.DS_Store

# R
.RData
.Rhistory
# Github codespaces
pythonenv3.8
6 changes: 0 additions & 6 deletions .travis.yml

This file was deleted.

36 changes: 15 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
# Minimal makefile for Sphinx documentation
#
install:
@python setup.py build install

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

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

.PHONY: help Makefile
black: clean
@isort --profile black jmetal/ examples/
@black jmetal/ examples/

# "make github" option to build gh-pages
github:
@make html
@cp -a $(BUILDDIR)/html/. docs
@rm -r $(BUILDDIR)
lint:
@mypy jmetal/ examples/ --show-error-codes

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
tests:
@python -m unittest discover -q
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
![jMetalPy](docs/source/jmetalpy.png)

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

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

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

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

## Features
The current release of jMetalPy (v1.5.5) contains the following components:
The current release of jMetalPy (v1.5.7) contains the following components:

* 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.
* Parallel computing based on Apache Spark and Dask.
Expand All @@ -118,9 +118,12 @@ The current release of jMetalPy (v1.5.5) contains the following components:

## Changelog

* [v1.5.7] Use of linters for catching errors and formatters to fix style, minor bug fixes.
* [v1.5.6] Removed warnings when using Python 3.8.
* [v1.5.5] Minor bug fixes.
* [v1.5.4] Refactored quality indicators to accept numpy array as input parameter.
* [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)

## License

This project is licensed under the terms of the MIT - see the [LICENSE](LICENSE) file for details.
1 change: 1 addition & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import os
import sys

sys.path.insert(0, os.path.abspath('../../'))

# -- Project information -----------------------------------------------------
Expand Down
32 changes: 17 additions & 15 deletions examples/experiment/comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ def configure_experiment(problems: dict, n_run: int):
problem=problem,
population_size=100,
offspring_population_size=100,
mutation=PolynomialMutation(probability=1.0 / problem.number_of_variables,
distribution_index=20),
mutation=PolynomialMutation(
probability=1.0 / problem.number_of_variables, distribution_index=20
),
crossover=SBXCrossover(probability=1.0, distribution_index=20),
termination_criterion=StoppingByEvaluations(max_evaluations=max_evaluations)
termination_criterion=StoppingByEvaluations(max_evaluations=max_evaluations),
),
algorithm_tag='NSGAII',
algorithm_tag="NSGAII",
problem_tag=problem_tag,
run=run,
)
Expand All @@ -38,9 +39,9 @@ def configure_experiment(problems: dict, n_run: int):
population_size=100,
cr=0.5,
f=0.5,
termination_criterion=StoppingByEvaluations(max_evaluations=max_evaluations)
termination_criterion=StoppingByEvaluations(max_evaluations=max_evaluations),
),
algorithm_tag='GDE3',
algorithm_tag="GDE3",
problem_tag=problem_tag,
run=run,
)
Expand All @@ -50,12 +51,13 @@ def configure_experiment(problems: dict, n_run: int):
algorithm=SMPSO(
problem=problem,
swarm_size=100,
mutation=PolynomialMutation(probability=1.0 / problem.number_of_variables,
distribution_index=20),
mutation=PolynomialMutation(
probability=1.0 / problem.number_of_variables, distribution_index=20
),
leaders=CrowdingDistanceArchive(100),
termination_criterion=StoppingByEvaluations(max_evaluations=max_evaluations)
termination_criterion=StoppingByEvaluations(max_evaluations=max_evaluations),
),
algorithm_tag='SMPSO',
algorithm_tag="SMPSO",
problem_tag=problem_tag,
run=run,
)
Expand All @@ -64,19 +66,19 @@ def configure_experiment(problems: dict, n_run: int):
return jobs


if __name__ == '__main__':
if __name__ == "__main__":
# Configure the experiments
jobs = configure_experiment(problems={'ZDT1': ZDT1(), 'ZDT2': ZDT2(), 'ZDT3': ZDT3()}, n_run=25)
jobs = configure_experiment(problems={"ZDT1": ZDT1(), "ZDT2": ZDT2(), "ZDT3": ZDT3()}, n_run=25)

# Run the study
output_directory = 'data'
output_directory = "data"

experiment = Experiment(output_dir=output_directory, jobs=jobs)
experiment.run()

# Generate summary file
generate_summary_from_experiment(
input_dir=output_directory,
reference_fronts='resources/reference_front',
quality_indicators=[GenerationalDistance(), EpsilonIndicator(), HyperVolume([1.0, 1.0])]
reference_fronts="resources/reference_front",
quality_indicators=[GenerationalDistance(), EpsilonIndicator(), HyperVolume([1.0, 1.0])],
)
87 changes: 47 additions & 40 deletions examples/experiment/statistical_analysis.py
Original file line number Diff line number Diff line change
@@ -1,68 +1,75 @@
from jmetal.lab.experiment import generate_boxplot, generate_latex_tables, compute_mean_indicator, compute_wilcoxon
from jmetal.lab.experiment import (
compute_mean_indicator,
compute_wilcoxon,
generate_boxplot,
generate_latex_tables,
)
from jmetal.lab.statistical_test.bayesian import *
from jmetal.lab.statistical_test.functions import *
from jmetal.lab.visualization import CDplot, plot_posterior

if __name__ == '__main__':
if __name__ == "__main__":
# Generate Median & IQR tables
generate_latex_tables(filename='QualityIndicatorSummary.csv')
generate_latex_tables(filename="QualityIndicatorSummary.csv")

# Generate boxplots
generate_boxplot(filename='QualityIndicatorSummary.csv')
generate_boxplot(filename="QualityIndicatorSummary.csv")

# Wilcoxon
compute_wilcoxon(filename='QualityIndicatorSummary.csv')
compute_wilcoxon(filename="QualityIndicatorSummary.csv")

# Statistical lab

avg = compute_mean_indicator(filename='QualityIndicatorSummary.csv', indicator_name='HV')
avg = compute_mean_indicator(filename="QualityIndicatorSummary.csv", indicator_name="HV")
print(avg)

# Non-parametric test
print('-------- Sign Test --------')
print(sign_test(avg[['NSGAII', 'SMPSO']]))
print('-------- Friedman Test --------')
print("-------- Sign Test --------")
print(sign_test(avg[["NSGAII", "SMPSO"]]))
print("-------- Friedman Test --------")
print(friedman_test(avg))
print('-------- Friedman Aligned Rank Test --------')
print("-------- Friedman Aligned Rank Test --------")
print(friedman_aligned_rank_test(avg))
print('-------- Quade Test --------')
print("-------- Quade Test --------")
print(quade_test(avg))

# Post-hoc tests
print('-------- Friedman Post-Hoc Test --------')
z, p_val, adj_pval = friedman_ph_test(avg, control=0, apv_procedure='Bonferroni')
print('z values \n', z)
print('p-values \n', p_val)
print('adjusted p-values \n', adj_pval)
print('-------- Friedman Aligned Rank Post-Hoc Test --------')
z, p_val, adj_pval = friedman_aligned_ph_test(avg, apv_procedure='Shaffer')
print('z values \n', z)
print('p-values \n', p_val)
print('adjusted p-values \n', adj_pval)
print('-------- QuadeTest Post-Hoc Test --------')
z, p_val, adj_pval = quade_ph_test(avg, apv_procedure='Holm')
print('z values \n', z)
print('p-values \n', p_val)
print('adjusted p-values \n', adj_pval)
print("-------- Friedman Post-Hoc Test --------")
z, p_val, adj_pval = friedman_ph_test(avg, control=0, apv_procedure="Bonferroni")
print("z values \n", z)
print("p-values \n", p_val)
print("adjusted p-values \n", adj_pval)
print("-------- Friedman Aligned Rank Post-Hoc Test --------")
z, p_val, adj_pval = friedman_aligned_ph_test(avg, apv_procedure="Shaffer")
print("z values \n", z)
print("p-values \n", p_val)
print("adjusted p-values \n", adj_pval)
print("-------- QuadeTest Post-Hoc Test --------")
z, p_val, adj_pval = quade_ph_test(avg, apv_procedure="Holm")
print("z values \n", z)
print("p-values \n", p_val)
print("adjusted p-values \n", adj_pval)

# Plot critical distance

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

print('-------- Bayesian Sign Test --------')
bst, DProcess = bayesian_sign_test(avg[['NSGAII', 'SMPSO']], rope_limits=[-0.002, 0.002],
prior_strength=0.5, return_sample=True)
plot_posterior(DProcess, higher_is_better=True, alg_names=['NSGAII', 'SMPSO'])
print("-------- Bayesian Sign Test --------")
bst, DProcess = bayesian_sign_test(
avg[["NSGAII", "SMPSO"]], rope_limits=[-0.002, 0.002], prior_strength=0.5, return_sample=True
)
plot_posterior(DProcess, higher_is_better=True, alg_names=["NSGAII", "SMPSO"])

print('Pr(NSGAII < SMPSO) = %.3f' % bst[0])
print('Pr(NSGAII ~= SMPSO) = %.3f' % bst[1])
print('Pr(NSGAII > SMPSO) = %.3f' % bst[2])
print("Pr(NSGAII < SMPSO) = %.3f" % bst[0])
print("Pr(NSGAII ~= SMPSO) = %.3f" % bst[1])
print("Pr(NSGAII > SMPSO) = %.3f" % bst[2])

print('-------- Bayesian Signed Rank Test --------')
bst, DProcess = bayesian_signed_rank_test(avg[['NSGAII', 'SMPSO']], rope_limits=[-0.002, 0.002],
prior_strength=0.5, return_sample=True)
plot_posterior(DProcess, higher_is_better=True, alg_names=['NSGAII', 'SMPSO'])
print("-------- Bayesian Signed Rank Test --------")
bst, DProcess = bayesian_signed_rank_test(
avg[["NSGAII", "SMPSO"]], rope_limits=[-0.002, 0.002], prior_strength=0.5, return_sample=True
)
plot_posterior(DProcess, higher_is_better=True, alg_names=["NSGAII", "SMPSO"])

print('Pr(NSGAII < SMPSO) = %.3f' % bst[0])
print('Pr(NSGAII ~= SMPSO) = %.3f' % bst[1])
print('Pr(NSGAII > SMPSO) = %.3f' % bst[2])
print("Pr(NSGAII < SMPSO) = %.3f" % bst[0])
print("Pr(NSGAII ~= SMPSO) = %.3f" % bst[1])
print("Pr(NSGAII > SMPSO) = %.3f" % bst[2])
Loading

0 comments on commit 9cadc68

Please sign in to comment.