Anda di halaman 1dari 7

# OPTEC Simulated Annealing

Malgorzata Kamedula
Anoop Vargheese

Program

A Simulated_Annealing() function was created that implements the simulated annealing algorithm
for a general function. It takes the following values as parameters:
funcname - name of the target function
X0 - Initial position
Xmin - Lower limits
Xmax - Upper limits
Ti - Initial T value
a - T variance parameter
Tf - Final T value
max_iter - Maximum number of iterations
The outputs of this function are:
Xopt - The optimum value of X
Fopt - The optimum value of the function
Xhist - The history of optimum found by the algorithm
NoEval - The total number of evaluations

Simulation

The function was tested for two test functions, as shown below:

()

Where { } { } {

}
And

((

Where { } { } { } { }

Figure 1 : 1D Function Plot
-15 -10 -5 0 5 10 15
-9
-8
-7
-6
-5
-4
-3
-2
-1
0
x
f
(
x
)

Function
Intermediate optimum
Global optimum
0 100 200 300 400 500 600 700 800 900
-8
-7
-6
-5
-4
-3
-2
-1
0
Number of evaluations
F
u
n
c
t
i
o
n

m
i
n
i
m
u
m
For the 1D function, the parameters that we use are :
%Set parameters
funcname = 'test_func'; % Name of the test function
X0 = 14; % Initial value
Xmin = -15; % Lower limit of x
Xmax = +15; % Upper limit of x
Ti = 9; % Initial value of T
Tf = 0.0001; % Final value of T
a = 0.2; % T variance parameter
max_iter = 200; % Maximum number of iterations

The results of the function plot are shown in Figure 1, while Figure 2 shows the evolution of the
optimum value with the number of evaluations of the function.

Figure 2 : 1D Function Optimum Value History

-15 -10 -5 0 5 10 15
-9
-8
-7
-6
-5
-4
-3
-2
-1
0
x
f
(
x
)

Function
Intermediate optimum
Global optimum
0 100 200 300 400 500 600 700 800 900
-8
-7
-6
-5
-4
-3
-2
-1
0
Number of evaluations
F
u
n
c
t
i
o
n

m
i
n
i
m
u
m
For the 2D function, the parameters that we use are :
%Set paremeters
funcname = 'test_func2';
X0 = [5,5];
Xmin = [-10,-10];
Xmax = [+10,+10];
Ti = 5;
Tf = 0.0001;
a = 0.2;
max_iter = 400;

The results of the function plot are shown in Figure 3, while Figure 4Figure 1 shows the evolution of
the optimum value with the number of evaluations of the function.

Figure 3 : 2D Function Contour Plot
X2 axis
X
1

a
x
i
s

-10 -8 -6 -4 -2 0 2 4 6 8 10
-10
-8
-6
-4
-2
0
2
4
6
8
10
Function contours
Intermediate optimum
Global optimum
0 500 1000 1500 2000 2500
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Number of evaluations
F
u
n
c
t
i
o
n

m
i
n
i
m
u
m

Figure 4 : 2D Function Optimum Value History

X2 axis
X
1

a
x
i
s

-10 -8 -6 -4 -2 0 2 4 6 8 10
-10
-8
-6
-4
-2
0
2
4
6
8
10
Function contours
Intermediate optimum
Global optimum
0 500 1000 1500 2000 2500
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Number of evaluations
F
u
n
c
t
i
o
n

m
i
n
i
m
u
m
For the 1D function, we performed an analysis of the effect of each parameter on the result of the
simulation. The collected data are shown at Erreur ! Source du renvoi introuvable.. The random seed
used for these experiments is 1000, and is hardcoded into the Simulated_Annealing() function.
Tableau 1 : Parameter Variation Table
x0 T
i
T
f
max_iter no_eval
1 14 10 0,0001 400 266
2 14 10 0,0001 200 611
3 14 10 0,0001 100 376
4 14 5 0,0001 100 84
6 14 7 0,0001 100 189
7 14 12 0,0001 100 312
8 14 4 0,0001 100 294
10 14 5 0,1 100 84
11 14 4 0,01 100 294
12 14 4 0,05 100 294
13 14 4 0,1 100 294
14 14 4 0,5 100 294
15 14 4 0,7 100 294
18 14 4 1,001 500 296
19 14 4 0,01 500 396
20 14 4 0,5 500 396

Decreasing T
i
makes it less likely to explore the domain, causing it to get stuck in a local optimum.
However, a lower value of T
i
can make it converge faster, especially if the initial condition is already
near the optimum.
If the value of T
f
is too high, the program cannot accurately pinpoint the location of the optimum,
though it may be in the neighborhood of the global minimum. Otherwise, if T
f
is below a certain
threshold, it has no effect on the number of evaluations before which it approaches very close to the
optimum.
The effect of the maximum number of iterations cannot be correctly gauged from this experiment, as
the number of evaluations tends to vary randomly with this value. However, having a higher value for
the maximum number of iterations increases the chances of a successful result.