How rohanchhipa/polygonga works
Main Components
• GA Core Library (PolygonGa.Algorithm): This is the heart of the system. Its subcomponents include:
• AlgorithmRunner: Orchestrates the overall GA process.
• Genetic Operators:
o Crossover Operators: Various implementations (SinglePointCrossover, TwoPointCrossover, UniformCrossover) linked through the ICrossover interface.
o Mutation Operators: Includes PolygonColourMutation, PolygonGrowMutation, PolygonMoveMutation, PolygonRotateMutation, PolygonShearMutation, PolygonShrinkMutation, PolygonSwapMutation – all implementing IMutation.
o Selection Mechanism: TournamentSelection via the ISelection interface.
o Fitness Function: Implementation such as MseFitnessFunction based on the IFitnessFunction interface.
• Polygon Generation: Includes implementations like SquarePolygonGenerator and TrianglePolygonGenerator, tied into IPolygonGenerator interface.
• GA Settings: GaParameters, configuration of evolution parameters (likely controlling mutation rates, population size, etc.).
• Supporting Utilities: Helpers found under Extensions (e.g., PointExtensions) and domain models like Chromosome and ImagePolygon.
• Console Application (PolygonGa.Console): Serves as the user interface that initializes the GA process and triggers the evolution experiment. It depends on the GA Core Library.
• External Resources and Results: The Results directory showing evolved images and animations. This represents persistent outputs of the algorithm.
Capturing Component Interactions
• The Console App (PolygonGa.Console) acts as the entry point. It instantiates and configures the GA Core, then triggers the AlgorithmRunner.
• The AlgorithmRunner coordinates the genetic evolution loop by selecting individuals, crossing them over, applying various mutations, and evaluating fitness against a target image.
• Within each evolution cycle, the Selection component (a tournament-style strategy) chooses parent solutions.
• Crossover operators are used to combine genetic material from selected parents.
• Mutation operators then perturb the offspring using various transformations like moving, rotating, or changing polygon attributes.
• The Fitness component calculates the difference between the current evolved image and the target image (using the MSE function) to determine quality.
Architectural Patterns and Design Principles
• Modularity: The use of interfaces (ICrossover, IMutation, ISelection, IFitnessFunction, IPolygonGenerator) promotes a plug-and-play architecture where new genetic operators or polygon generators can be added easily.
• Separation of Concerns: The system clearly separates the genetic algorithm logic from the user-facing console application.
• Extensibility: Additional evolutionary operators or polygon types can be introduced with minimal changes due to clear interface boundaries.