Package isula.aco

Class AcoProblemSolver<C,E extends Environment>

java.lang.Object
isula.aco.AcoProblemSolver<C,E>
Type Parameters:
C - Class for components of a solution.
E - Class representing the Environment.
Direct Known Subclasses:
ParallelAcoProblemSolver

public class AcoProblemSolver<C,E extends Environment> extends Object
The main component of the framework: Is the one in charge of making a colony an ants to traverse an environment in order to generate solutions.

The solveProblem() method is the one that starts the optimization process. Previously, you have to properly configure your solver by assigning it a Colony, an Environment and Daemon Actions (if required).

Author:
Carlos G. Gavidia
  • Constructor Details

    • AcoProblemSolver

      public AcoProblemSolver()
  • Method Details

    • initialize

      public void initialize(E environment, AntColony<C,E> colony, ConfigurationProvider config) throws ConfigurationException
      Prepares the solver for problem resolution.
      Parameters:
      environment - Environment instance, with problem-related information.
      colony - The Ant Colony with specialized ants.
      config - Algorithm configuration.
      Throws:
      ConfigurationException
    • initialize

      public void initialize(E environment, AntColony<C,E> colony, ConfigurationProvider config, Duration timeLimit) throws ConfigurationException
      Throws:
      ConfigurationException
    • configureAntColony

      protected void configureAntColony(AntColony<C,E> colony, E environment, Duration timeLimit)
    • addDaemonActions

      @SafeVarargs public final void addDaemonActions(DaemonAction<C,E>... daemonActions)
      Adds a list of Daemon Actions for the current solver. A daemon action is a global procedure applied while algorithm execution.
      Parameters:
      daemonActions - Daemon actions.
    • addDaemonAction

      protected void addDaemonAction(DaemonAction<C,E> daemonAction)
      Adds a Daemon Action for the current solver.
      Parameters:
      daemonAction - Daemon action.
    • configureDaemonAction

      protected void configureDaemonAction(AntColony<C,E> antColony, DaemonAction<C,E> daemonAction, E environment)
    • solveProblem

      public void solveProblem() throws ConfigurationException
      Solves an optimization problem using a Colony of Ants.
      Throws:
      ConfigurationException - If algorithm parameters aren't properly configured.
    • kickOffColony

      public PerformanceTracker<C,E> kickOffColony(AntColony<C,E> antColony, E environment, Instant executionStartTime) throws ConfigurationException
      Throws:
      ConfigurationException
    • updateGlobalMetrics

      protected void updateGlobalMetrics(Instant executionStartTime, PerformanceTracker<C,E> performanceTracker)
    • updateIterationPerformance

      public void updateIterationPerformance(Ant<C,E> bestAnt, int iteration, long iterationTimeInSeconds, E environment)
      Updates the information of the best solution produced with the solutions produced by the Colony.
      Parameters:
      iterationTimeInSeconds - Time spent during the iteration.
      environment - Environment where the solutions where produced.
    • getEnvironment

      public E getEnvironment()
    • setEnvironment

      public void setEnvironment(E environment)
    • getAntColony

      public AntColony<C,E> getAntColony()
    • setAntColony

      public void setAntColony(AntColony<C,E> antColony)
    • getConfigurationProvider

      public ConfigurationProvider getConfigurationProvider()
    • setConfigurationProvider

      public void setConfigurationProvider(ConfigurationProvider configurationProvider)
    • getBestSolution

      public List<C> getBestSolution()
    • getBestSolutionCost

      public double getBestSolutionCost()
    • getBestSolutionAsString

      public String getBestSolutionAsString()
    • getDaemonActions

      public List<DaemonAction<C,E>> getDaemonActions()
    • toString

      public String toString()
      Overrides:
      toString in class Object