Skip to content

Have wrappers for SIMULATED-ANNEALING and HILL-CLIMBING? #368

Closed

Description

@kaivalyar

Figure 4.5 - SIMULATED-ANNEALING describes an optimization algorithm that is supposed to return a state, as per the first line of the function declaration. The rest of the implementation, however, goes on to return a node instead of its state. I am not certain about the reason behind this, but I think the pseudocode should change to match the function declaration (and the standard format of other optimisation functions in the book, such as HILL-CLIMBING). I am unsure about how to propose this as an edit to the pseudocode (or even whether I should do so or not).

Activity

  1. kaivalyar commented on Mar 17, 2017

    @kaivalyar
    ContributorAuthor

    Update:

    I have added #40 to the aima-pseudocode repo, and #369 to the aima-python repo to fix this - if I am making an error, then these can be ignored, but I went ahead and made the pull requests anyway.

  2. kaivalyar commented on Mar 17, 2017

    @kaivalyar
    ContributorAuthor

    Perspective from the aima-java repo:

    I had a look at the aima-java implementation to get a greater idea about this. Both the optimisation functions (Hill-Climbing and Simulated-Annealing) is to return a Node, rather than a state.

    HillClimbingSearch.java
    SimulatedAnnealingSearch.java

    Maybe I was wrong with my edit - Hill-Climbing should have been changed instead of Simulated-Annealing. However, in my opinion, returning a solution state seems more intuitive than a solution node. Could somebody please weigh in on this?

  3. norvig commented on Mar 18, 2017

    @norvig
    Member

    I'll have to think about this some more, and I welcome more discussion. Clearly, the path searching functions like A* search need to give you a path, which you get from a Node. For the optimization functions, if you are really using them for optimization, all you care about is the state. The difficulty is that sometimes you apply them where you aren't interested only in optimization, and you do want the path. I'm inclined to say that you should be returning the state, and if you really want to recover some other information, that should be part of the state. But I'm open to counter-arguments.

  4. kaivalyar commented on Mar 18, 2017

    @kaivalyar
    ContributorAuthor

    We can have a different approach that combines the best of both features:

    • Since the text introduces both the Hill-Climbing and Simulated-Annealing as optimisation functions, we can stick to returning states in the pseudocode, as would be required for most optimisation problems.

    • However, in the python implementation, it is easy to have the best of both worlds - a helper function that does the actual optimal path searching - returning a node, and a wrapper that simply returns the state of the given node, thus forming a user interface consistent with that provided in the textbook.

    This has a major drawback though - the python implementation will look slightly different from the pseudocode - an outcome that is clearly undesirable given the explicit goals of the aimacode project.

  5. changed the title [-]Simulated-Annealing doesn't return a state[/-] [+]Have wrappers for SIMULATED-ANNEALING and HILL-CLIMBING?[/+] on Mar 22, 2017
  6. norvig commented on May 29, 2017

    @norvig
    Member

    I think the algorithms and the pseudocode should be changed to use states rather than nodes. The only purpose of Nodes is to define paths, and in hillclimbing and simulated annealing, we don't define a path, so there is no need for Nodes.

  7. kaivalyar commented on May 29, 2017

    @kaivalyar
    ContributorAuthor

    I would just like to say that the Python implementation has already been modified to use states in #369, and the aima-pseudocode repository also already mentions this change in issue #45. So this issue can probably be closed now if the matter has been decided.

  8. dmeoli commented on Jun 26, 2026

    @dmeoli
    Member

    hill_climbing and simulated_annealing are both implemented in search.py. Closing as resolved — feel free to open a focused PR if you want thin player/partial wrappers specifically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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