Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalize custom function interfaces #17

Open
chrisbloom7 opened this issue Feb 8, 2022 · 1 comment
Open

Normalize custom function interfaces #17

chrisbloom7 opened this issue Feb 8, 2022 · 1 comment

Comments

@chrisbloom7
Copy link
Collaborator

The 4 custom functions - energy_calculator, state_change, cool_down, and termination_condition - all have different method signatures that need to be adhered to when overriding them. I think we can normalize them pretty easily to make documenting their use a little easier.

  • Both energy_calculator and state_change currently expect one argument: the state of the current Metal instance being evaluated.
  • The newest function, cool_down, expects 4 arguments: the energy and temperature of the current Metal instance, the current cooling_rate config that has precedence (i.e. local versus global), and finally the steps the annealer has taken which make it possible to do exponential temperature reductions, etc. *
  • The termination_condition expects 3 arguments: the state, energy, and temperature of the current Metal instance *

With the exception of the cool_down function, all of the arguments are things the current Metal instance can tell us. So, I propose we:

  • Create a static, idempotent object that represents the current state of the annealing process during any given iteration. (Suggestions: Annealing::Step) Specifically, it would know the current state, energy, and temperature of the current metal instance, as well as the current cooling_rate and iteration (aka step) of the annealing simulator. The benefit of using a different class than Annealing::Metal is that some metal methods are not idempotent and shouldn't be called from outside the simulator itself, plus it lets us add info about the current simulation step without requiring Metal to start tracking things external to its own purpose.
  • Update the 4 custom function signatures to each accept a single argument representing this new object. Everything there is to know about the current state of the simulation becomes available to those custom functions and we don't have to try to guess at what might be helpful to someone in the future. And if we do need to add something, we can add it to to this new class and then it's available to all of the custom functions to use.

* For the two newest functions I could only make a reasonable guess as to what data might be helpful for all future use cases, though for my own purposes I only cared about cooling_rate and steps for the cool down function, and only energy for the termination condition.

@chrisbloom7
Copy link
Collaborator Author

chrisbloom7 commented Nov 5, 2022

Was doing some more reading about SA implementations in preparation for a presentation and noticed that some SA solutions choose a neighboring state as a function of k (where k might be the current iteration or current temperature, depending on if the algorithm supports reannealing) and where the new state is selected based on a probability distribution of scale k. Mentioning this as another argument in favor of having greater visibility into the current state of the annealer from state_change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant