Skip to main content

DiscoveryResult Class

Description

The DiscoveryResult dataclass contains all information about a completed discovery run, including the best solution found, its score, detailed metrics, and the location of output files.

Fields

Optional[Program]
The best Program object found during discovery, or None if no valid programs were produced.Contains detailed information including solution code, metrics, lineage, and metadata.
float
Score of the best program. Extracted from the combined_score metric or aggregated from other metrics.Always a float value; 0.0 if no valid programs were found.
str
Source code of the best solution as a string.Empty string if no valid programs were found.
Dict[str, Any]
Detailed metrics dictionary returned by the evaluator for the best program.Common keys:
  • combined_score: Overall score
  • Custom metrics defined by your evaluator
Empty dictionary if no valid programs were found.
Optional[str]
Path to the directory containing results, logs, and checkpoints.None if cleanup=True was used (temporary files removed).
Optional[float]
Score of the initial program (if one was provided).None if:
  • No initial program was provided
  • Initial program evaluation failed
  • Score could not be determined

Methods

repr

Returns: Human-readable string showing best score and initial score. Example output: DiscoveryResult(best_score=0.8750, initial_score=0.4200)

Program Class

Program Fields

str
Unique identifier for the program (UUID).
str
Source code of the program.
str
Programming language (e.g., “python”, “cpp”, “javascript”).Default: "python"
Dict[str, Any]
Evaluation metrics returned by the evaluator.Typically includes:
  • combined_score: Overall score used for ranking
  • Custom metrics specific to your problem
int
Iteration number when this program was discovered.Default: 0 (initial program)
Optional[str]
ID of the parent program this was mutated from.None for initial programs or programs generated from scratch.
Optional[List[str]]
List of IDs of other programs provided as context during generation.Used by search algorithms for crossover or learning from multiple examples.
Optional[Tuple[str, str]]
Additional information about the parent program as (label, description).
Optional[List[Tuple[str, str]]]
Additional information about context programs as list of (label, description) tuples.
float
Unix timestamp when the program was created.
Dict[str, Any]
Additional metadata about the program.Example keys:
  • image_path: For image generation tasks
  • Custom tracking information
Dict[str, Any]
Artifacts produced during evaluation (e.g., test outputs, visualizations).
Optional[Dict[str, Any]]
Prompts used to generate this program (if prompt logging is enabled).
int
Generation number in the evolutionary process.Default: 0

Program Methods

to_dict

Returns: Dictionary containing all program fields.

from_dict

Parameters:
  • data: Dictionary containing program fields
Returns: New Program instance.

Examples

Basic Result Inspection

Accessing Detailed Metrics

Accessing the Program Object

Saving Results

Comparing Multiple Runs

Working with Program Lineage

Converting Program to Dictionary

Checking Result Status

Notes

  • DiscoveryResult is a dataclass, so all fields can be accessed as attributes
  • The best_program field contains the full Program object with lineage information
  • Use best_solution for quick access to just the source code
  • metrics contains all evaluation metrics, not just the score
  • output_dir is None when cleanup=True (temporary files removed)
  • The initial_score helps measure improvement over the starting solution
  • Program objects can be serialized to/from dictionaries for storage

See Also