Class RandomOperatorSelector<S extends Solution<S>>

java.lang.Object
io.github.nhtc2005.alns.selection.RandomOperatorSelector<S>
Type Parameters:
S - the solution type
All Implemented Interfaces:
OperatorSelector<S>

public final class RandomOperatorSelector<S extends Solution<S>> extends Object implements OperatorSelector<S>
Selects destroy and repair operators independently and uniformly using the search's random generator.
  • Constructor Details

    • RandomOperatorSelector

      public RandomOperatorSelector(int destroyOperatorCount, int repairOperatorCount)
      Creates a selector for fixed operator counts.
      Parameters:
      destroyOperatorCount - the positive number of destroy operators
      repairOperatorCount - the positive number of repair operators
      Throws:
      IllegalArgumentException - if either operator count is not positive
  • Method Details

    • validateOperatorCounts

      public void validateOperatorCounts(int destroyOperatorCount, int repairOperatorCount)
      Validates the operator counts when the solver is built.

      Selectors with fixed counts must check that both counts match their configuration. The default implementation does nothing.

      Specified by:
      validateOperatorCounts in interface OperatorSelector<S extends Solution<S>>
      Parameters:
      destroyOperatorCount - the positive number of configured destroy operators
      repairOperatorCount - the positive number of configured repair operators
      Throws:
      IllegalArgumentException - if either count differs from this selector's configured count
    • select

      public OperatorSelection select(OperatorSelectionContext<S> context)
      Description copied from interface: OperatorSelector
      Selects operator indices without modifying the solutions in the context.
      Specified by:
      select in interface OperatorSelector<S extends Solution<S>>
      Parameters:
      context - the non-null search context
      Returns:
      a non-null selection with zero-based indices within the configured operator lists
    • getDestroyOperatorCount

      public int getDestroyOperatorCount()
      Returns the configured number of destroy operators.
      Returns:
      the configured number of destroy operators
    • getRepairOperatorCount

      public int getRepairOperatorCount()
      Returns the configured number of repair operators.
      Returns:
      the configured number of repair operators