You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Have wrappers for SIMULATED-ANNEALING and HILL-CLIMBING? #368
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).
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.
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.
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?
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.
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.
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.
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.
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.
Activity
kaivalyar commentedon Mar 17, 2017
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.
kaivalyar commentedon Mar 17, 2017
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?
norvig commentedon Mar 18, 2017
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.
kaivalyar commentedon Mar 18, 2017
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.
[-]Simulated-Annealing doesn't return a state[/-][+]Have wrappers for SIMULATED-ANNEALING and HILL-CLIMBING?[/+]norvig commentedon May 29, 2017
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.
kaivalyar commentedon May 29, 2017
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.
dmeoli commentedon Jun 26, 2026
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.