


iteration step for golden line search (minimizer) THIS IS NO USER FUNCTION


0001 function [lineSearchStat, bestObject] = iterateLineSearchGolden(... 0002 lineSearchStat, bestObject, getObjectCall, objectiveFunction) 0003 % iteration step for golden line search (minimizer) 0004 % 0005 % THIS IS NO USER FUNCTION 0006 0007 % The elk-library: convex geometry applied to crystallization modeling. 0008 % Copyright (C) 2012 Alexander Reinhold 0009 % 0010 % This program is free software: you can redistribute it and/or modify it 0011 % under the terms of the GNU General Public License as published by the 0012 % Free Software Foundation, either version 3 of the License, or (at your 0013 % option) any later version. 0014 % 0015 % This program is distributed in the hope that it will be useful, but 0016 % WITHOUT ANY WARRANTY; without even the implied warranty of 0017 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0018 % General Public License for more details. 0019 % 0020 % You should have received a copy of the GNU General Public License along 0021 % with this program. If not, see <http://www.gnu.org/licenses/> 0022 0023 %% new guess 0024 % new data point 0025 newX = lineSearchStat(3,1) - (lineSearchStat(2,1) - lineSearchStat(1,1)); 0026 0027 % new objective function 0028 newObject = getObjectCall(newX); 0029 newObjective = objectiveFunction(newObject); 0030 0031 %% make a decision 0032 if lineSearchStat(2,2) < newObjective 0033 % current candidate remains 0034 if lineSearchStat(2,1) <= newX 0035 % right bound to abandon 0036 lineSearchStat(3,:) = [newX; newObjective]; 0037 else 0038 % left bound to abandon 0039 lineSearchStat(1,:) = [newX; newObjective]; 0040 end 0041 else 0042 % new candidate remains 0043 bestObject = newObject; 0044 if lineSearchStat(2,1) < newX 0045 % left bound to abandon 0046 lineSearchStat(1,:) = lineSearchStat(2,:); 0047 else 0048 % right bound to abandon 0049 lineSearchStat(3,:) = lineSearchStat(2,:); 0050 end 0051 lineSearchStat(2,:) = [newX; newObjective]; 0052 end