Optimization: principles and algorithms, by Michel Bierlaire
ex1906.m
Go to the documentation of this file.
1 %> \file
2 %> \f[\min f(x)=100(x_2-x_1^2)^2+(1-x_1)^2\f] subject to \f[x_1-x_2^2-\frac{1}{2} \f]
3 %> @author <a href="http://people.epfl.ch/michel.bierlaire">Michel Bierlaire</a>
4 %> @date Wed Mar 25 17:53:06 2015
5 %> @ingroup Examples
6 %> @ingroup chap19
7 
8 %> @param x value of the variables
9 %> @param index If 0, the objective function is evaluated. If not, the constraint number index is evaluated.
10 %> @return f value of the function
11 %> @return g value of the gradient
12 %> @return H value of the hessian
13 function [f,g,H] = ex1906(x,index)
14  if (index == 0)
15  f = 100.0 * (x(2) - x(1) * x(1))^2 + (1.0 - x(1))^2;
16  g = [ -400.0 * x(1) * x(2) + 400 * x(1)^3 - 2.0 + 2 * x(1) ;
17  200.0 * (x(2) - x(1)*x(1)) ];
18  H = [ -400.0 * x(2) + 1200.0 * x(1) * x(1) + 2.0 -400.0 * x(1) ;
19  -400.0 * x(1) 200.0] ;
20 
21  return ;
22  endif
23  if (index == 1)
24  f = x(1) - x(2) * x(2) - 0.5 ;
25  g = [ 1 ; -2.0 * x(2) ] ;
26  H = [0 0 ; 0 -2] ;
27  return
28  endif
29  error("There is only one constraint") ;
30 endfunction
function ex1906(in x, in index)
Copyright 2015-2018 Michel Bierlaire