summaryrefslogtreecommitdiff
path: root/code/fminbnd/MichalewiczFunction.sce
blob: b700973dd70584d670ae34b0cc62286a7d90b3e5 (plain)
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
//Reference: Michalewicz, Z.: Genetic Algorithms + Data Structures = Evolution Programs. Berlin, Heidelberg, New York: Springer-Verlag, 1992

// MICHALEWICZ FUNCTION
clc; 
function f = ObjectiveFunction(X)
    m = 10;
    nVar = length(X);
    d = length(X);
    f = 0;
    for n = 1:nVar
        f = f - sin(X(n))*((sin((n*X(n)^2)/%pi))^(2*m));
    end

    f = -f;
endfunction

nVar = 2;
lb = zeros(1,nVar);
ub = %pi*ones(1,nVar);
[xopt,fopt,exitflag,output,lambda] = fminbnd(ObjectiveFunction,lb,ub)

disp (nVar)
disp(fopt)
disp(xopt')