Class SegmentedRouletteWheelOperatorSelector<S extends Solution<S>>
- Type Parameters:
S- the solution type
- All Implemented Interfaces:
OperatorSelector<S>
Destroy and repair selection is independent, with \(P(i) = w_i / \sum_j w_j\) in each group. Weights start at 1; an all-zero group uses uniform selection. At a segment boundary:
\[ w_i' = \theta w_i + (1 - \theta) \frac{\Sigma_i}{n_i}. \]
Here \(\theta\) is decay, and \(\Sigma_i\) is the sum of scores credited to operator
\(i\) in that segment, and \(n_i\) is its selection count. Ineligible feedback contributes the
rejected-outcome score scores[3], counts as a selection, and advances the segment.
Operators with no selections retain their weights. Segment scores and selection counts are
cleared after updating. Instances hold mutable state and must not be shared by concurrent runs.
-
Constructor Summary
ConstructorsConstructorDescriptionSegmentedRouletteWheelOperatorSelector(int destroyOperatorCount, int repairOperatorCount, double[] scores, double decay, long segmentLength) Creates a selector for fixed operator counts. -
Method Summary
Modifier and TypeMethodDescriptiondoublegetDecay()Returns the configured weight retention factor.intReturns the configured number of destroy operators.double[]Returns a copy of accumulated destroy scores in the incomplete segment.double[]Returns a copy of destroy weights indexed by operator.longReturns the number of feedback updates in the incomplete segment.intReturns the configured number of repair operators.double[]Returns a copy of accumulated repair scores in the incomplete segment.double[]Returns a copy of repair weights indexed by operator.double[]Returns a copy of the scores inBEST,BETTER,ACCEPTED,REJECTEDorder.longReturns the number of feedback updates per segment.voidreset()Restores all weights to 1 and clears segment scores, selection counts, and the segment counter.select(OperatorSelectionContext<S> context) Selects operator indices without modifying the solutions in the context.voidupdate(OperatorSelectionFeedback<S> feedback) Receives the outcome after each iteration to update selection state.voidvalidateOperatorCounts(int destroyOperatorCount, int repairOperatorCount) Validates the operator counts when the solver is built.
-
Constructor Details
-
SegmentedRouletteWheelOperatorSelector
public SegmentedRouletteWheelOperatorSelector(int destroyOperatorCount, int repairOperatorCount, double[] scores, double decay, long segmentLength) Creates a selector for fixed operator counts.- Parameters:
destroyOperatorCount- the positive number of destroy operatorsrepairOperatorCount- the positive number of repair operatorsscores- four finite non-negative scores inBEST,BETTER,ACCEPTED,REJECTEDorder; copied on constructiondecay- the finite weight retention factor in[0, 1]segmentLength- the positive number of feedback updates per segment- Throws:
IllegalArgumentException- if any numeric parameter or score count is invalidNullPointerException- ifscoresis null
-
-
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
-
update
Receives the outcome after each iteration to update selection state.The candidate solution must not be modified. The default implementation does nothing.
- Specified by:
updatein interfaceOperatorSelector<S extends Solution<S>>- Parameters:
feedback- the non-null outcome and reward eligibility of the selected operator pair- Throws:
IndexOutOfBoundsException- if either selected operator index is out of rangeArithmeticException- if accumulated segment scores would become non-finite
-
reset
public void reset()Restores all weights to 1 and clears segment scores, selection counts, and the segment counter.- Specified by:
resetin interfaceOperatorSelector<S extends Solution<S>>
-
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
-
getScores
public double[] getScores()Returns a copy of the scores inBEST,BETTER,ACCEPTED,REJECTEDorder.- Returns:
- a copy of the scores in
BEST,BETTER,ACCEPTED,REJECTEDorder
-
getDecay
public double getDecay()Returns the configured weight retention factor.- Returns:
- the configured weight retention factor
-
getSegmentLength
public long getSegmentLength()Returns the number of feedback updates per segment.- Returns:
- the number of feedback updates per segment
-
getIterationsInSegment
public long getIterationsInSegment()Returns the number of feedback updates in the incomplete segment.- Returns:
- the number of feedback updates in the incomplete segment
-
getDestroyOperatorWeights
public double[] getDestroyOperatorWeights()Returns a copy of destroy weights indexed by operator.- Returns:
- a copy of destroy weights indexed by operator
-
getRepairOperatorWeights
public double[] getRepairOperatorWeights()Returns a copy of repair weights indexed by operator.- Returns:
- a copy of repair weights indexed by operator
-
getDestroyOperatorSegmentScores
public double[] getDestroyOperatorSegmentScores()Returns a copy of accumulated destroy scores in the incomplete segment.- Returns:
- a copy of accumulated destroy scores in the incomplete segment
-
getRepairOperatorSegmentScores
public double[] getRepairOperatorSegmentScores()Returns a copy of accumulated repair scores in the incomplete segment.- Returns:
- a copy of accumulated repair scores in the incomplete segment
-