Skip to content
Hüseyin Tuğrul BÜYÜKIŞIK edited this page Jul 4, 2023 · 2 revisions

Simulated annealing algorithm works for reducing the energy of a system. This is a kind of global-optimization problem and it is iteratively solved by selecting the best state and reproducing its randomized versions and repeating.

By default, every state clone runs on 256 GPU threads or OpenCL workitems. Each thread can compute a different part of the energy in parallel. For example, in a polynomial curve fitting algorithm, total energy would be the RMS error of the polynomial for all curve points. Each thread can work on just 1 data point to test the error so that 256 GPU threads can test 256 curve points at once, possibly even thousands of curve points with a simple loop structure.

When user-function body is finished, library adds all energies from 256 threads into single energy value and uses this value to compare to all other state clones. The best clone is selected and re-generated N-times with slightly cooler randomizations than before. This goes on until minimum temperature is reached.

The run method of UFSACL::UltraFastSimulatedAnnealing instance has a callback parameter for returning parameters for current energy level:

sim.build();
sim.run(
            startTemperature, stopTemperature, coolingRate, numReHeating, 
            debugPerformance, debugDevice, debugEnergy,
            [](float * optimizedParameters) {
                // callback that is called whenever a better(lower) energy is found
                for (int i = 0; i < 106; i++)
                {
                    // do something with new parameters
                }
                std::cout << "------" << std::endl;
            }
        );
Clone this wiki locally