Skip to main content

SingleColdestStratified

Move Type: Basic Complexity: O(strata × sample_size) with coldest-first ordering

Move objects to the coldest (least loaded) containers within each stratum. Combines stratified sampling with capacity-aware greedy selection.

Overview

SingleColdestStratified evaluates single object moves to the coldest containers (containers with lowest load/potential) within each stratum. Unlike random stratified sampling, this move type preferentially targets underutilized containers, making it excellent for capacity balancing and bin-packing.

Use when:

  • Capacity balancing is critical
  • Want to fill underutilized containers
  • Containers group into natural strata
  • Bin-packing or consolidation scenarios

Avoid when:

  • Load balancing across all containers equally important
  • Containers are homogeneous (no strata)
  • "Coldest" doesn't align with objective
  • Need deterministic results

Quick Example

# Move to coldest containers per stratum (legacy string-based)
spec = LocalSearchSolverSpec(
stratifiedSampleSize=10, # Sample 10 coldest per stratum
moveTypeList=[
MoveTypeSpec(moveTypeName="SINGLE_COLDEST_STRATIFIED"),
],
)
solver.addSolver(SolverSpecs(localSearchSolverSpec=spec))

Parameters

Note: SingleColdestStratified uses the legacy string-based move type specification. Parameters are set on LocalSearchSolverSpec, not a dedicated move type spec.

ParameterTypeRequiredDefaultDescription
moveTypeNamestringYes-Set to "SINGLE_COLDEST_STRATIFIED"
stratifiedSampleSizeint32No10Sample size of coldest containers per stratum
includeEqualSizeRandomSampleForSingleColdestMoveTypeboolNofalseDouble sample size by adding random containers

Parameter Details

stratifiedSampleSize:

  • Number of coldest containers to sample per stratum
  • Containers are ranked by "coldness" (low load/potential)
  • Default: 10 containers per stratum

includeEqualSizeRandomSampleForSingleColdestMoveType:

  • When true: Sample k coldest + k random containers per stratum (total 2k)
  • When false: Sample only k coldest containers per stratum
  • Helps avoid getting stuck in local optima by adding randomness

How It Works

Given a hot container and object to move:

  1. Define strata: Group containers by scope or similarity
  2. Find coldest per stratum: Rank containers by coldness (low load)
  3. Sample coldest: Take stratifiedSampleSize coldest from each stratum
  4. Optional random: If enabled, add equal number of random containers
  5. Evaluate samples: Test moving object to each sampled container
  6. Apply best: Apply the move that improves objective most

What is "Coldest"?

A container is cold if it has:

  • Low container potential: Low contribution to objective
  • Few objects: Underutilized capacity
  • Spare capacity: Room to accept more objects

Coldness ranking: Lower potential = colder = more preferred

Visual Example

System with 5 regions (strata), sample size = 2:

Region 1 Region 2 Region 3 Region 4 Region 5
+-----------+ +-----------+ +-----------+ +-----------+ +-----------+
| Coldest 1 | ← | Coldest 1 | ← | Coldest 1 | ← | Coldest 1 | ← | Coldest 1 |
| Coldest 2 | ← | Coldest 2 | ← | Coldest 2 | ← | Coldest 2 | ← | Coldest 2 |
| (rest) | | (rest) | | (rest) | | (rest) | | (rest) |
+-----------+ +-----------+ +-----------+ +-----------+ +-----------+

Total evaluations: 2 × 5 = 10 coldest containers

With includeEqualSizeRandomSampleForSingleColdestMoveType=true:
2 coldest + 2 random per region = 4 per region
Total evaluations: 4 × 5 = 20 containers

Comparison with Variants

Move TypeSelection StrategyCoverageUse Case
SingleRandomStratifiedRandom per stratumBalancedGeneral stratified sampling
SingleColdestStratifiedColdest per stratumCapacity-awareBin-packing, consolidation
SingleRandomObjectStratifiedRandom objectsObject diversityObject-level stratification

Complexity

Moves evaluated per iteration: O(S × K)

Where:

  • S = stratifiedSampleSize (or 2×S if random sampling enabled)
  • K = number of strata

Example - Capacity balancing:

  • Regions (strata): 5
  • Sample per region: 10 coldest
  • Moves evaluated: 10 × 5 = 50
  • With random sampling: 20 × 5 = 100

Usage Patterns

Bin-Packing/Consolidation

Fill underutilized containers:

# Bin-packing: fill coldest (most empty) containers
solver.addGoal(
GoalSpecs(
minimizeContainersSpec=MinimizeContainersSpec(
name="minimize-containers",
scope="container",
)
),
weight=10.0,
)

spec = LocalSearchSolverSpec(
stratifiedSampleSize=10, # Try 10 coldest per stratum
moveTypeList=[
MoveTypeSpec(moveTypeName="SINGLE_COLDEST_STRATIFIED"),
],
)
solver.addSolver(SolverSpecs(localSearchSolverSpec=spec))

