Skip to content

Resource Estimation and Feasibility Preflight

evobench.tools.resources provides lightweight preflight utilities to estimate the computational cost of an experiment before executing it.

This submodule is useful when a planned experiment increases dimensionality, population size, number of generations, or independent runs. It does not replace real profiling, but it helps classify configurations as operationally reasonable or expensive.

Why this belongs in tools/

Resource estimation is not an optimizer, benchmark function, or statistical test. It is an experiment-planning tool. For that reason, the recommended location is:

src/evobench/tools/resources/

This keeps the architecture aligned with evobench's current structure:

Package area Responsibility
algorithms/ Optimization algorithms such as PSO, EDA and ABC
benchmarks/ Objective functions such as Sphere, Ackley and Rosenbrock
stats/ Statistical testing and post-hoc analysis
tools/ Experiment execution, plotting, operators and resource planning

Public imports

Use the tools namespace for user-facing resource planning:

from evobench.tools import FeasibilityBudget, estimate_feasibility
from evobench.tools import estimate_algorithm_memory_mb
from evobench.tools import estimate_runtime_seconds

Advanced users may also import from the submodule directly:

from evobench.tools.resources import RuntimeBaseline

Memory estimation

from evobench.tools import estimate_algorithm_memory_mb

memory_mb = estimate_algorithm_memory_mb(
    algorithm_name="pso",
    population_size=1000,
    dim=100,
)

print(f"Estimated memory: {memory_mb:.2f} MiB")

The default model estimates a population-like array and multiplies it by an algorithm-specific working-memory multiplier.

Default algorithm keys include:

Algorithm Key
Particle Swarm Optimization pso
Estimation of Distribution Algorithm eda
Artificial Bee Colony abc

Runtime estimation

from evobench.tools import estimate_runtime_seconds

seconds = estimate_runtime_seconds(
    algorithm_name="pso",
    dim=100,
    population_size=1000,
    generations=10,
)

print(f"Estimated runtime: {seconds:.2f} seconds")

Runtime estimation uses configurable empirical baselines. These defaults are planning references, not hardware guarantees.

Feasibility report

from evobench.tools import FeasibilityBudget, estimate_feasibility

report = estimate_feasibility(
    algorithm_name="pso",
    dim=5000,
    population_size=50000,
    generations=10,
    budget=FeasibilityBudget(
        max_dimension=100,
        max_population_size=1000,
        max_estimated_memory_mb=1024,
        max_estimated_seconds=30,
    ),
)

print(report.to_dict())

The report tells the user whether the configuration is feasible under the selected budget and explains the reasons when it is not.

Custom algorithms

For external algorithms, provide both memory and runtime assumptions:

from evobench.tools import RuntimeBaseline, estimate_feasibility

report = estimate_feasibility(
    algorithm_name="my_ga",
    dim=500,
    population_size=5000,
    generations=20,
    memory_multipliers={
        "my_ga": 5.5,
    },
    runtime_baselines={
        "my_ga": RuntimeBaseline(
            seconds=0.75,
            dim=100,
            population_size=1000,
            generations=10,
            complexity="linear_units",
        ),
    },
)

Supported runtime complexity models:

Model Interpretation
linear_units Scales with generations * population_size * dim
quadratic_dim Adds stronger dimension sensitivity
cubic_dim Conservative option for algorithms with expensive high-dimensional matrix operations
  1. Define the benchmark dimension and population size.
  2. Estimate feasibility before launching a full experiment.
  3. Run the experiment only if the report is feasible.
  4. If infeasible, reduce dimension, population size, generations, or independent runs.
  5. Calibrate baselines with local measurements when preparing formal experimental reports.