The Metric class currently mixes two concerns:
- Metric definition (what the metric is: name, comparison method)
- Metric value(a specific measurement: the numeric value)
This causes:
- Memory inefficiency: Each solution creates a new MetricComparator instance even when using the same comparison method
- Conceptual confusion: The class violates single responsibility principle
- TODO comment in code indicates this needs refactoring (line 101 in metric.py)
Expected Behavior
- Separate metric type definition from metric value
- Share comparator instances across all solutions using the same comparison method
- Reduce memory usage by reusing comparator objects
- Maintain full backward compatibility with existing API
Impact
When running with max_iterations=10, we create 10 identical MetricComparator objects instead of sharing one. This wastes memory and makes the code harder to maintain.