diff options
author | RemyaDebasis | 2018-07-23 20:01:22 +0530 |
---|---|---|
committer | RemyaDebasis | 2018-07-23 20:01:22 +0530 |
commit | 69460c03b8b53068d60fd08d3180efc91e627603 (patch) | |
tree | 1689256f9ca4b9ce8076d3da8d5dac1b76963859 /code/fminsearch/FletcherPowell.sce | |
parent | f2539f26af7794da4ea4ccd8ae5ec2c753e94212 (diff) | |
download | FOT_Examples-69460c03b8b53068d60fd08d3180efc91e627603.tar.gz FOT_Examples-69460c03b8b53068d60fd08d3180efc91e627603.tar.bz2 FOT_Examples-69460c03b8b53068d60fd08d3180efc91e627603.zip |
added code files
Diffstat (limited to 'code/fminsearch/FletcherPowell.sce')
-rw-r--r-- | code/fminsearch/FletcherPowell.sce | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/code/fminsearch/FletcherPowell.sce b/code/fminsearch/FletcherPowell.sce new file mode 100644 index 0000000..b3b4971 --- /dev/null +++ b/code/fminsearch/FletcherPowell.sce @@ -0,0 +1,65 @@ +// This is an example for unconstraint nonlinear problems. +// Ref:R.fletcher and M.J.D Powell, A Rapidly Convergent Descent Method for Minimization Algorithms, Computer journal, Vol. 6, pp. 163-168, 1963 +//Example: +//f(x1,x2,x3) = 100*((x3 - 10*theta(x1,x2))^2 + (sqrt(x1^2 + x1^2) - 1)^2) + x3^2 +//theta(x1,x2) = (atan(x(2)/x(1)))/(2*%pi) if x(1)>0 +// = %pi + atan(x(2)/x(1)) if x(1)<0 +//====================================================================== +// Copyright (C) 2018 - IIT Bombay - FOSSEE +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt +// Author:Debasis Maharana +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in +//====================================================================== +clc; + +clc;clear;close + +function y = FletcherPowell(x) + if (x(1)>0) + theta_x1x2 = (atan(x(2)/x(1)))/(2*%pi); + elseif (x(1)<0) + theta_x1x2 = %pi + atan(x(2)/x(1)); + end + y = 100*( (x(3) - 10*theta_x1x2 ).^2 + (sqrt(x(1)^2 + x(2)^2) - 1)^2) + x(3)^2; +endfunction + +X0 = [-1 0 0]; +MFes = 500; +Miter = 200; +TF = 1D-10; +TX = 1D-10; +mprintf('The following settings are used\n Maximum iterations %d \n maximum functional exaluations %d\n Function tolerance %s \n variable tolerance %s ',Miter,MFes,string(TF),string(TX)); +input('Press enter to proceed ') +clc; +mprintf('Scilab is solving the problem...') + +options = optimset ("MaxFunEvals",MFes,"MaxIter",Miter,"PlotFcns",optimplotfval,"TolFun",TF,"TolX",TX); + +[x,fval,exitflag,output] = fminsearch(FletcherPowell,X0,options) +clc +select exitflag +case -1 + disp(output.algorithm, 'Algorithm used') + mprintf('\n The maximum number of iterations has been reached \n') + mprintf('\n The number of iterations %d ',output.iterations) + mprintf('\n The number of function evaluations %d',output.funcCount) +case 0 + disp(output.algorithm, 'Algorithm used ') + mprintf('\n The maximum number of function evaluations has been reached \n') + mprintf('\n The number of function evaluations %d',output.funcCount) + mprintf('\n The number of iterations %d ',output.iterations) + +case 1 + disp(output.algorithm, 'Algorithm used ') + mprintf('\n The tolerance on the simplex size and function value delta has been reached\n') + mprintf('\n The number of function evaluations %d',output.funcCount) + mprintf('\n The number of iterations %d ',output.iterations) +end + +disp(x,"The optimal solution is") +mprintf("\n The optimum value of the function is %s",string(fval)) |