boofun.core.batch_processing

Comprehensive batch processing infrastructure for Boolean function operations.

This module provides efficient batch evaluation, vectorized operations, and parallel processing capabilities for Boolean functions across all representations.

Functions

get_batch_processor_stats()

Get batch processing statistics and capabilities.

process_batch(inputs, function_data, ...)

Process a batch of inputs efficiently.

set_batch_thresholds([vectorized_threshold, ...])

Set thresholds for batch processing strategies.

Classes

BatchProcessor()

Abstract base class for batch processing strategies.

BatchProcessorManager()

Manages batch processing strategies for different representations.

OptimizedANFProcessor([chunk_size])

Optimized batch processor for ANF representations.

OptimizedFourierProcessor([chunk_size])

Optimized batch processor for Fourier expansion representations.

OptimizedTruthTableProcessor([chunk_size])

Optimized batch processor for truth table representations.

ParallelBatchProcessor([n_workers, ...])

Parallel batch processor using multiprocessing.

VectorizedBatchProcessor([chunk_size])

Vectorized batch processor using NumPy operations.

class boofun.core.batch_processing.BatchProcessor[source]

Abstract base class for batch processing strategies.

abstractmethod process_batch(inputs: ndarray, function_data: Any, space: Space, n_vars: int) ndarray[source]

Process a batch of inputs.

abstractmethod supports_representation(representation: str) bool[source]

Check if processor supports a representation.

class boofun.core.batch_processing.VectorizedBatchProcessor(chunk_size: int = 10000)[source]

Vectorized batch processor using NumPy operations.

Optimized for representations that can leverage NumPy’s vectorization.

__init__(chunk_size: int = 10000)[source]

Initialize vectorized processor.

Parameters:

chunk_size – Size of chunks for memory-efficient processing

process_batch(inputs: ndarray, function_data: Any, space: Space, n_vars: int) ndarray[source]

Process batch using vectorized operations.

supports_representation(representation: str) bool[source]

Check if representation is supported.

class boofun.core.batch_processing.ParallelBatchProcessor(n_workers: int | None = None, use_processes: bool = True)[source]

Parallel batch processor using multiprocessing.

Distributes work across multiple CPU cores for compute-intensive operations.

__init__(n_workers: int | None = None, use_processes: bool = True)[source]

Initialize parallel processor.

Parameters:
  • n_workers – Number of worker processes/threads (default: CPU count)

  • use_processes – Whether to use processes (True) or threads (False)

process_batch(inputs: ndarray, function_data: Any, space: Space, n_vars: int) ndarray[source]

Process batch using parallel workers.

supports_representation(representation: str) bool[source]

Check if representation is supported.

class boofun.core.batch_processing.OptimizedTruthTableProcessor(chunk_size: int = 100000)[source]

Optimized batch processor for truth table representations.

__init__(chunk_size: int = 100000)[source]

Initialize vectorized processor.

Parameters:

chunk_size – Size of chunks for memory-efficient processing

class boofun.core.batch_processing.OptimizedFourierProcessor(chunk_size: int = 50000)[source]

Optimized batch processor for Fourier expansion representations.

__init__(chunk_size: int = 50000)[source]

Initialize vectorized processor.

Parameters:

chunk_size – Size of chunks for memory-efficient processing

class boofun.core.batch_processing.OptimizedANFProcessor(chunk_size: int = 50000)[source]

Optimized batch processor for ANF representations.

__init__(chunk_size: int = 50000)[source]

Initialize vectorized processor.

Parameters:

chunk_size – Size of chunks for memory-efficient processing

class boofun.core.batch_processing.BatchProcessorManager[source]

Manages batch processing strategies for different representations.

Automatically selects the best processor based on representation type, input size, and available hardware.

__init__()[source]

Initialize batch processor manager.

process_batch(inputs: ndarray, function_data: Any, representation: str, space: Space, n_vars: int) ndarray[source]

Process batch using optimal strategy.

Parameters:
  • inputs – Batch of inputs to process

  • function_data – Representation-specific function data

  • representation – Representation type

  • space – Mathematical space

  • n_vars – Number of variables

Returns:

Batch evaluation results

get_processor_stats() Dict[str, Any][source]

Get statistics about available processors.

boofun.core.batch_processing.process_batch(inputs: ndarray, function_data: Any, representation: str, space: Space, n_vars: int) ndarray[source]

Process a batch of inputs efficiently.

Parameters:
  • inputs – Batch of inputs

  • function_data – Representation-specific data

  • representation – Representation type

  • space – Mathematical space

  • n_vars – Number of variables

Returns:

Batch evaluation results

boofun.core.batch_processing.get_batch_processor_stats() Dict[str, Any][source]

Get batch processing statistics and capabilities.

boofun.core.batch_processing.set_batch_thresholds(vectorized_threshold: int = 1000, parallel_threshold: int = 10000)[source]

Set thresholds for batch processing strategies.

Parameters:
  • vectorized_threshold – Minimum size for vectorized processing

  • parallel_threshold – Minimum size for parallel processing