eckity.statistics.statistics

 1from sys import stdout
 2from abc import abstractmethod
 3
 4
 5class Statistics:
 6    """
 7    Abstract Statistics class.
 8    Provides statistics about the current evolution state.
 9
10    Parameters
11    ----------
12    format_string: str
13        String format of the data to output.
14        Value depends on the information the statistics provides.
15        For more information, check out the concrete classes who extend this class.
16
17    output_stream: Optional[SupportsWrite[str]], default=stdout
18        Output file for the statistics.
19        By default, the statistics will be written to stdout.
20    """
21    def __init__(self, format_string, output_stream=stdout):
22        self.output_stream = output_stream
23        self.format_string = format_string
24
25    @abstractmethod
26    def write_statistics(self, sender, data_dict):
27        """
28        Write the statistics information using the format string field to the output stream field.
29
30        Parameters
31        ----------
32        sender: object
33            The object that this statistics provides information about.
34            This class registers to a certain event that the sender object publishes.
35            The statistics are shown as a callback to the event publication.
36            For example, we can register a concrete Statistics sub-class to provide statistics after every generation
37            of a concrete Algorithm sub-class.
38
39        data_dict: dict(str, object)
40            Relevant data to the statistics. Used to gain and provide information from the sender.
41
42        Returns
43        -------
44        None.
45        """
46        pass
class Statistics:
 6class Statistics:
 7    """
 8    Abstract Statistics class.
 9    Provides statistics about the current evolution state.
10
11    Parameters
12    ----------
13    format_string: str
14        String format of the data to output.
15        Value depends on the information the statistics provides.
16        For more information, check out the concrete classes who extend this class.
17
18    output_stream: Optional[SupportsWrite[str]], default=stdout
19        Output file for the statistics.
20        By default, the statistics will be written to stdout.
21    """
22    def __init__(self, format_string, output_stream=stdout):
23        self.output_stream = output_stream
24        self.format_string = format_string
25
26    @abstractmethod
27    def write_statistics(self, sender, data_dict):
28        """
29        Write the statistics information using the format string field to the output stream field.
30
31        Parameters
32        ----------
33        sender: object
34            The object that this statistics provides information about.
35            This class registers to a certain event that the sender object publishes.
36            The statistics are shown as a callback to the event publication.
37            For example, we can register a concrete Statistics sub-class to provide statistics after every generation
38            of a concrete Algorithm sub-class.
39
40        data_dict: dict(str, object)
41            Relevant data to the statistics. Used to gain and provide information from the sender.
42
43        Returns
44        -------
45        None.
46        """
47        pass

Abstract Statistics class. Provides statistics about the current evolution state.

Parameters
  • format_string (str): String format of the data to output. Value depends on the information the statistics provides. For more information, check out the concrete classes who extend this class.
  • output_stream (Optional[SupportsWrite[str]], default=stdout): Output file for the statistics. By default, the statistics will be written to stdout.
Statistics(format_string, output_stream=<_io.StringIO object>)
22    def __init__(self, format_string, output_stream=stdout):
23        self.output_stream = output_stream
24        self.format_string = format_string
output_stream
format_string
@abstractmethod
def write_statistics(self, sender, data_dict):
26    @abstractmethod
27    def write_statistics(self, sender, data_dict):
28        """
29        Write the statistics information using the format string field to the output stream field.
30
31        Parameters
32        ----------
33        sender: object
34            The object that this statistics provides information about.
35            This class registers to a certain event that the sender object publishes.
36            The statistics are shown as a callback to the event publication.
37            For example, we can register a concrete Statistics sub-class to provide statistics after every generation
38            of a concrete Algorithm sub-class.
39
40        data_dict: dict(str, object)
41            Relevant data to the statistics. Used to gain and provide information from the sender.
42
43        Returns
44        -------
45        None.
46        """
47        pass

Write the statistics information using the format string field to the output stream field.

Parameters
  • sender (object): The object that this statistics provides information about. This class registers to a certain event that the sender object publishes. The statistics are shown as a callback to the event publication. For example, we can register a concrete Statistics sub-class to provide statistics after every generation of a concrete Algorithm sub-class.
  • data_dict (dict(str, object)): Relevant data to the statistics. Used to gain and provide information from the sender.
Returns
  • None.