Capacity Balancing Across Regions

Balance load while respecting regions:

# Move to coldest servers in each region for capacity balancing
spec = LocalSearchSolverSpec(
stratifiedSampleSize=20, # Sample 20 coldest per region
moveTypeList=[
MoveTypeSpec(moveTypeName="SINGLE_COLDEST_STRATIFIED"),
],
)
solver.addSolver(SolverSpecs(localSearchSolverSpec=spec))

With Random Sampling for Diversity

Add randomness to avoid local optima:

# Include random sampling for diversity: k coldest + k random
spec = LocalSearchSolverSpec(
stratifiedSampleSize=10, # 10 coldest
includeEqualSizeRandomSampleForSingleColdestMoveType=True, # + 10 random = 20 total
moveTypeList=[
MoveTypeSpec(moveTypeName="SINGLE_COLDEST_STRATIFIED"),
],
)
solver.addSolver(SolverSpecs(localSearchSolverSpec=spec))

Server Decommissioning

Empty servers by moving to coldest alternatives:

# Decommission servers: move shards to coldest available servers
# Use with toFree or nonAccepting constraints to mark servers for decommission
spec = LocalSearchSolverSpec(
stratifiedSampleSize=15, # Try 15 coldest alternatives per region
moveTypeList=[
MoveTypeSpec(moveTypeName="SINGLE_COLDEST_STRATIFIED"),
],
)
solver.addSolver(SolverSpecs(localSearchSolverSpec=spec))

Performance Characteristics

Sample Size Tuning

Sample SizeRandom EnabledTotal Samples (5 strata)QualityUse Case
5No25LowVery fast, rough balancing
10 (default)No50MediumBalanced speed/quality
10Yes100HigherAdd diversity
20No100HighThorough coldest search
20Yes200HighestMaximum quality

When Does It Help?

SingleColdestStratified helps when:

  • Capacity imbalance: Some containers nearly full, others nearly empty
  • Bin-packing: Want to minimize active containers
  • Consolidation: Fill existing containers before using new ones
  • Stratified structure: Containers naturally group (regions, sizes)
  • Greedy works: Moving to coldest aligns with objective

SingleColdestStratified does NOT help when:

  • All containers similar load: No "cold" containers to target
  • Coldest ≠ best: Objective doesn't favor underutilized containers
  • Need randomness: Deterministic coldest selection gets stuck
  • Homogeneous containers: No meaningful stratification

Comparison with Variants

Move TypeSelectionRandomnessBest For
SingleAll containersNoneSmall, complete search
SingleFastEarly exitNoneMedium, fast
SingleRandomBatchesBatchesUniform randomLarge, parallel
SingleRandomStratifiedPer stratumStratified randomLarge, balanced
SingleColdestStratifiedColdest per stratumOptional randomCapacity balancing

Decision tree:

  1. Capacity balancing needed?SingleColdestStratified
  2. General stratified?SingleRandomStratified
  3. No stratification?Single or SingleFast

Troubleshooting

Problem: Always moving to same cold containers

Diagnosis: Sample size too small OR not using random sampling

Solutions:

  • Increase stratifiedSampleSize
  • Enable includeEqualSizeRandomSampleForSingleColdestMoveType=true
  • Check if "coldest" definition aligns with objective
  • May need different move type if cold containers filling up

Problem: Not balancing capacity well

Diagnosis: Coldness metric doesn't capture capacity

Solutions:

  • Verify objective function includes capacity terms
  • Check container potential calculation
  • May need explicit capacity constraints/goals
  • Consider MinimizeContainers goal

Problem: Getting stuck in local optimum

Diagnosis: Deterministic coldest selection

Solutions:

  • Enable includeEqualSizeRandomSampleForSingleColdestMoveType=true
  • Increase sample size for more options
  • Combine with SingleRandomStratified
  • Use multi-stage with different move types

Problem: Stratification not helping

Diagnosis: Strata not meaningful OR coldest similar across strata

Solutions:

  • Verify containers actually group into meaningful strata
  • Check coldness varies across strata
  • May need different stratification (different scope)
  • Consider SingleRandomBatches instead

When to Use SingleColdestStratified

DO use when:

  • Bin-packing or container consolidation
  • Capacity balancing across regions/groups
  • Filling underutilized containers
  • Decommissioning servers (move to cold alternatives)
  • Objective favors moving to less-loaded containers

DO NOT use when:

  • All containers equally loaded
  • Coldest selection doesn't align with objective
  • Need random exploration
  • Containers are homogeneous

Stratified variants:

Capacity-focused:

Use together:

  1. SingleColdestStratified for capacity balancing
  2. Swap for fine-tuning
  3. MinimizeContainers goal

Source Code

Next Steps