java.lang.Object
es.urjc.etsii.grafo.algorithms.scattersearch.ScatterSearchBuilder<S,I>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected SolutionCombinator
<S, I> Defines how solutions are combined to create the new candidate refsetprotected Constructive
<S, I> Constructive to use when creating "diverse" solutionsprotected Constructive
<S, I> Constructive to use to create "good value" solutionsprotected double
Proportion of items in refset to select using diversity criteria instead of a greedy or by value one.Improvement methodprotected double
When initializing the refset inside the Scatter Search, build (initialRatio * refSetSize) solutions, and choose from them the set of the best solutions and diverse solutions.protected int
Maximum number of iterations, set by default to a value near Integer.MAX_VALUEprotected String
Name of the algorithmObjective to optimize Defaults to mainObjectiveprotected int
Refset sizeprotected boolean
protected SolutionDistance
<S, I> How solution distance is measured, useful to calculate diversity metrics -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Build a Scatter Search algorithm with the configured parameters of this builderwithCombinator
(SolutionCombinator<S, I> combinator) Configure the method used to generate a new candidate set in each Scatter Search algorithmwithConstructive
(Constructive<S, I> constructive) Configure constructive method for initial refset generation.withConstructiveForDiversity
(Constructive<S, I> constructive) Configure a constructive method to use only when diverse solutions are requiredwithDistance
(SolutionDistance<S, I> distance) Configure how distance is calculated between different solutions, needed to see how diverse are the solutions.withDiversity
(double ratio) Configure diversity ratio, ie, number of elements that during refset initialization will be accepted maximizing distance to existing solutions, instead of by objective function value.withImprover
(Improver<S, I> improver) Configure an improvement method for the Scatter Search algorithm.withInitialRatio
(double ratio) Optional parameter, specifies how many extra solutions to build during refset initialization When initializing the refset inside the Scatter Search, build (initialRatio * refSetSize) solutions, and choose from them the set of the best solutions and diverse solutions.withMaxIterations
(int maxIterations) Optional parameter, specifies how many scatter search iterations to execute before stopping.Configure algorithm namewithObjective
(Objective<?, S, I> objective) Set objective to optimize in ScatterSearchwithRefsetSize
(int size) Refset size, common values are in range [10,30]withSoftRestart
(boolean enabled) Enable or disable soft restart.
-
Field Details
-
name
Name of the algorithm -
initialRatio
protected double initialRatioWhen initializing the refset inside the Scatter Search, build (initialRatio * refSetSize) solutions, and choose from them the set of the best solutions and diverse solutions. The bigger the initialRatio, the better the initial solutions and more diverse, but it will take longer to initialize the refset and reset it if it gets stuck. -
maxIterations
protected int maxIterationsMaximum number of iterations, set by default to a value near Integer.MAX_VALUE -
refsetSize
protected int refsetSizeRefset size -
diversityRatio
protected double diversityRatioProportion of items in refset to select using diversity criteria instead of a greedy or by value one. Must be in range [0, 1] -
objective
Objective to optimize Defaults to mainObjective -
constructiveGoodValues
Constructive to use to create "good value" solutions -
constructiveDiverseValues
Constructive to use when creating "diverse" solutions -
improver
Improvement method -
combinator
Defines how solutions are combined to create the new candidate refset -
solutionDistance
How solution distance is measured, useful to calculate diversity metrics -
softRestartEnabled
protected boolean softRestartEnabled
-
-
Constructor Details
-
ScatterSearchBuilder
public ScatterSearchBuilder()Create a new Scatter Search Builder. After configuring the parameters, call ref build()
-
-
Method Details
-
withConstructive
Configure constructive method for initial refset generation. If no diverse constructive method is specified, this constructive method will be used by default to build diverse solutions- Parameters:
constructive
- constructive method- Returns:
- builder
-
withConstructiveForDiversity
Configure a constructive method to use only when diverse solutions are required- Parameters:
constructive
- constructive method- Returns:
- builder
-
withImprover
Configure an improvement method for the Scatter Search algorithm. The improvement method, if provided, will be executed after constructing each solution.- Parameters:
improver
- improvement method- Returns:
- builder
-
withCombinator
Configure the method used to generate a new candidate set in each Scatter Search algorithm- Parameters:
combinator
- non null combinator method- Returns:
- builder
-
withDistance
Configure how distance is calculated between different solutions, needed to see how diverse are the solutions.- Parameters:
distance
- distance calculation implementation- Returns:
- builder
-
withRefsetSize
Refset size, common values are in range [10,30]- Parameters:
size
- number of elements in refset- Returns:
- builder
-
withDiversity
Configure diversity ratio, ie, number of elements that during refset initialization will be accepted maximizing distance to existing solutions, instead of by objective function value.- Parameters:
ratio
- double in range [0, 1]- Returns:
- builder
-
withName
Configure algorithm name- Parameters:
name
- algorithm name, must not be blank- Returns:
- builder
-
withInitialRatio
Optional parameter, specifies how many extra solutions to build during refset initialization When initializing the refset inside the Scatter Search, build (initialRatio * refSetSize) solutions, and choose from them the set of the best solutions and diverse solutions. The bigger the initialRatio, the better the initial solutions and more diverse, but it will take longer to initialize the refset and reset it if it gets stuck.- Parameters:
ratio
- create ratio*initialRefset solutions to choose from for both by value and by diversity acceptance during initial refset initialization. If not configured defaults to 1.- Returns:
- builder
-
withMaxIterations
Optional parameter, specifies how many scatter search iterations to execute before stopping. Defaults to a huge number, if a TimeLimit is not configured, the algorithm will run indefinitely.- Parameters:
maxIterations
- maximum number of iterations. Defaults to Integer.MAX_VALUE / 2 or an equivalent huge number.- Returns:
- builder
-
withObjective
Set objective to optimize in ScatterSearch- Parameters:
objective
- objective to optimize, defautls to Context::getMainObjective if not set- Returns:
- current builder with solving mode set
-
withSoftRestart
Enable or disable soft restart. If soft restart is disabled, the algorithm ends when the reference set converges, otherwise, part of the refset is discarded and new solutions are inserted. If not configured, defaults to false.- Parameters:
enabled
- MAXIMIZING if maximizing, MINIMIZING if minimizing- Returns:
- current builder with soft restart set.
-
build
Build a Scatter Search algorithm with the configured parameters of this builder- Returns:
- New instance of Scatter Search algorithm. Same builder can generate multiple algorithm instances.
-