Skip to content

Comments

feat: Add Simulated Annealing algorithm with GUI visualization#13704

Closed
29di wants to merge 2 commits intoTheAlgorithms:masterfrom
29di:feature/simulated-annealing-gui
Closed

feat: Add Simulated Annealing algorithm with GUI visualization#13704
29di wants to merge 2 commits intoTheAlgorithms:masterfrom
29di:feature/simulated-annealing-gui

Conversation

@29di
Copy link

@29di 29di commented Oct 23, 2025

  • Implement SimulatedAnnealingOptimizer for general optimization
  • Add interactive GUI with real-time visualization
  • Implement TSP solver with route visualization
  • Add comprehensive test suite
  • Include detailed documentation and guides
  • Support multiple benchmark functions (Sphere, Rastrigin, Rosenbrock, Ackley)
  • Add parameter tuning controls and pause/resume functionality

Describe your change:

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Add or change doctests? -- Note: Please avoid changing both code and tests in a single pull request.
  • Documentation change?

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms include at least one URL that points to Wikipedia or another similar explanation.
  • If this pull request resolves one or more open issues then the description above includes the issue number(s) with a closing keyword: "Fixes #ISSUE-NUMBER".

divyasinhadev and others added 2 commits October 23, 2025 12:54
- Implement SimulatedAnnealingOptimizer for general optimization
- Add interactive GUI with real-time visualization
- Implement TSP solver with route visualization
- Add comprehensive test suite
- Include detailed documentation and guides
- Support multiple benchmark functions (Sphere, Rastrigin, Rosenbrock, Ackley)
- Add parameter tuning controls and pause/resume functionality
@29di 29di closed this Oct 23, 2025
@29di 29di reopened this Oct 23, 2025
@algorithms-keeper algorithms-keeper bot added documentation This PR modified documentation files require descriptive names This PR needs descriptive function and/or variable names require type hints https://docs.python.org/3/library/typing.html labels Oct 23, 2025
Copy link

@algorithms-keeper algorithms-keeper bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Click here to look at the relevant links ⬇️

🔗 Relevant Links

Repository:

Python:

Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.

algorithms-keeper commands and options

algorithms-keeper actions can be triggered by commenting on this PR:

  • @algorithms-keeper review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.

NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.

class City:
"""Represents a city with x, y coordinates."""

def __init__(self, x: float, y: float, name: str = ""):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide return type hint for the function: __init__. If the function does not return a value, please provide the type hint as: def function() -> None:

Please provide descriptive name for the parameter: x

Please provide descriptive name for the parameter: y

class TSPRoute:
"""Represents a route through all cities."""

def __init__(self, cities: list[City], order: list[int] | None = None):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide return type hint for the function: __init__. If the function does not return a value, please provide the type hint as: def function() -> None:

self._distance = distance
return self._distance

def swap_cities(self, i: int, j: int) -> "TSPRoute":

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide descriptive name for the parameter: i

Please provide descriptive name for the parameter: j

new_order[i], new_order[j] = new_order[j], new_order[i]
return TSPRoute(self.cities, new_order)

def reverse_segment(self, i: int, j: int) -> "TSPRoute":

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide descriptive name for the parameter: i

Please provide descriptive name for the parameter: j

class TSPSimulatedAnnealing:
"""Simulated Annealing solver for TSP."""

def __init__(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide return type hint for the function: __init__. If the function does not return a value, please provide the type hint as: def function() -> None:


self.status_var.set("Ready")

def _animate(self):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide return type hint for the function: _animate. If the function does not return a value, please provide the type hint as: def function() -> None:

# Schedule next frame
self.animation_id = self.root.after(50, self._animate)

def _update_plots(self):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide return type hint for the function: _update_plots. If the function does not return a value, please provide the type hint as: def function() -> None:

self.fig.tight_layout()
self.canvas.draw()

def _optimization_complete(self):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide return type hint for the function: _optimization_complete. If the function does not return a value, please provide the type hint as: def function() -> None:

)


def main():

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide return type hint for the function: main. If the function does not return a value, please provide the type hint as: def function() -> None:

print("=" * 50)

# Test with Sphere function
sphere = lambda x: sum(xi**2 for xi in x)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide descriptive name for the parameter: x

@29di 29di closed this Oct 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation This PR modified documentation files require descriptive names This PR needs descriptive function and/or variable names require type hints https://docs.python.org/3/library/typing.html

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant