java.lang.Object
es.urjc.etsii.grafo.algorithms.vns.VNSBuilder<S,I>
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Builds the VNS algorithm with the configured parameters.Builds the VNS algorithm with the configured parameters.VNSBuilder
<S, I> withConstructive
(Constructive<S, I> constructive) Creates a new VNSBuilder instance.VNSBuilder
<S, I> Optimize default objective function, which is the main objective declared in the current Context.VNSBuilder
<S, I> withImprover
(Improver<S, I> improver) Configures the improvement procedureVNSBuilder
<S, I> withNeighChange
(int maxK) Configures the neighborhood change strategy with a maximum K value.VNSBuilder
<S, I> withNeighChange
(int maxK, int increment) Configures the neighborhood change strategy with a maximum K value and a one-by-one increment.VNSBuilder
<S, I> withNeighChange
(VNSNeighChange<S, I> neighChange) Configures the neighborhood change strategy.VNSBuilder
<S, I> withObjective
(Objective<?, S, I> objective) Configures the objective function to optimize.VNSBuilder
<S, I> Configures the shake procedure.
-
Field Details
-
objective
Objective to optimize Defaults to the default objective declared in the current Context
-
-
Constructor Details
-
VNSBuilder
public VNSBuilder()
-
-
Method Details
-
withConstructive
Creates a new VNSBuilder instance.- Parameters:
constructive
- Constructive procedure to use when generating initial solutions.- Returns:
- This builder instance for method chaining
-
withImprover
Configures the improvement procedure- Parameters:
improver
- Improvement procedure to use when improving the solution.- Returns:
- This builder instance for method chaining
-
withShake
Configures the shake procedure.- Parameters:
shake
- Shake procedure to use when perturbing the solution.- Returns:
- This builder instance for method chaining
-
withDefaultObjective
Optimize default objective function, which is the main objective declared in the current Context. Note that calling this method is optional, if the objective is not set it will default to the main objective.- Returns:
- This builder instance for method chaining
-
withObjective
Configures the objective function to optimize.- Parameters:
objective
- Objective function to optimize.- Returns:
- This builder instance for method chaining
-
withNeighChange
Configures the neighborhood change strategy. Provide a custom implementation of VNSNeighChange to define how the k value should change. And when the VNS should stop.- Parameters:
neighChange
- Custom neighborhood change strategy. This should implement the VNSNeighChange interface, or be a lambada function that takes a solution and an integer k, and returns an integer k value (the updated k value). Example: withNeighChange((solution, k) -> k+1); // note that in this example k will keep increasing forever if the solution does not improve- Returns:
- This builder instance for method chaining
-
withNeighChange
Configures the neighborhood change strategy with a maximum K value. Increment defaults to 1.- Parameters:
maxK
- Maximum K value for the neighborhood change. When k reaches this value, the VNS will stop.- Returns:
- This builder instance for method chaining
-
withNeighChange
Configures the neighborhood change strategy with a maximum K value and a one-by-one increment.- Parameters:
maxK
- Maximum K value for the neighborhood change. When k reaches this value, the VNS will stop.increment
- Increment to apply to K when the solution does not improve- Returns:
- This builder instance for method chaining
-
build
Builds the VNS algorithm with the configured parameters. Uses a random name for the algorithm.- Returns:
- A new instance of VNS
-
build
Builds the VNS algorithm with the configured parameters.- Returns:
- A new instance of VNS
-