SolutionPartitioner

Trait SolutionPartitioner 

Source
pub trait SolutionPartitioner<S: PlanningSolution>:
    Send
    + Sync
    + Debug {
    // Required methods
    fn partition(&self, solution: &S) -> Vec<S>;
    fn merge(&self, original: &S, partitions: Vec<S>) -> S;

    // Provided method
    fn recommended_partition_count(&self) -> Option<usize> { ... }
}
Expand description

Splits a solution into independent partitions for parallel solving.

Each partition should be solvable independently without affecting the correctness of other partitions. The partitioner must also be able to merge the solved partitions back into a complete solution.

§Type Parameters

  • S: The planning solution type

§Example

For a school timetabling problem, a natural partitioning might be by room or by time period, where each partition contains lessons that don’t interact with lessons in other partitions.

Required Methods§

Source

fn partition(&self, solution: &S) -> Vec<S>

Splits the solution into independent partitions.

Each returned solution should be a subset of the original that can be optimized independently. The union of all partitions should cover all entities in the original solution.

§Arguments
  • solution - The solution to partition
§Returns

A vector of partial solutions, one per partition.

Source

fn merge(&self, original: &S, partitions: Vec<S>) -> S

Merges solved partitions back into a complete solution.

This is called after all partitions have been solved to combine them into the final result.

§Arguments
  • original - The original unpartitioned solution
  • partitions - The solved partition solutions
§Returns

The merged complete solution.

Provided Methods§

Source

fn recommended_partition_count(&self) -> Option<usize>

Returns the recommended number of partitions.

This can be used by the partitioned search phase to determine how many threads to use. Returns None if no recommendation.

Implementors§

Source§

impl<S, PF, MF> SolutionPartitioner<S> for FunctionalPartitioner<S, PF, MF>
where S: PlanningSolution, PF: Fn(&S) -> Vec<S> + Send + Sync, MF: Fn(&S, Vec<S>) -> S + Send + Sync,