A Firefly Algorithm for Mixed-Variable Optimization Based on Hybrid Distance Modeling

This paper proposes a hybrid distance-based Firefly Algorithm (FAmv) that effectively handles mixed-variable optimization problems by integrating continuous, ordinal, and categorical variables into a unified attractiveness mechanism, demonstrating superior performance on benchmark and engineering design tasks compared to state-of-the-art methods.

Ousmane Tom Bechir, Adán José-García, Zaineb Chelly Garcia, Vincent Sobanski, Clarisse Dhaenens

Published 2026-03-31
📖 6 min read🧠 Deep dive

The Big Picture: The "Mixed-Up" Puzzle

Imagine you are trying to solve a massive, complex puzzle. But here's the catch: some of the puzzle pieces are smooth, round numbers (like temperature or speed), while others are distinct, separate categories (like "Red," "Blue," or "Green," or specific integer settings like "1," "2," or "3").

In the world of computer science, this is called a Mixed-Variable Optimization Problem. Most computer algorithms are like specialized tools: some are great at moving smooth, round pieces (continuous variables), and others are great at snapping together distinct blocks (discrete variables). But very few are good at handling a mix of both at the same time without getting confused.

This paper introduces a new version of a popular algorithm called the Firefly Algorithm, specifically designed to handle this "mixed-up" puzzle. The authors call it FAmv.


The Original Firefly Algorithm: A Nightlight Dance

To understand the new version, we first need to understand the original Firefly Algorithm.

Imagine a dark forest filled with fireflies.

  • The Goal: Every firefly wants to find the brightest light (the best solution).
  • The Rule: Fireflies are attracted to brighter lights. The brighter the firefly, the more attractive it is.
  • The Movement: If a firefly sees a brighter one nearby, it flies toward it. If it's far away, the attraction is weaker. If it's close, the attraction is strong.
  • The Randomness: Sometimes, fireflies just flutter around randomly to explore new areas.

In the original algorithm, all fireflies live in a world of smooth, continuous numbers. They measure distance using a standard ruler (Euclidean distance). If Firefly A is at (1.5, 2.3) and Firefly B is at (1.6, 2.4), the distance is easy to calculate.

The Problem: What happens if Firefly A has a "Red" shirt and Firefly B has a "Blue" shirt? You can't measure the distance between "Red" and "Blue" with a standard ruler. The original algorithm gets stuck because it doesn't know how to compare different types of variables.


The New Solution: The "Hybrid Distance" Model

The authors realized they needed a new way to measure "distance" that works for both smooth numbers and distinct categories. They invented a Hybrid Distance Model.

Think of it like a Universal Translator for distance. Instead of just using a ruler, the algorithm now uses a two-part measuring tape:

  1. The Ruler Part: Measures the difference between smooth numbers (e.g., how far apart 5.0 and 5.5 are).
  2. The Switch Part: Measures the difference between categories (e.g., is "Red" the same as "Blue"? If not, that's a big jump. If it's the same, the jump is zero).

They tested two ways to combine these:

  • The Hamming Approach: This is like counting how many switches are different. If two fireflies have different colors or different integer settings, you count a "point" of difference.
  • The Gower Approach: This is a more sophisticated method that normalizes everything. It ensures that a huge difference in a smooth number (like 1 vs. 1000) doesn't completely drown out a small difference in a category (like "Red" vs. "Blue"). It balances the score so both types of variables get fair treatment.

How the New Fireflies Move

In the new FAmv algorithm, the fireflies have a split personality when they move:

  1. The Smooth Move: For the continuous parts (numbers), they fly just like the original fireflies, gliding smoothly toward the brighter light.
  2. The Discrete Move: For the categorical parts (colors, types), they don't "fly" smoothly. Instead, they perform a probabilistic swap.
    • Analogy: Imagine you are wearing a "Red" hat. You see a brighter firefly wearing a "Blue" hat. The algorithm calculates: "How close are we?"
    • If you are very close, there is a high chance you will instantly swap your hat to "Blue" to match the brighter firefly.
    • If you are far away, there is a low chance you will swap. You might keep your "Red" hat and just flutter randomly to see if you can find a better spot.

This ensures that the fireflies respect the rules of the puzzle (you can't have a "half-red" hat) while still learning from the best solutions.

The "Smart" Firefly: Adapting on the Fly

The authors also added a "smart" feature. In the original algorithm, the fireflies have fixed settings for how much they explore (wander) versus how much they exploit (follow the leader).

In FAmv, the fireflies are like smart explorers.

  • At the start of the journey: They are very adventurous. They wander far and wide (high exploration) to find where the good stuff might be.
  • As they get closer to the finish line: They become more focused. They stop wandering so much and start fine-tuning their position to get the perfect result (high exploitation).

The algorithm automatically adjusts this behavior based on how much "time" (computing power) is left.

Did It Work?

The authors tested their new algorithm on two types of challenges:

  1. Math Puzzles (CEC2013): They took standard math problems and forced them to have mixed variables. The new Firefly algorithm competed very well against other top-tier algorithms, often finding better solutions.
  2. Real-World Engineering: They tested it on designing things like:
    • A Pressure Vessel (where thickness must be a specific multiple of a number, but radius can be any number).
    • A Welded Beam.
    • A Coil Spring.

In these real-world tests, the new Firefly algorithm was often the winner or tied for the best, proving it can handle messy, real-life engineering problems.

The Takeaway

This paper is about teaching a computer algorithm to be multilingual. Just as a human needs to speak both English and Spanish to navigate a diverse city, this new Firefly Algorithm learned to speak the language of "smooth numbers" and "distinct categories" simultaneously.

By creating a new way to measure distance and a new way to move, the authors created a tool that is better at solving complex, real-world puzzles where variables don't all fit into the same neat box. It's a step forward in making artificial intelligence more flexible and practical for the messy, mixed-up problems we face in engineering and science.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →