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 Summary
ConstructorsConstructorDescriptionRandomOperatorSelector(int destroyOperatorCount, int repairOperatorCount) Creates a selector for fixed operator counts. -
Method Summary
Modifier and TypeMethodDescriptionintReturns the configured number of destroy operators.intReturns the configured number of repair operators.select(OperatorSelectionContext<S> context) Selects operator indices without modifying the solutions in the context.voidvalidateOperatorCounts(int destroyOperatorCount, int repairOperatorCount) Validates the operator counts when the solver is built.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.github.nhtc2005.alns.selection.OperatorSelector
reset, update
-
Constructor Details
-
RandomOperatorSelector
public RandomOperatorSelector(int destroyOperatorCount, int repairOperatorCount) Creates a selector for fixed operator counts.- Parameters:
destroyOperatorCount- the positive number of destroy operatorsrepairOperatorCount- 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:
validateOperatorCountsin interfaceOperatorSelector<S extends Solution<S>>- Parameters:
destroyOperatorCount- the positive number of configured destroy operatorsrepairOperatorCount- the positive number of configured repair operators- Throws:
IllegalArgumentException- if either count differs from this selector's configured count
-
select
Description copied from interface:OperatorSelectorSelects operator indices without modifying the solutions in the context.- Specified by:
selectin interfaceOperatorSelector<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
-