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
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
addDaemonAction
(DaemonAction<C, E> daemonAction) Adds a Daemon Action for the current solver.final void
addDaemonActions
(DaemonAction<C, E>... daemonActions) Adds a list of Daemon Actions for the current solver.protected void
protected void
configureDaemonAction
(AntColony<C, E> antColony, DaemonAction<C, E> daemonAction, E environment) double
List<DaemonAction<C,
E>> void
initialize
(E environment, AntColony<C, E> colony, ConfigurationProvider config) Prepares the solver for problem resolution.void
initialize
(E environment, AntColony<C, E> colony, ConfigurationProvider config, Duration timeLimit) void
setAntColony
(AntColony<C, E> antColony) void
setConfigurationProvider
(ConfigurationProvider configurationProvider) void
setEnvironment
(E environment) void
Solves an optimization problem using a Colony of Ants.toString()
protected void
updateGlobalMetrics
(Instant executionStartTime, PerformanceTracker<C, E> performanceTracker) 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.
-
Constructor Details
-
AcoProblemSolver
public AcoProblemSolver()
-
-
Method Details
-
initialize
public void initialize(E environment, AntColony<C, E> colony, ConfigurationProvider config) throws ConfigurationExceptionPrepares 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
-
addDaemonActions
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
Adds a Daemon Action for the current solver.- Parameters:
daemonAction
- Daemon action.
-
configureDaemonAction
-
solveProblem
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
-
setEnvironment
-
getAntColony
-
setAntColony
-
getConfigurationProvider
-
setConfigurationProvider
-
getBestSolution
-
getBestSolutionCost
public double getBestSolutionCost() -
getBestSolutionAsString
-
getDaemonActions
-
toString
-