class MOArchive4obj(MOArchiveParent):
Class for storing a set of non-dominated points in 4 objective space and calculating hypervolume with respect to the given reference point.
The archive is implemented as a doubly linked list, and can be modified using functions add and remove. Points of the archive can be accessed as a list of points order by the fourth coordinate using function points_list. >>> from moarchiving.get_archive import get_mo_archive >>> moa = get_mo_archive([[1, 2, 3, 4], [4, 3, 2, 1]]) >>> list(moa) # returns the list of points in the archive sorted by the third coordinate [[4, 3, 2, 1], [1, 2, 3, 4]] >>> moa.add([2, 2, 2, 2]) # add a new point to the archive True >>> moa.add([3, 3, 3, 3]) False >>> get_mo_archive.hypervolume_final_float_type = fractions.Fraction >>> moa = get_mo_archive([[1, 2, 3, 4], [2, 3, 4, 5], [4, 3, 2, 1]], ... reference_point=[5, 5, 5, 5], infos=["A", "B", "C"]) >>> moa.infos # returns the list of infos for each point in the archive ['C', 'A'] >>> moa.hypervolume Fraction(44, 1) >>> get_mo_archive.hypervolume_final_float_type = float >>> get_mo_archive.hypervolume_computation_float_type = float >>> moa2 = get_mo_archive([[1, 2, 3, 4], [2, 3, 4, 5], [4, 3, 2, 1]], ... reference_point=[5, 5, 5, 5]) >>> moa2.hypervolume 44.0
Method | __init__ |
Create a new 4 objective archive object. |
Method | add |
Add a new point to the archive. |
Method | add |
Add a list of points to the archive. |
Method | compute |
Compute the hypervolume of the archive. |
Method | copy |
Return a copy of the archive. |
Method | hypervolume |
Returns the hypervolume improvement of adding a point to the archive |
Method | remove |
Remove a point from the archive. |
Method | remove |
Preprocessing step to remove dominated points. |
Method | _get |
Function that returns the kink points of the archive. |
Instance Variable | _hypervolume |
Undocumented |
Instance Variable | _hypervolume |
Undocumented |
Instance Variable | _length |
Undocumented |
Inherited from MOArchiveParent
:
Method | __iter__ |
Undocumented |
Method | __len__ |
Undocumented |
Method | contributing |
Return the hypervolume contribution of a point in the archive |
Method | distance |
Return the distance to the hypervolume area of the archive |
Method | distance |
Return the distance to the Pareto front of the archive, by calculating the distances to the kink points |
Method | dominates |
return True if any element of points dominates or is equal to f_val . Otherwise return False . |
Method | dominators |
return the list of all f_val -dominating elements in self , including an equal element. len(....dominators(...)) is hence the number of dominating elements which can also be obtained without creating the list with ... |
Method | in |
return True if f_vals is dominating the reference point, False otherwise. True means that f_vals contributes to the hypervolume if not dominated by other elements. |
Instance Variable | head |
Undocumented |
Instance Variable | hypervolume |
Undocumented |
Instance Variable | hypervolume |
Undocumented |
Instance Variable | n |
Undocumented |
Instance Variable | reference |
Undocumented |
Property | contributing |
list of hypervolume contributions of each point in the archive |
Property | hypervolume |
Return the hypervolume of the archive |
Property | hypervolume |
Return the hypervolume_plus of the archive |
Property | infos |
list of complementary information corresponding to each archive entry, corresponding to each of the points in the archive |
Method | _points |
returns the points in the archive in a form of a python generator instead of a circular doubly linked list |
Method | _set_ |
Set the hypervolume of the archive |
Instance Variable | _hypervolume |
Undocumented |
Instance Variable | _kink |
Undocumented |
Create a new 4 objective archive object.
f-vals beyond the reference_point
are pruned away. The reference_point
is also used
to compute the hypervolume.
infos are an optional list of additional information about the points in the archive.
Add a new point to the archive.
update_hypervolume should be set to True, unless adding multiple points at once, in which case it is slightly more efficient to set it to True only for last point
>>> from moarchiving.get_archive import get_mo_archive >>> moa = get_mo_archive(reference_point=[5, 5, 5, 5]) >>> moa.add([2, 3, 4, 5]) False >>> moa.add([1, 2, 3, 4]) True >>> list(moa) [[1, 2, 3, 4]] >>> moa.add([4, 3, 2, 1]) True >>> list(moa) [[4, 3, 2, 1], [1, 2, 3, 4]] >>> moa.add([2, 2, 2, 2]) True >>> list(moa) [[4, 3, 2, 1], [2, 2, 2, 2], [1, 2, 3, 4]]
Add a list of points to the archive.
>>> from moarchiving.get_archive import get_mo_archive >>> moa = get_mo_archive(reference_point=[5, 5, 5, 5]) >>> moa.add_list([[1, 2, 4, 4], [1, 2, 3, 4]], infos=["A", "B"]) >>> list(moa), moa.infos ([[1, 2, 3, 4]], ['B']) >>> moa.add_list([[4, 3, 2, 1], [2, 2, 2, 2], [3, 3, 3, 3]], infos=["C", "D", "E"]) >>> list(moa), moa.infos ([[4, 3, 2, 1], [2, 2, 2, 2], [1, 2, 3, 4]], ['C', 'D', 'B']) >>> moa.add_list([[1, 1, 1, 1]]) >>> list(moa), moa.infos ([[1, 1, 1, 1]], [None])
Compute the hypervolume of the archive.
>>> from moarchiving.get_archive import get_mo_archive >>> moa = get_mo_archive([[1, 2, 3, 4], [4, 3, 2, 1]], reference_point=[5, 5, 5, 5]) >>> moa.compute_hypervolume() 44.0
Return a copy of the archive.
>>> from moarchiving.get_archive import get_mo_archive >>> moa = get_mo_archive([[1, 2, 3, 4], [2, 2, 2, 2], [4, 3, 2, 1]], ... reference_point=[5, 5, 5, 5], infos=["A", "B", "C"]) >>> moa2 = moa.copy() >>> list(moa2), moa2.infos ([[4, 3, 2, 1], [2, 2, 2, 2], [1, 2, 3, 4]], ['C', 'B', 'A']) >>> moa.remove([2, 2, 2, 2]) 'B' >>> moa2.add([0, 1, 3, 1.5], "D") True >>> list(moa2), moa2.infos ([[4, 3, 2, 1], [0, 1, 3, 1.5], [2, 2, 2, 2]], ['C', 'D', 'B']) >>> list(moa), moa.infos ([[4, 3, 2, 1], [1, 2, 3, 4]], ['C', 'A'])
Returns the hypervolume improvement of adding a point to the archive
>>> from moarchiving.get_archive import get_mo_archive >>> moa = get_mo_archive([[1, 2, 3, 4], [4, 3, 2, 1]], reference_point=[5, 5, 5, 5]) >>> moa.hypervolume_improvement([2, 2, 2, 2]) 49.0 >>> moa.hypervolume_improvement([3, 3, 4, 5]) -1.0
Remove a point from the archive.
Returns False if the point is not in the archive and it's Info if the point is removed
>>> from moarchiving.get_archive import get_mo_archive >>> moa = get_mo_archive([[1, 2, 3, 4], [2, 2, 2, 2], [4, 3, 2, 1]], ... reference_point=[5, 5, 5, 5], infos=["A", "B", "C"]) >>> moa.remove([2, 2, 2, 2]) 'B' >>> list(moa) [[4, 3, 2, 1], [1, 2, 3, 4]] >>> moa.remove([1, 2, 3, 4]) 'A' >>> list(moa) [[4, 3, 2, 1]]
Function that returns the kink points of the archive.
Kink point are calculated by making a sweep of the archive, where the state is one 3 objective archive of all possible kink points found so far, and another 3 objective archive which stores the non-dominated points so far in the sweep
>>> from moarchiving.get_archive import get_mo_archive >>> moa = get_mo_archive([[1, 2, 3, 4], [4, 3, 2, 1]], reference_point=[5, 5, 5, 5]) >>> moa._get_kink_points() [[5, 5, 5, 1], [5, 3, 5, 4], [4, 5, 5, 4], [5, 5, 2, 5], [5, 3, 3, 5], [4, 5, 3, 5], [5, 2, 5, 5], [1, 5, 5, 5]]