pareto

Nondominated sorting for multi-objective problems

https://github.com/matthewjwoodruff/pareto.py

Science Score: 10.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    1 of 5 committers (20.0%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (8.3%) to scientific vocabulary
Last synced: 11 months ago · JSON representation

Repository

Nondominated sorting for multi-objective problems

Basic Info
  • Host: GitHub
  • Owner: matthewjwoodruff
  • License: lgpl-3.0
  • Language: Python
  • Default Branch: master
  • Size: 2.16 MB
Statistics
  • Stars: 115
  • Watchers: 10
  • Forks: 40
  • Open Issues: 11
  • Releases: 0
Created almost 13 years ago · Last pushed about 8 years ago
Metadata Files
Readme License

README.md

pareto.py

Nondominated sorting for multi-objective problems

by matthewjwoodruff and jdherman

pareto.py implements an epsilon-nondominated sort in pure Python. It sorts one or more files of solutions into the Pareto-efficient (or "nondominated") set. Solutions can contain columns other than objectives, which will be carried through, unsorted, to the output. By default, output rows are reproduced verbatim from input. pareto.py supports both minimization and maximization, although it assumes minimization.

This sort assumes a desired output resolution (epsilons). If a strict nondominated sort is required, it can be approximated by setting epsilons arbitrarily small (within reason -- floating-point division is involved here.) The default epsilon resolution of 1e-9 will effectively result in a strict nondominated sort in many cases.

Data prior to sort.  Objectives f1 and f2 are both to be minimized.

Data prior to sorting. Objectives f1 and f2 are both to be minimized.

Data after epsilon-nondominated sort.  Highlighted solutions are epsilon-nondominated.

Data after epsilon-nondominated sort. Red epsilon-boxes and all of the solutions in them are dominated. Marked solutions are epsilon-nondominated.

This picture shows the same data sorted at a variety of epsilon resolutions. (Note that there is no requirement that epsilons be the same for each objective. Epsilons for f1 and f2 are set equal for illustration only.)

Release Notes

Usage

Example usage for a group of input files beginning with my_file_: python pareto.py \ my_file_* \ -o 3-5 \ -e 0.01 0.05 0.1 \ -m 3 \ --output my_pareto_set.txt \ --delimiter=' ' \ --print-only-objectives \ --header=1 \ --blank \ --comment="#" \ --contribution \ --line-number

  • inputs: Required. List of input files to sort, separated by spaces. Input files are assumed to contain floating-point values separated by delimiter. Input files must all contain the same number of columns. - may be specified as an input, indicating standard input. This allows pareto.py to be part of a pipeline.

  • --output: Optional. Filename to output your Pareto set.

  • -o, --objectives: Optional. A list of columns of the input files to sort (zero-indexed), separated by spaces. If not given, all columns of the input files will be sorted. Ranges and individual column numbers may be mixed, e.g. -o 0 3-7 12

  • -e, --epsilons: Optional. A list of epsilon (precision) values corresponding to each objective. If not given, all objectives will use a precision of 1e-9.

  • -m, --maximize: Optional. A list of objective columns to maximize. By default, pareto.py minimizes all objectives.

  • -M, --maximize-all: Optional. Maximize all objectives. Overrides -m.

  • -d, --delimiter: Optional. Input file delimiter. Common choices:

    • Space-delimited (default): --delimiter=' '
    • Comma-delimited: --delimiter=','
    • Tab: --tabs (see below)
  • --tabs: Use tabs as delimiter. Provided for convenience because tabs can be difficult to escape properly at the command line.

  • --print-only-objectives: Optional. Include this flag to print only the objective values in the Pareto set. If this flag is not included, all columns of the input will be printed to the output, even if they were not sorted.

  • --header: Optional. Number of rows to skip at the top of each input. If the header is prefixed with a comment character (see --comment) this is unnecessary.

  • -c, --comment: Optional. Character to look for at the beginning of a row indicating that the row contains a comment and should be ignored. Commented rows are not preserved in output. More than one character may be specified. For example, -c "#" "//" will cause lines starting with either # or // to be skipped.

  • --blank: Optional. Skip blank rows instead of erroring out.

  • --contribution: Optional. Append filename of origin to each solution in the output.

  • --line-number: Optional. Report line number in file of origin when appending contribution.

  • --reverse-column-indices: Optional. Count column indices from the end of the row rather than from the beginning. This affects the behavior of -o, -e, and -m. -o and -m will count from the end of the row, which reverses the order of the objectives from the point of view of -e. So if you specify -o 0-2 --reverse-column-indices -e 0.1 0.2 0.2 -m 0, the last column of each row gets maximized with epsilon 0.1, while the two columns before it get minimized with epsilon 0.2. If you want to specify epsilons in forward order, switch the direction of the index range: -o 2-0 --reverse-column-indices -e 0.2 0.2 0.1 -m 0 has the same effect.

What is this?

For more information, please consult the following references:

But what is it for?

Among other things, pareto.py can serve the following purposes:

  • Post-process the output of multiple optimization runs. Since multiple-objective evolutionary algorithms (MOEAs) are search heuristics using random numbers, they may be run more than once and produce different output each time. Therefore the estabilshed best practice for MOEA users is to sort together the output of as many optimization runs as possible to get a good approximation of the true Pareto-efficient set.
  • Combine the output of more than one MOEA, for research studies comparing the performance of different MOEAs. This is useful when computing metrics of optimization performance such as hypervolume and the epsilon-indicator.
  • Find the Pareto-efficient solutions within a set of unsorted data.
  • Prepare reference data for validating other implementations of epsilon-nondominated sorting routines.
  • Understand how epsilon-nondominated sorting works by reading and modifying the source code.

Alternatives

The ReferenceSetMerger from moeaframework (http://www.moeaframework.org) tends to be faster then pareto.py when the reference set is large, i.e. when a lot of comparisons must be made for each solution. pareto.py seems to have a speed advantage in situations where reading the input file is the limiting factor. ReferenceSetMerger tends to use a great deal more RAM.

YMMV, TANSTAAFL.

Dependencies

  • Python standard library (sys, math, and argparse)
  • Python 2.7 or later, Python 3.2 or later (for argparse)

Note for Pandas users

Pandas is an excellent library for Python data analysis. Doing a nondominated sort on a Pandas Data Frame requires itertuples(False), because pareto.py expects to be able to iterate over rows. The False argument excludes the index. It can be included if desired, but the objective columns should be adjusted accordingly.

``` import pandas import pareto

table = pandas.readtable("datafile.txt") nondominated = pareto.epssort([list(table.itertuples(False))], [3, 4, 5], [1, 0.1, 3]) ```

Note for PyPy users

Congratulations! You're using a blazing fast Python interpreter. pareto.py works great with PyPy. A comparison on a 692M file with 10 objectives, 27 other columns, and a reference set of 507 solutions, ran in 23.5s using pypy (version 2.1.0), versus 8m29s with CPython 2.7.5. (Disclaimer: many factors affect performance. This is an anecdotal result.)

Note for Python3 users

pareto.py works with Python3.2 and up. However, informal performance comparisons show a speed regression of about 30% for CPython 3.3.2 versus 2.7.5, possibly because we're being naive about string handling.

License

Copyright (C) 2013 Matt Woodruff and Jon Herman. Licensed under the GNU Lesser General Public License.

pareto.py is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

pareto.py is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with the pareto.py. If not, see http://www.gnu.org/licenses/.

Owner

  • Login: matthewjwoodruff
  • Kind: user

GitHub Events

Total
  • Watch event: 1
Last Year
  • Watch event: 1

Committers

Last synced: almost 3 years ago

All Time
  • Total Commits: 122
  • Total Committers: 5
  • Avg Commits per committer: 24.4
  • Development Distribution Score (DDS): 0.27
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Matthew Woodruff m****7@p****u 89
Matthew Woodruff m****f@d****m 12
matthewjwoodruff m****f 11
jdherman j****8@g****m 9
Kaligule K****e@g****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 11 months ago

All Time
  • Total issues: 33
  • Total pull requests: 1
  • Average time to close issues: about 1 month
  • Average time to close pull requests: about 15 hours
  • Total issue authors: 9
  • Total pull request authors: 1
  • Average comments per issue: 1.61
  • Average comments per pull request: 0.0
  • Merged pull requests: 1
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • matthewjwoodruff (22)
  • Lordmzn (3)
  • jdherman (2)
  • agusmdev (1)
  • TRomijn (1)
  • fab6 (1)
  • zy455761544 (1)
  • Ambier (1)
  • benoitpaillard (1)
Pull Request Authors
  • Kaligule (1)
Top Labels
Issue Labels
enhancement (21) bug (4) question (2) wontfix (2)
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 9,691 last-month
  • Total dependent packages: 1
  • Total dependent repositories: 8
  • Total versions: 1
  • Total maintainers: 1
pypi.org: pareto

Nondominated sorting for multi-objective problems

  • Homepage: https://github.com/matthewjwoodruff/pareto.py
  • Documentation: https://pareto.readthedocs.io/
  • License: GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. "The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the Combined Work with a copy of the GNU GPL and this license document. c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library.
  • Latest release: 1.1.1-3
    published about 11 years ago
  • Versions: 1
  • Dependent Packages: 1
  • Dependent Repositories: 8
  • Downloads: 9,691 Last month
Rankings
Dependent packages count: 4.7%
Dependent repos count: 5.2%
Forks count: 6.4%
Average: 6.6%
Stargazers count: 6.8%
Downloads: 9.9%
Maintainers (1)
Last synced: 11 months ago