class MOArchive3obj(MOArchiveParent):
Class for storing a set of non-dominated points in 3 objective space and efficiently 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 third coordinate using function points_list.
>>> from moarchiving.get_archive import get_mo_archive >>> moa = get_mo_archive([[1, 2, 3], [3, 2, 1]]) >>> list(moa) # returns the list of points in the archive sorted by the third coordinate [[3, 2, 1], [1, 2, 3]] >>> moa.add([2, 2, 2]) # add a new point to the archive True >>> moa.add([3, 3, 3]) False >>> moa = get_mo_archive([[1, 2, 3], [2, 3, 4], [3, 2, 1]], ... reference_point=[4, 4, 4], infos=["A", "B", "C"]) >>> moa.infos # returns the list of infos for each point in the archive ['C', 'A'] >>> moa.hypervolume Fraction(10, 1) >>> get_mo_archive.hypervolume_final_float_type = float >>> get_mo_archive.hypervolume_computation_float_type = float >>> moa2 = get_mo_archive([[1, 2, 3], [2, 3, 4], [3, 2, 1]], reference_point=[4, 4, 4]) >>> moa2.hypervolume 10.0
Method | __init__ |
Create a new 3 objective archive object. |
Method | add |
Adds a new point to the archive, and updates the hypervolume if needed. |
Method | add |
Adds a list of points to the archive, and updates the hypervolume. |
Method | compute |
Compute the hypervolume of the current state of archive |
Method | copy |
Returns a copy of the archive |
Method | hypervolume |
Returns the hypervolume improvement of adding a point to the archive |
Method | preprocessing |
Preprocessing step to determine the closest points in x and y directions, as described in the paper and implemented in the original C code. |
Method | remove |
Removes a point from the archive, and updates the hypervolume. If the point is not found, it raises a ValueError. |
Method | _get |
Function that returns the kink points of the archive. |
Instance Variable | _hypervolume |
1) Set u.cx to the point q ∈ Q with the smallest q_x > u_x such that q_y < u_y and q <L u. If such a point is not unique, the alternative with the smallest q_y is preferred |
Instance Variable | _kink |
Undocumented |
Instance Variable | _length |
Undocumented |
Instance Variable | _removed |
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 |
Create a new 3 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.
Adds a new point to the archive, and updates the hypervolume if needed.
Returns True if the point was added, False if it was dominated by another point in the archive
>>> from moarchiving.get_archive import get_mo_archive >>> moa = get_mo_archive(reference_point=[4, 4, 4]) >>> moa.add([2, 3, 4]) False >>> moa.add([1, 2, 3]) True >>> list(moa) [[1, 2, 3]] >>> moa.add([3, 2, 1]) True >>> list(moa) [[3, 2, 1], [1, 2, 3]] >>> moa.add([2, 2, 2]) True >>> list(moa) [[3, 2, 1], [2, 2, 2], [1, 2, 3]]
Adds a list of points to the archive, and updates the hypervolume.
points are added with the add_method
method:
- compare: compares the number of points to add with the number of points in the archive and uses the most efficient method based on that
- one_by_one: adds the points one by one to the archive
- reinit: reinitializes the archive with the new points
>>> from moarchiving.get_archive import get_mo_archive >>> moa = get_mo_archive(reference_point=[4, 4, 4]) >>> moa.add_list([[2, 3, 3], [1, 2, 3]], infos=["A", "B"]) >>> list(moa), moa.infos ([[1, 2, 3]], ['B']) >>> moa.add_list([[3, 2, 1], [2, 2, 2], [3, 3, 3]], infos=["C", "D", "E"]) >>> list(moa), moa.infos ([[3, 2, 1], [2, 2, 2], [1, 2, 3]], ['C', 'D', 'B']) >>> moa.add_list([[1, 1, 1]]) >>> list(moa), moa.infos ([[1, 1, 1]], [None])
Compute the hypervolume of the current state of archive
>>> from moarchiving.get_archive import get_mo_archive >>> moa = get_mo_archive([[1, 2, 3], [3, 2, 1]], reference_point=[4, 4, 4]) >>> moa.compute_hypervolume() 10.0
Returns a copy of the archive
>>> from moarchiving.get_archive import get_mo_archive >>> moa = get_mo_archive([[1, 2, 3], [2, 2, 2], [3, 2, 1]], reference_point=[4, 4, 4], ... infos=["A", "B", "C"]) >>> moa2 = moa.copy() >>> list(moa2), moa2.infos ([[3, 2, 1], [2, 2, 2], [1, 2, 3]], ['C', 'B', 'A']) >>> moa.remove([2, 2, 2]) 'B' >>> moa2.add([1.5, 1.5, 1.5], "D") True >>> list(moa2), moa2.infos ([[3, 2, 1], [1.5, 1.5, 1.5], [1, 2, 3]], ['C', 'D', 'A']) >>> list(moa), moa.infos ([[3, 2, 1], [1, 2, 3]], ['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], [3, 2, 1]], reference_point=[4, 4, 4]) >>> moa.hypervolume_improvement([2, 2, 2]) 2.0 >>> moa.hypervolume_improvement([3, 3, 4]) -1.0
Preprocessing step to determine the closest points in x and y directions, as described in the paper and implemented in the original C code.
Removes a point from the archive, and updates the hypervolume. If the point is not found, it raises a ValueError.
Returns the info of the removed point.
>>> from moarchiving.get_archive import get_mo_archive >>> moa = get_mo_archive([[1, 2, 3], [2, 2, 2], [3, 2, 1]], reference_point=[4, 4, 4], ... infos=["A", "B", "C"]) >>> moa.remove([2, 2, 2]) 'B' >>> list(moa) [[3, 2, 1], [1, 2, 3]] >>> moa.remove([1, 2, 3]) 'A' >>> list(moa) [[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 2 objective archive of all possible kink points found so far, and another 2 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], [2, 2, 2], [3, 2, 1]], reference_point=[4, 4, 4]) >>> moa._get_kink_points() [[4, 4, 1], [3, 4, 2], [2, 4, 3], [1, 4, 4], [4, 2, 4]]
1) Set u.cx to the point q ∈ Q with the smallest q_x > u_x such that q_y < u_y and q <L u. If such a point is not unique, the alternative with the smallest q_y is preferred