Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
Simulated Annealing Two Variable Function Minimizer
===================================================
This program attempts to optimize the variables x and y such that the value of
the function func(x,y) is minimized, using simulated annealing.
Compile and run
---------------
make
./sa
Output
------
Each line of the form
(<x>,<y>) Delta: <d> --<accepted/rejected>
represents an attempt where x and y are perturbed values, d represents the
difference [(new value of f) - (old value of f)] and accepted/rejected is
indicated.
To view the attempt output better, reduce the number of iterations per round,
though this WILL reduce the final accuracy.
To see scatter plot of attempts, pipe the output to attempts.py:
./sa | ./attempts.py
Modifications to experiment with!
---------------------------------
- func(x,y)
- Sets the function to minimize
- The number of variables can also be increased for testing purposes, but
then this would need to be changed everywhere
- ITERATIONS macro at top of sa.cpp
- Represents number of iterations of [perturb and accept]
- Accuracy (usually) increases with increase in number of iterations!
- INIT_TEMP macro at top of sa.cpp
- Modifies the initial temperature, so initial variability is changed
- nextTemp()
- Sets the curve of the cooling schedule
- Refer to first link below (what-when-how.com)
Good Links
----------
http://what-when-how.com/artificial-intelligence/a-comparison-of-cooling-schedules-for-simulated-annealing-artificial-intelligence/
https://machinelearningmastery.com/simulated-annealing-from-scratch-in-python/
https://towardsdatascience.com/optimization-techniques-simulated-annealing-d6a4785a1de7
https://csg.sph.umich.edu/abecasis/class/2008/615.18.pdf