Ant Colony Optimization (ACO) is one of the optimization methods available in Gpredomics, alongside the Genetic Algorithm, Beam Search, and MCMC approaches. It is a constructive metaheuristic inspired by the foraging behavior of ants, where solutions are built feature-by-feature guided by collective pheromone memory and heuristic information.
The ACO implemented in Gpredomics follows a Max-Min Ant System (MMAS) variant:
- Initialization: Initialize pheromone trails to maximum values on all features
- Construction: Each ant builds a model by selecting features probabilistically
- Evaluation: Compute fitness scores for all constructed models
- Local search: Greedily remove features from top models if it improves penalized fitness
- Pheromone update: Evaporate pheromone, then deposit on features used by best models
- Iteration: Repeat 2–5 until convergence or stopping criteria are met
| Aspect | GA | ACO |
|---|---|---|
| Approach | Recombinative (crossover + mutation) | Constructive (build from scratch) |
| Memory | Implicit (population carries good features) | Explicit (pheromone matrix) |
| Diversity | Requires forced diversity mechanisms | Natural (probabilistic construction) |
| Model size | Controlled by mutation balance | Controlled by k_max + local search |
| Speed | Faster per generation (parallel fitness) | Slower but more diverse exploration |
The pheromone matrix stores learned desirability for each (feature, coefficient sign) pair:
- τ[feature][+1]: Pheromone for using this feature with a positive coefficient
- τ[feature][-1]: Pheromone for using this feature with a negative coefficient
High pheromone means many good models have used this feature with this sign. The pheromone matrix is the collective memory of the colony — it encodes which features are consistently useful across diverse solutions.
The Max-Min Ant System clamps pheromone values to [τ_min, τ_max]:
- τ_max prevents any single feature from dominating (avoids premature convergence)
- τ_min ensures every feature retains a minimum selection probability (maintains exploration)
Pheromone is initialized to τ_max at the start, encouraging maximum exploration in early iterations.
Each feature has a heuristic desirability based on its statistical significance from feature selection:
- For p-value methods (Student's t, Wilcoxon):
η[i] = 1 / (p_value + ε)— lower p-value = higher desirability - For Bayesian Fisher:
η[i] = |log_bayes_factor|— higher factor = higher desirability
This biases ants toward statistically significant features without excluding others entirely.
Each ant constructs a complete model through the following steps:
-
Choose model size k: Uniformly sampled from [k_min, k_max]
-
Select k features using roulette wheel selection (without replacement):
- Selection probability:
P(feature i) = τ[i]^α × η[i]^β / Σ(τ[j]^α × η[j]^β) - α controls pheromone influence (higher = more exploitation)
- β controls heuristic influence (higher = more bias toward significant features)
- Features are removed from the candidate set after selection (no duplicates)
- Selection probability:
-
Assign coefficients based on language and pheromone:
- Binary: Always +1
- Ternary/Ratio: Sign chosen probabilistically based on pheromone
τ[i][+1]vsτ[i][-1], biased by the feature's class association - Pow2: Sign from class association, magnitude randomly sampled as 2^p where p ∈ {0, 1, 2, 3}
-
Quality control: Same as GA — remove stillborn (invalid coefficient patterns) and out-of-bounds (k outside range) individuals
After construction and fitness evaluation, the top 5 models undergo a greedy local search:
- For each feature in the model:
- Temporarily remove the feature
- Recompute AUC
- Compare penalized fitness:
fit - k_penalty × k - If the sparser model has equal or better penalized fitness, keep the removal
- This reduces model complexity without sacrificing performance
Local search is what allows ACO to produce models as sparse as GA despite the constructive approach's tendency toward larger models.
After all ants have been evaluated:
-
Evaporation: All pheromone values decay by factor (1 - ρ):
τ[i] = max(τ_min, τ[i] × (1 - ρ))- Higher ρ = faster forgetting = more exploration
- Lower ρ = longer memory = more exploitation
-
Iteration-best deposit: The best ant of the current iteration deposits pheromone on its features:
τ[feature][sign] += fitness / k- Normalized by k to avoid biasing toward larger models
-
Global-best deposit: The best-ever ant deposits additional pheromone:
τ[feature][sign] += elite_weight × fitness / kelite_weightcontrols how strongly the global best influences future construction
-
Clamping: All values are clamped to [τ_min, τ_max]
The algorithm terminates when any of the following conditions is met:
- Maximum iterations reached: The number of iterations exceeds
max_iterations - Best model age limit: After
min_iterations, if the best model hasn't improved formax_age_best_modeliterations - Manual interruption: User sends a stop signal (Ctrl+C or SIGHUP/SIGTERM)
aco:
n_ants: 100 # Number of ants (models constructed) per iteration
max_iterations: 200 # Maximum number of iterations
min_iterations: 10 # Minimum iterations before early stopping is allowed
alpha: 1.0 # Pheromone importance exponent (α)
beta: 2.0 # Heuristic importance exponent (β)
rho: 0.1 # Pheromone evaporation rate (ρ ∈ [0,1])
tau_min: 0.01 # Minimum pheromone value (MMAS lower bound)
tau_max: 1.0 # Maximum pheromone value (MMAS upper bound)
elite_weight: 2.0 # Extra pheromone deposit weight for global-best ant
k_min: 1 # Minimum number of features per model
k_max: 200 # Maximum number of features per model (0 = no limit)
max_age_best_model: 10 # Early stopping: max iterations without improvement| Parameter | Effect of increasing | Recommended range |
|---|---|---|
| n_ants | Better exploration, slower per iteration | 50–500 |
| alpha | More exploitation (follow pheromone) | 0.5–2.0 |
| beta | More bias toward significant features | 1.0–5.0 |
| rho | Faster forgetting, more exploration | 0.05–0.3 |
| tau_min | Higher floor prevents feature extinction | 0.001–0.1 |
| elite_weight | Stronger influence of global best | 1.0–5.0 |
| k_max | Allows larger models (use with k_penalty) | Dataset-dependent |
Typical starting configuration: The defaults work well for most metagenomics datasets. For very large feature spaces (>5000 features), increase n_ants to 200–500 and beta to 3.0 to strengthen the heuristic guidance.
Ant construction is parallelized via rayon:
- Each ant receives a deterministic seed derived from the master RNG
- Construction is independent across ants (no shared mutable state)
- Fitness evaluation reuses the existing parallel population evaluation
This ensures both performance and reproducibility.
All randomness is controlled by the seed parameter. The master RNG generates per-ant seeds deterministically, so results are identical across runs with the same seed, regardless of thread count.
Use ACO when:
- You want to explore a wider variety of model structures
- FBM diversity is important (ACO naturally produces more diverse models)
- You suspect the GA is converging prematurely to a local optimum
- You want an alternative perspective on feature importance (via the pheromone matrix)
Use GA when:
- Speed is the priority (GA is typically 2–5x faster)
- You need very sparse models (GA's mutation pressure naturally reduces k)
- You have a good initial population to start from
- Cross-validation mode is needed (ACO + CV is supported but less tested)
Use both together: Run GA and ACO on the same data, then compare FBMs. Features that appear in both algorithms' top models are strong candidates. The voting ensemble can combine experts from both runs.
general:
algo: aco
language: ter
data_type: prev
seed: 42
fit: auc
k_penalty: 0.001
aco:
n_ants: 200
max_iterations: 100
min_iterations: 20
alpha: 1.0
beta: 2.0
rho: 0.1
k_min: 1
k_max: 50
max_age_best_model: 15
voting:
vote: true
fbm_ci_alpha: 0.05- Dorigo, M. & Stützle, T. (2004). Ant Colony Optimization. MIT Press.
- Stützle, T. & Hoos, H. (2000). Max-Min Ant System. Future Generation Computer Systems, 16(8), 889–914.
- Al-Ani, A. (2005). Feature subset selection using ant colony optimization. Expert Systems with Applications, 36(8), 11198–11204.
Last updated: v0.8.3