https://github.com/cma-es/moarchiving
Multiobjective nondominated archive classes with up to four objectives
Science Score: 59.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 8 DOI reference(s) in README -
✓Academic publication links
Links to: arxiv.org -
✓Committers with academic emails
1 of 1 committers (100.0%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (14.7%) to scientific vocabulary
Repository
Multiobjective nondominated archive classes with up to four objectives
Basic Info
Statistics
- Stars: 2
- Watchers: 4
- Forks: 4
- Open Issues: 12
- Releases: 0
Metadata Files
README.md
Introduction
This package implements a multi-objective non-dominated archive for 2, 3 or 4 objectives, providing easy and fast access to multiple hypervolume indicators:
- the hypervolume of the entire archive,
- the contributing hypervolume of each element,
- the uncrowded hypervolume improvement (see also here) of any given point in the objective space, and
- the uncrowded hypervolume of the (unpruned) archive, here called hypervolume plus.
Additionally, the package provides a constrained version of the archive, which allows to store points with constraints.
The source code is available on GitHub.
Installation
On a system shell, either like
pip install moarchiving
or from GitHub, for example
pip install git+https://github.com/CMA-ES/moarchiving.git@development
installing from the development branch.
Testing
python -m moarchiving.test
on a system shell should output something like
```
doctest.testmod(
...
OK
unittest.TextTestRunner().run(unittest.TestLoader().loadTestsFromModule(
.......
Ran 7 tests in 0.001s ```
Links
Details
moarchiving with 2 objectives uses the fractions.Fraction type to avoid rounding errors when computing hypervolume differences, but its usage can also be easily switched off by assigning the respective class attributes hypervolume_computation_float_type and hypervolume_final_float_type. The Fraction type can become prohibitively computationally expensive with increasing precision.
The implementation of the two-objective archive is heavily based on the bisect module, while in three and four objectives it is based on the sortedcontainers module.
Releases
- 1.0.0 addition of MOArchive classes for 3 and 4 objectives, as well as a class for handling solutions to constrained problems
- 0.7.0 reimplementation of
BiobjectiveNondominatedSortedList.hypervolume_improvementby extracting a sublist first. - 0.6.0 the
infosattribute is alistwith corresponding (arbitrary) information, e.g. for keeping the respective solutions. - 0.5.3 fixed assertion error when not using
fractions.Fraction - 0.5.2 first published version
Usage examples
- Initialization
- Constrained MOArchive
- Accessing solution information
- Adding solutions
- Archive size
- Performance indicators
- Contributing hypervolumes
- Hypervolume improvement
- Distance to the Pareto front
- Enabling or disabling fractions
- Additional functions
- Visualization of indicator values
- Performance tests
1. Initialization
The MOArchive object can be created using the get_mo_archive function by providing a list of objective values, a reference point, or at least the number of objectives.
Further solutions can be added using add or add_list methods, but the reference point cannot be changed once the instance is created. A list of information strings can be provided for each element, which will be stored as long as the corresponding element remains in the archive (e.g., the x values of the element). At any time, the list of non-dominated elements and their corresponding information can be accessed.
```python from moarchiving import getmoarchive
moa2obj = getmoarchive([[1, 5], [2, 3], [4, 5], [5, 0]], referencepoint=[10, 10], infos=["a", "b", "c", "d"]) moa3obj = getmoarchive([[1, 2, 3], [3, 2, 1], [3, 3, 0], [2, 2, 1]], [10, 10, 10], ["a", "b", "c", "d"]) moa4obj = getmoarchive([[1, 2, 3, 4], [1, 3, 4, 5], [4, 3, 2, 1], [1, 3, 0, 1]], referencepoint=[10, 10, 10, 10], infos=["a", "b", "c", "d"])
print("points in the 2 objective archive:", list(moa2obj)) print("points in the 3 objective archive:", list(moa3obj)) print("points in the 4 objective archive:", list(moa4obj)) ```
points in the 2 objective archive: [[1, 5], [2, 3], [5, 0]]
points in the 3 objective archive: [[3, 3, 0], [2, 2, 1], [1, 2, 3]]
points in the 4 objective archive: [[1, 3, 0, 1], [1, 2, 3, 4]]
MOArchive objects can also be initialized empty.
python
moa = get_mo_archive(reference_point=[4, 4, 4])
print("points in the empty archive:", list(moa))
points in the empty archive: []
2. Constrained MOArchive
Constrained MOArchive supports all the functionalities of a non-constrained MOArchive, with the added capability of handling constraints when adding or initializing the archive. In addition to the objective values of a solution, constraint values must be provided in the form of a list or a number. A solution is deemed feasible when all its constraint values are less than or equal to zero.
```python from moarchiving import getcmoarchive
cmoa = getcmoarchive([[1, 2, 3], [1, 3, 4], [4, 3, 2], [1, 3, 0]], [[3, 0], [0, 0], [0, 0], [0, 1]], reference_point=[5, 5, 5], infos=["a", "b", "c", "d"]) print("points in the archive:", list(cmoa)) ```
points in the archive: [[4, 3, 2], [1, 3, 4]]
3. Accessing solution information
archive.infos is used to get the information on solutions in the archive.
```python
infos of the previously defined empty archive
print("infos of the empty archive", moa.infos) print("infos of the constrained archive", cmoa.infos) ```
infos of the empty archive []
infos of the constrained archive ['c', 'b']
4. Adding solutions
Solutions can be added to the MOArchive at any time using the add function (for a single solution) or the add_list function (for multiple solutions).
```python moa.add([1, 2, 3], "a") print("points:", list(moa)) print("infos:", moa.infos)
moa.add_list([[3, 2, 1], [2, 3, 2], [2, 2, 2]], ["b", "c", "d"]) print("points:", list(moa)) print("infos:", moa.infos) ```
points: [[1, 2, 3]]
infos: ['a']
points: [[3, 2, 1], [2, 2, 2], [1, 2, 3]]
infos: ['b', 'd', 'a']
When adding to the constrained archive, constraint values must be added as well.
python
cmoa.add_list([[3, 3, 3], [1, 1, 1]], [[0, 0], [42, 0]], ["e", "f"])
print("points:", list(cmoa))
print("infos:", cmoa.infos)
points: [[4, 3, 2], [3, 3, 3], [1, 3, 4]]
infos: ['c', 'e', 'b']
5. Archive size
The MOArchive implements some functionality of a list (in the 2 objective case, it actually extends the list class, though this is not the case in 3 and 4 objectives). In particular, it includes the len method to get the number of solutions in the archive as well as the in keyword to check if a point is in the archive.
python
print("Points in the archive:", list(moa))
print("Length of the archive:", len(moa))
print("[2, 2, 2] in moa:", [2, 2, 2] in moa)
print("[3, 2, 0] in moa:", [3, 2, 0] in moa)
Points in the archive: [[3, 2, 1], [2, 2, 2], [1, 2, 3]]
Length of the archive: 3
[2, 2, 2] in moa: True
[3, 2, 0] in moa: False
6. Performance indicators
An archive provides the following performance indicators:
- hypervolume
- hypervolume_plus, providing additionally the closest distance to the reference area for an empty archive, see here and here
- hypervolume_plus_constr (for CMOArchive), based on, but not completely equal to the one defined here
Indicators are defined for maximization (the original hypervolume_plus_constr indicator is multiplied by -1). When the archive is not empty, all the indicators are positive and have the same value. As the archive does not (yet) support an ideal point, the values of indicators are not normalized.
python
print("Hypervolume of the archive:", moa.hypervolume)
print("Hypervolume plus of the archive:", moa.hypervolume_plus)
Hypervolume of the archive: 12
Hypervolume plus of the archive: 12
In case of a constrained MOArchive, the hypervolume_plus_constr attribute can be accessed as well.
python
print("Hyperolume of the constrained archive:", cmoa.hypervolume)
print("Hypervolume plus of the constrained archive:", cmoa.hypervolume_plus)
print("Hypervolume plus constr of the constrained archive:", cmoa.hypervolume_plus_constr)
Hyperolume of the constrained archive: 14
Hypervolume plus of the constrained archive: 14
Hypervolume plus constr of the constrained archive: 14
7. Contributing hypervolumes
The contributing_hypervolumes attribute provides a list of hypervolume contributions for each point of the archive. Alternatively, the contribution for a single point can be computed using the contributing_hypervolume(point) method.
```python for i, objectives in enumerate(moa): assert moa.contributinghypervolume(objectives) == moa.contributinghypervolumes[i] print("contributing hv of point", objectives, "is", moa.contributing_hypervolume(objectives))
print("All contributing hypervolumes:", moa.contributing_hypervolumes) ```
contributing hv of point [3, 2, 1] is 2
contributing hv of point [2, 2, 2] is 2
contributing hv of point [1, 2, 3] is 2
All contributing hypervolumes: [Fraction(2, 1), Fraction(2, 1), Fraction(2, 1)]
8. Hypervolume improvement
The hypervolume_improvement(point) method returns the improvement of the hypervolume if we would add the point to the archive.
python
point = [1, 3, 0]
print(f"hypervolume before adding {point}: {moa.hypervolume}")
print(f"hypervolume improvement of point {point}: {moa.hypervolume_improvement(point)}")
moa.add(point)
print(f"hypervolume after adding {point}: {moa.hypervolume}")
hypervolume before adding [1, 3, 0]: 12
hypervolume improvement of point [1, 3, 0]: 6
hypervolume after adding [1, 3, 0]: 18
9. Distance to the empirical Pareto front
The distance_to_pareto_front(point) method returns the distance between the given point and the Pareto front.
python
print(f"Current archive: {list(moa)}")
print("Distance of [3, 2, 1] to pareto front:", moa.distance_to_pareto_front([3, 2, 1]))
print("Distance of [3, 2, 2] to pareto front:", moa.distance_to_pareto_front([3, 3, 3]))
Current archive: [[1, 3, 0], [3, 2, 1], [2, 2, 2], [1, 2, 3]]
Distance of [3, 2, 1] to pareto front: 0.0
Distance of [3, 2, 2] to pareto front: 1.0
10. Enabling or disabling fractions
To avoid loss of precision, fractions are used by default. This can be changed to floats by setting the hypervolume_final_float_type and hypervolume_computation_float_type function attributes.
```python import fractions getmoarchive.hypervolumecomputationfloattype = fractions.Fraction getmoarchive.hypervolumefinalfloattype = fractions.Fraction
moa3fr = getmoarchive([[1, 2, 3], [2, 1, 3], [3, 3, 1.32], [1.3, 1.3, 3], [1.7, 1.1, 2]], referencepoint=[4, 4, 4]) print(moa3_fr.hypervolume)
getmoarchive.hypervolumecomputationfloattype = float getmoarchive.hypervolumefinalfloattype = float
moa3nofr = getmoarchive([[1, 2, 3], [2, 1, 3], [3, 3, 1.32], [1.3, 1.3, 3], [1.7, 1.1, 2]], referencepoint=[4, 4, 4]) print(moa3_nofr.hypervolume) ```
161245156349030777798724819133399/10141204801825835211973625643008
15.899999999999999
Owner
- Name: CMA-ES
- Login: CMA-ES
- Kind: organization
- Repositories: 8
- Profile: https://github.com/CMA-ES
GitHub Events
Total
- Issues event: 12
- Issue comment event: 74
- Push event: 15
- Pull request event: 5
- Pull request review event: 20
- Pull request review comment event: 19
- Fork event: 1
- Create event: 1
Last Year
- Issues event: 12
- Issue comment event: 74
- Push event: 15
- Pull request event: 5
- Pull request review event: 20
- Pull request review comment event: 19
- Fork event: 1
- Create event: 1
Committers
Last synced: almost 3 years ago
All Time
- Total Commits: 66
- Total Committers: 1
- Avg Commits per committer: 66.0
- Development Distribution Score (DDS): 0.0
Top Committers
| Name | Commits | |
|---|---|---|
| nikohansen | n****n@i****r | 66 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 16
- Total pull requests: 9
- Average time to close issues: 14 days
- Average time to close pull requests: 20 days
- Total issue authors: 4
- Total pull request authors: 3
- Average comments per issue: 2.19
- Average comments per pull request: 0.89
- Merged pull requests: 5
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 8
- Pull requests: 7
- Average time to close issues: 22 days
- Average time to close pull requests: about 1 month
- Issue authors: 2
- Pull request authors: 1
- Average comments per issue: 3.25
- Average comments per pull request: 1.14
- Merged pull requests: 3
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- nikohansen (11)
- ttusar (4)
- mgharafi (1)
- brockho (1)
- naceee (1)
Pull Request Authors
- naceee (7)
- nikohansen (2)
- cjwatson (2)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 2
-
Total downloads:
- pypi 147 last-month
-
Total dependent packages: 2
(may contain duplicates) -
Total dependent repositories: 1
(may contain duplicates) - Total versions: 5
- Total maintainers: 4
pypi.org: moarchiving
This package implements a non-dominated archive for 2, 3 or 4 objectives with hypervolume indicator and uncrowded hypervolume improvement computation.
- Homepage: https://github.com/cma-es/moarchiving
- Documentation: https://moarchiving.readthedocs.io/
- License: other
-
Latest release: 1.0.0
published 11 months ago
Rankings
Maintainers (3)
spack.io: py-moarchiving
Biobjective Archive class with hypervolume indicator and uncrowded hypervolume improvement computation.
- Homepage: https://github.com/CMA-ES/moarchiving
- License: []
-
Latest release: 0.6.0
published over 2 years ago
Rankings
Maintainers (1)
Dependencies
- sortedcontainers >=2.4.0