Skip to content

Improve initial population diversity in IsoFuel algorithmΒ #104

@jnakaigen

Description

@jnakaigen

Description

I have been reviewing the IsoFuelPopulation class in algorithms/genetic/population.py and noticed a potential issue with the fallback strategy for initial population generation.

Currently, in IsoFuelPopulation.generate, if the patcher returns fewer routes than n_samples, the code fills the remaining slots by copying the last available route (lines 163-165):

for j in range(i + 1, n_samples):
    X[j, 0] = np.copy(X[j - 1, 0])

Impact:
If IsoFuel generates only a few valid routes (e.g., 3 out of 50), the remaining 47 individuals become identical clones. This severely limits genetic diversity in the first generation, potentially causing premature convergence or stagnation.

Proposed Solution:
I propose adding a perturbation step to the fallback mechanism. Instead of exact copying, we could apply a small random mutation to the coordinates of the copied routes to ensure the initial population maintains diversity.

I am happy to draft a PR for this if this approach aligns with the project's goals.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions