lineSearchGolden

PURPOSE ^

golden line search (minimizer)

SYNOPSIS ^

function varargout = lineSearchGolden(getObjectCall, objectiveFunction,minGuess, maxGuess, tolGuess)

DESCRIPTION ^

 golden line search (minimizer)

 Syntax: bestObject = lineSearchGolden(getObjectCall, objectiveFunction,
                        minGuess, maxGuess, tolGuess)
        [bestObject, bestGuess, bestObjectiveValue] = ...
 
 The function tries to find an optimal object of arbitrary type:
     bestObject = getObjectCall(bestPoint)
   while minimizing the objective:
     bestObjective = objectiveFunction(bestObject).

 The guesses are scalar variables (line search is not suited for nD 
   optimization). The tolerance is absolute.

 THIS IS NO USER FUNCTION

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function varargout = lineSearchGolden(getObjectCall, objectiveFunction, ...
0002     minGuess, maxGuess, tolGuess)
0003 % golden line search (minimizer)
0004 %
0005 % Syntax: bestObject = lineSearchGolden(getObjectCall, objectiveFunction,
0006 %                        minGuess, maxGuess, tolGuess)
0007 %        [bestObject, bestGuess, bestObjectiveValue] = ...
0008 %
0009 % The function tries to find an optimal object of arbitrary type:
0010 %     bestObject = getObjectCall(bestPoint)
0011 %   while minimizing the objective:
0012 %     bestObjective = objectiveFunction(bestObject).
0013 %
0014 % The guesses are scalar variables (line search is not suited for nD
0015 %   optimization). The tolerance is absolute.
0016 %
0017 % THIS IS NO USER FUNCTION
0018 
0019 % The elk-library: convex geometry applied to crystallization modeling.
0020 %   Copyright (C) 2012 Alexander Reinhold
0021 %
0022 % This program is free software: you can redistribute it and/or modify it
0023 %   under the terms of the GNU General Public License as published by the
0024 %   Free Software Foundation, either version 3 of the License, or (at your
0025 %   option) any later version.
0026 %
0027 % This program is distributed in the hope that it will be useful, but
0028 %   WITHOUT ANY WARRANTY; without even the implied warranty of
0029 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0030 %   General Public License for more details.
0031 %
0032 % You should have received a copy of the GNU General Public License along
0033 %   with this program.  If not, see <http://www.gnu.org/licenses/>
0034 
0035 % The solver uses the matrix lineSearchStat too keep it's state
0036 %   information: x-position (1st column), objective value (2nd column);
0037 %   left bound (1st row), inner point (2nd row), right bound (3rd row).
0038 
0039 %% the golden ratio
0040 phi = (1+sqrt(5)) / 2;
0041 
0042 %% an inner sample point
0043 innerAngle = (phi-1)*minGuess + (2-phi)*maxGuess;
0044 
0045 %% compute objective functions
0046 minObjective = objectiveFunction(getObjectCall(minGuess));
0047 maxObjective = objectiveFunction(getObjectCall(maxGuess));
0048 bestObject = getObjectCall(innerAngle);
0049 innerObjective = objectiveFunction(bestObject);
0050 
0051 %% initialize line search status
0052 lineSearchStat = [minGuess, minObjective; ...
0053     innerAngle, innerObjective; ...
0054     maxGuess, maxObjective];
0055 
0056 %% iterate through golden line search (which is a minimizer)
0057 while abs(lineSearchStat(1,1) - lineSearchStat(3,1)) > tolGuess
0058     [lineSearchStat bestObject] = iterateLineSearchGolden(...
0059         lineSearchStat, bestObject, getObjectCall, objectiveFunction);
0060 end
0061 
0062 %% assign output
0063 switch nargout
0064     case 1
0065         varargout{1} = bestObject;
0066     case 3
0067         varargout{1} = bestObject;
0068         varargout{2} = lineSearchStat(2, 1);
0069         varargout{3} = lineSearchStat(2, 2);
0070 end

Generated on Sat 18-Jul-2015 16:45:31 by m2html © 2005