Package es.urjc.etsii.grafo.create.grasp
Class GraspBuilder<M extends Move<S,I>,S extends Solution<S,I>,I extends Instance>
java.lang.Object
es.urjc.etsii.grafo.create.grasp.GraspBuilder<M,S,I>
- Type Parameters:
M
- Move classS
- Solution classI
- Instance class
public class GraspBuilder<M extends Move<S,I>,S extends Solution<S,I>,I extends Instance>
extends Object
Creates GRASP constructive instances using with different configurations, allowing to easily configure them and reuse the configurations.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Build the GRASP constructive with the config specified previously.GraspBuilder
<M, S, I> withAlphaInRange
(double alphaMin, double alphaMax) Pick a random alpha value in range [min, max].GraspBuilder
<M, S, I> withAlphaProvider
(AlphaProvider provider, String explained) Configure any custom strategy for configuring alpha values.GraspBuilder
<M, S, I> Use a random alpha value in each constructive iteration.GraspBuilder
<M, S, I> withAlphaValue
(double alpha) Configure alpha value to a fixed value.GraspBuilder
<M, S, I> withListManager
(GRASPListManager<? extends M, S, I> graspListManager) Configure the GRASP list manager, responsible for generating the initial candidate list and updating it after each move iteration.GraspBuilder
<M, S, I> withObjective
(Objective<M, S, I> objective) Determines both which greedy function is used to evaluate moves, and if the greedy function should be minimized or maximized.GraspBuilder
<M, S, I> Use greedy random strategy, or in other words, pick a subset of elements whose greedy function value is near the best value and then pick a random element from this subset.GraspBuilder
<M, S, I> Use random greedy strategy, or in other words, pick a subset of elements randomly, and then pick the best element from this subset.
-
Constructor Details
-
GraspBuilder
public GraspBuilder()
-
-
Method Details
-
withStrategyGreedyRandom
Use greedy random strategy, or in other words, pick a subset of elements whose greedy function value is near the best value and then pick a random element from this subset.- Returns:
- same builder with its config changed
-
withStrategyRandomGreedy
Use random greedy strategy, or in other words, pick a subset of elements randomly, and then pick the best element from this subset.- Returns:
- same builder with its config changed
-
withObjective
Determines both which greedy function is used to evaluate moves, and if the greedy function should be minimized or maximized.- Parameters:
objective
- objective function to use- Returns:
- same builder with its config changed
-
withAlphaValue
Configure alpha value to a fixed value. The alpha value is used to determine the randomness / greediness of the method.- Parameters:
alpha
- fixed alpha value to use, must be in range [0, 1]. A value of 0 means completely greedy, while a value of one means completely random.- Returns:
- same builder with its config changed
-
withAlphaRandom
Use a random alpha value in each constructive iteration.- Returns:
- same builder with its config changed
-
withAlphaInRange
Pick a random alpha value in range [min, max].- Parameters:
alphaMin
- minimum value, inclusivealphaMax
- maximum value, inclusive- Returns:
- same builder with its config changed
-
withAlphaProvider
Configure any custom strategy for configuring alpha values. The function provided as a first argument will be called once per constructive iteration.- Parameters:
provider
- function that generates an alpha value for each grasp iteration. Using a lambda expression is recommended.explained
- String that explains how the alpha provider is generating the values. Examples: FIXED{a=0.25}, RANGE{min=0.1, max=0.3}- Returns:
- same builder with its config changed
-
withListManager
Configure the GRASP list manager, responsible for generating the initial candidate list and updating it after each move iteration.- Parameters:
graspListManager
- GRASP list manager instance- Returns:
- same builder with its config changed
-
build
Build the GRASP constructive with the config specified previously. Before building the constructive method, a set of checks are executed in order to verify that al parameters are assigned and have valid values.- Returns:
- an instance of a GRASP constructive
- Throws:
IllegalArgumentException
- if any config value is not valid or there are missing values
-