2 %> Algorithm 15.2: Torczon algorithm. Implementation of algorithm 15.2 of \cite Bier15-book
4 %> @note Tested with \ref run1503torczon.m
6 %> @author Michel Bierlaire
7 %> @date Sun Mar 22 10:26:50 2015
11 %> Applies Torczon
's algorithm to solve \f$\min_x f(x)\f$ where \f$f:\mathbb{R}^n\to\mathbb{R}\f$. 12 %> @param obj the name of the Octave function defining f(x) 13 %> @param x0 matrix nx(n+1) containnig the initial simplex 14 %> @param eps algorithm stops if \f$\|x_{n+1}-x_1\| \leq \varepsilon \f$. 15 %> @param maxiter maximum number of iterations (Default: 100) 16 %> @return [solution,simplex]: the solution and the final simplex. 17 function [solution,simplex] = torczon(obj,x0,eps,maxiter=100) 21 error("Incorrect size") ; 30 f = [ f ; feval(obj,x(:,k)) ] ; 34 [worst,worstindex] = max(f) ; 36 [best,bestindex] = min(f) ; 39 printf("%e\t",x(jj,bestindex)) ; 43 d = x(:,worstindex) - x(:,bestindex) ; 50 xr(:,k) = 2 * x(:,bestindex) - x(:,k) ; 55 fr = [ fr ; feval(obj,xr(:,k)) ] ; 59 [bestr,bestrindex] = min(fr) ; 66 x(:,k) = 0.5 * (x(:,bestindex) + x(:,k)) ; 75 xe(:,k) = 3 * x(:,bestindex) - 2 * x(:,k) ; 80 fe = [ fe ; feval(obj,xe(:,k)) ] ; 84 [beste,besteindex] = min(fe) ; 95 until (norm(d) < eps || iter >= maxiter) 96 solution = x(:,bestindex) ;