Optimization: principles and algorithms, by Michel Bierlaire
ex1402.m
Go to the documentation of this file.
1 %> @file
2 %> Example 14.2 in \cite Bier15-book
3 %> @author <a href="http://people.epfl.ch/michel.bierlaire">Michel Bierlaire</a>
4 %> @date Fri Mar 20 16:03:42 2015
5 %> @ingroup Examples
6 %> @ingroup chap14
7 
8 %> Example 14.2 in \cite Bier15-book
9 function [g,gradg] = ex1402(x)
10  alpha = [1.165 ; 0.626 ; 0.075 ; 0.351 ; -0.696] ;
11  beta = [1 ; -1 ; -1 ; 1 ; 1 ] ;
12  m = size(alpha,1) ;
13  n = size(x,1) ;
14  if (n != 2)
15  error("x should contain two entries");
16  endif
17  g = zeros(m,1) ;
18  gradg = zeros(n,m) ;
19  for i=1:m
20  [phi,deriv] = hyperbolicTangent(alpha(i) * x(1) + x(2)) ;
21  g(i) = phi - beta(i) ;
22  gradg(1,i) = alpha(i) * deriv ;
23  gradg(2,i) = deriv ;
24  endfor
25 endfunction
function hyperbolicTangent(in alpha)
Hyperbolic tangent function. Equation (14.9) in .
function ex1402(in x)
Example 14.2 in .
Copyright 2015-2016 Michel Bierlaire