Skip to content

Class swarmauri_core.evaluators.IEvaluate.IEvaluate

swarmauri_core.evaluators.IEvaluate.IEvaluate

Bases: ABC

Interface for program evaluation functions.

This abstract class defines the contract that all evaluators must implement, providing methods to assess program fitness according to specific criteria. Evaluators must be stateless to allow for parallel execution.

evaluate abstractmethod

evaluate(program, **kwargs)

Evaluate a program and return a fitness score with metadata.

This method assesses the fitness of a program according to specific criteria and returns both a scalar score and detailed metadata about the evaluation.

PARAMETER DESCRIPTION
program

The program to evaluate

TYPE: IProgram

**kwargs

Additional parameters for the evaluation process

DEFAULT: {}

RETURNS DESCRIPTION
Tuple[float, Dict[str, Any]]

A tuple containing: - float: A scalar fitness score (higher is better) - Dict[str, Any]: Metadata about the evaluation, including feature dimensions

RAISES DESCRIPTION
EvaluationError

If the evaluation process fails

TypeError

If the program is not of the expected type

Source code in swarmauri_core/evaluators/IEvaluate.py
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
@abstractmethod
def evaluate(self, program: IProgram, **kwargs) -> Tuple[float, Dict[str, Any]]:
    """
    Evaluate a program and return a fitness score with metadata.

    This method assesses the fitness of a program according to specific criteria
    and returns both a scalar score and detailed metadata about the evaluation.

    Args:
        program: The program to evaluate
        **kwargs: Additional parameters for the evaluation process

    Returns:
        A tuple containing:
            - float: A scalar fitness score (higher is better)
            - Dict[str, Any]: Metadata about the evaluation, including feature dimensions

    Raises:
        EvaluationError: If the evaluation process fails
        TypeError: If the program is not of the expected type
    """
    pass

reset abstractmethod

reset()

Reset the evaluator to its initial state.

This method should clear any internal state or cached data to ensure that the evaluator is ready for a new evaluation cycle.

Source code in swarmauri_core/evaluators/IEvaluate.py
51
52
53
54
55
56
57
58
59
@abstractmethod
def reset(self) -> None:
    """
    Reset the evaluator to its initial state.

    This method should clear any internal state or cached data to ensure
    that the evaluator is ready for a new evaluation cycle.
    """
    pass