summaryrefslogtreecommitdiff
path: root/code/fminbnd/MichalewiczFunction.sce
diff options
context:
space:
mode:
Diffstat (limited to 'code/fminbnd/MichalewiczFunction.sce')
-rw-r--r--code/fminbnd/MichalewiczFunction.sce29
1 files changed, 29 insertions, 0 deletions
diff --git a/code/fminbnd/MichalewiczFunction.sce b/code/fminbnd/MichalewiczFunction.sce
new file mode 100644
index 0000000..b700973
--- /dev/null
+++ b/code/fminbnd/MichalewiczFunction.sce
@@ -0,0 +1,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')
+
+
+
+
+