Skip to content

[Bug/DesignProblem] NoAlgorithmIsSafe #12

@pointan

Description

@pointan

To be specific Threadsafe, Safe in a single thread, or even to just solve two problems right after each other.

I think we have a fundamental design flaw in the entire ML Library, that affects every single algorithm. I don't know how we missed this, and why none of the tests indirectly pointed to it.

All (that I checked) of our Algorithms are stateful but in Spring we define them as singletons. So while all of us were probably aware none of the Algs is threadsafe. Even worse they don't reset their states (GeneticAlgorithm has a "reset()" function that was probably used in EDEN, but nowhere else. This means that if I run anything after the first run some states (may) bleed over.

As possible solutions (in descending order of preference):

  • We could make every algorithm carry the state as parameters instead of global values (also would make everything immediately threadsafe). This is how most other frameworks handle this issue.
  • We could implement and ENFORCE a reset() function (ex. always called at start of the Algorithm.solve())
  • We could Switch to a factory pattern that creates Single-Use Algorithms
  • We could simply mention this in the documentation

Metadata

Metadata

Assignees

No one assigned

    Labels

    blockerThis issue is BLOCKING other issuesbugSomething isn't workingconfirmedRequest was accepted and will be worked on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions