Module documentation¶
Module for enumerating and visualising non-dominated points.
This module comprises classes for different feasible domains, a class for multiple objectives and a class for enumerating and visualising different subsets of (non-dominated) points.
Available classes¶
GenericDomain
- represents the feasible domain of a(n abstract) generic optimisation problem.
AssignmentDomain
- represents the feasible domain of an assignment problem.
CubeDomain
- represents the feasible domain given by the vertices of a standard cube.
ExplicitDomain
- represents the feasible domain given by an explicitly given set of feasible solutions.
Objectives
- represents the objectives of a multi-criteria optimisation problem.
PolyNondom
- enumerates and visualises different sets of (non-dominated) points.
-
class
polynondom.
AssignmentDomain
(agents)[source]¶ Bases:
polynondom.GenericDomain
Feasible domain of an assignment problem.
The assignment problem has a number of agents and a(n equal) number of tasks. Any agent can be assigned to perform any task. A feasible solution is given by an assignment of agents to tasks in such a way that each agent is one task and all tasks are assigned by exactly by one agent.
Variables: num_agents (int) – Number of agents of corresponding assignment problem Example: ad = AssignmentDomain(4)
-
class
polynondom.
CubeDomain
(dim)[source]¶ Bases:
polynondom.GenericDomain
Feasible domain given by the vertices of an n-dimensional standard cube.
Example: cd = CubeDomain(3)
-
exception
polynondom.
Error
[source]¶ Bases:
Exception
Base class for exceptions.
-
with_traceback
()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
-
class
polynondom.
ExplicitDomain
(dim, domain)[source]¶ Bases:
polynondom.GenericDomain
Explicitely given feasible domain.
Variables: domain (Iterable) – Feasible domain Example: ed = ExplicitDomain(3, some_iterable)
-
class
polynondom.
GenericDomain
(dim)[source]¶ Bases:
object
Feasible domain of a generic optimisation problem.
Variables: dim (int) – Dimension of feasible domain Note
Do not use this class directly.
-
exception
polynondom.
InfeasibleBoxError
[source]¶ Bases:
polynondom.Error
Rectangular box is infeasible.
-
with_traceback
()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
-
class
polynondom.
Objectives
[source]¶ Bases:
object
Represents the objectives of a multi-criteria optimisation problem.
Variables: objectives (list) – Objective functions -
__call__
(sol)[source]¶ Point in objective space corresponding to given solution.
Parameters: sol (Iterable) – Feasible solution Returns: Image in objective space Return type: tuple
-
obj
¶ Objective functions
Getter: Returns objectives as list of tuples Setter: Appends objective (given by an Iterable) to list Example: mult_crit.obj = [3, 2, -1] where mult_crit = Objectives()
-
classmethod
read
(file, *, delimiter=' ')[source]¶ Read objectives given via file.
Parameters: Return type: Raises: - FileNotFoundError – if file cannot be found
- PermissionError – if file cannot be opened
Example: obj = Objectives.read(filename, delimiter=’,’) where filename corresponds to the location of the input file
-
-
class
polynondom.
Points
(identifier, color)[source]¶ Bases:
object
Represents certain set of points in objective space.
Variables: -
add_visualised_items
(items)[source]¶ Add items to container storing visualised objects.
Parameters: items ( matplotlib.collections.PathCollection
) – Visualised items
-
-
class
polynondom.
PolyNondom
[source]¶ Bases:
object
Enumerates and visualises different sets of (non-dominated) points.
- non-dominated point
- A point y is non-dominated (in the point set P) if there is no other point z in P such that z_i <= y_i for all i with at least one strict inequality.
- dominated point
- A point is y is dominated if y is not non-dominated.
- polynon-dominated point
- A non-dominated point y is polynon-dominated (w.r.t. the underlying multi-objective problem) if the projection of the point is also non-dominated for the given multi-objective problem where one of the objectives was neglected
- mononon-dominated point
- A non-dominated point y is mononon-dominated if y is not polynon-dominated.
See also the mathematical definitions
Variables: - _dim (int) – Dimension of objective space
- _fig (Figure) – Figure object of matplotlib
- _ax (Axes) – Axes object of matplotlib
- _message (str) – Info message
- points (dict) – Maps indentifier to
Points
- obj_to_polynd_points (list) – maps objective to polynon-dominated points
- polynd_boxes (list) – Container for feasible boxes given by polynon-dominated points
- _ax_limits (dict) – Maps coordinate axes to axes limits used in visualisation
- _ax_setter (dict) – Maps coordinate axes to matplotlib functions used for setting axes limits
-
classmethod
compute_points
(domain, objectives)[source]¶ Computes points sets based on given feasible domain and objectives.
Computes dominated, non-dominated, polynon-dominated and mononon-dominated points in objective space based on given domain and objectives.
Parameters: - domain (GenericDomain) – Feasible domain
- objectives (Objectives) – Objective functions
Return type: Example: ins = PolyNondom.compute_points(feas_dom, mult_crit) where feas_dom corresponds to
GenericDomain
and mult_crit corresponds toObjectives
-
classmethod
read_points
(file, *, delimiter=' ', all_nondom=False)[source]¶ Read points given via file.
Reads all points given via file, computes dominated, non-dominated, polynon-dominated and mononon-dominated points and returns corresponding instance.
Parameters: Return type: Raises: - FileNotFoundError – if file cannot be found
- PermissionError – if file cannot be opened
Example: ins = PolyNondom.read_points(filename, delimiter=’,’) where filename corresponds to the location of the input file
-
visualise
(id, *, my_color=None, my_width=0.8, my_style='--', my_marker='o', my_marker_size=40, with_lines=True)[source]¶ Visualises point sets corresponding to id.
Parameters: - id (str) – identifier corresponding to (combinations of) ‘d’ominated, ‘n’on-dominated, ‘p’olynon-dominated, ‘m’ononon-dominated points
- my_color (str) – color to use for visualisation (Defaults are dominated points - black, non-domintated points - blue, polynon-dominated points - green, mononon-dominated points - brown
- my_width (float) – width of lines (Default is 0.8)
- my_style (str) – style used for lines (Default is ‘–’)
- my_marker (str) – marker used for points (Default is ‘o’)
- my_marker_size (int) – size used for marker (Default is 40)
- with_lines (bool) – Specifier if lines should be visualised in the 3d case (Default is True)
Example: ins.visualise(‘dp’, my_color=’blue’)
-
visualise_box
(interval1, interval2, interval3=None, *, my_face_color='blue', my_alpha=0.2)[source]¶ Visualises given rectangular box.
Parameters: - interval1 (tuple) – first interval in Cartesian product corresponding to box
- interval2 (tuple) – second interval in Cartesian product corresponding to box
- interval3 (tuple) – (in 3d case) third interval in Cartesian product corresponding to box
- my_face_color (str) – color used to visualise faces of box (Default is blue)
- my_alpha (float) – alpha value used for coloring faces
Example: ins.visualise_box((3, 4), (5, 7), (3, 5), my_face_color=’red’)
Todo
Adjust size of figure to include box in any case.