Class CMSABuilder<S extends Solution<S,I>, I extends Instance, C>

java.lang.Object
es.urjc.etsii.grafo.algorithms.cmsa.CMSABuilder<S,I,C>
Type Parameters:
S - type of the solution of the problem
I - type of the instance of the problem
C - type of the solution components

public class CMSABuilder<S extends Solution<S,I>, I extends Instance, C> extends Object
CMSA algorithm builder based on the Java Builder Pattern.
  • Constructor Details

    • CMSABuilder

      public CMSABuilder()
  • Method Details

    • withConstructive

      public CMSABuilder<S,I,C> withConstructive(CMSAConstructive<S,I,C> constructive)
      Configures the probabilistic constructive procedure used to sample solution components.
      Parameters:
      constructive - probabilistic constructive procedure
      Returns:
      this builder instance for method chaining
    • withSolver

      public CMSABuilder<S,I,C> withSolver(CMSASolver<S,I,C> solver)
      Configures the exact (or near-exact) method used to solve the restricted sub-instance.
      Parameters:
      solver - exact method implementation
      Returns:
      this builder instance for method chaining
    • withSolutionsPerIteration

      public CMSABuilder<S,I,C> withSolutionsPerIteration(int solutionsPerIteration)
      Configures how many solutions are probabilistically constructed at each iteration before merging their components into the sub-instance and calling the solver. Defaults to 30.
      Parameters:
      solutionsPerIteration - number of solutions constructed at each iteration, usually denoted na
      Returns:
      this builder instance for method chaining
    • withAgeMax

      public CMSABuilder<S,I,C> withAgeMax(int ageMax)
      Configures the maximum age a solution component can reach, while not being used by the solver, before being removed from the sub-instance. Defaults to 5.
      Parameters:
      ageMax - maximum component age
      Returns:
      this builder instance for method chaining
    • withSolverTimeLimitInMillis

      public CMSABuilder<S,I,C> withSolverTimeLimitInMillis(long solverTimeLimitInMillis)
      Configures the time budget, in milliseconds, given to the solver at each iteration to solve the restricted sub-instance. Defaults to 1000 (1 second).
      Parameters:
      solverTimeLimitInMillis - time budget in milliseconds
      Returns:
      this builder instance for method chaining
    • withMaxIterations

      public CMSABuilder<S,I,C> withMaxIterations(int maxIterations)
      Configures the maximum number of iterations. Defaults to 0, disabling this limit and relying exclusively on the global time limit.
      Parameters:
      maxIterations - maximum number of iterations, use a value smaller or equal to zero to disable
      Returns:
      this builder instance for method chaining
    • withDefaultObjective

      public CMSABuilder<S,I,C> 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

      public CMSABuilder<S,I,C> withObjective(Objective<?,S,I> objective)
      Configures the objective function to optimize.
      Parameters:
      objective - objective function to optimize
      Returns:
      this builder instance for method chaining
    • build

      public CMSA<S,I,C> build()
      Builds the CMSA algorithm with the configured parameters. Uses a random name for the algorithm.
      Returns:
      a new instance of CMSA
    • build

      public CMSA<S,I,C> build(String name)
      Builds the CMSA algorithm with the configured parameters.
      Parameters:
      name - algorithm name
      Returns:
      a new instance of CMSA