Merge branch 'master' of ssh://git.code.sf.net/p/maxima/code
[maxima.git] / share / cobyla / ex / ex8.mac
blob55dcfb9934b0ab3670b26d7e3f087fed4595181f
1 /*
2  * Test problem 8 (Rosen-Suzuki)
3  *
4  * f = x1^2 + x2^2 + 2*x3^2 + x4^2 - 5*x1 - 5*x2 - 21*x3 + 7*x4
5  * 8-x1^2-x2^2-x3^2-x4^2-x1+x2-x3+x4 >= 0
6  * 10-x1^2-2*x2^2-x3^2-2*x4^2+x1+x4 >= 0
7  * 5-2*x1^2-x2^2-x3^2-2*x1+x2+x4
8  *
9  * True solution: x1=0, x2 = 1, x3 = 2, x4 = -1
10  */
12 fmin_cobyla(x1^2 + x2^2 + 2*x3^2 + x4^2 - 5*x1 - 5*x2 - 21*x3 + 7*x4, [x1, x2, x3, x4],
13             [1,1,1,1], 
14             constraints = [8-x1^2-x2^2-x3^2-x4^2-x1+x2-x3+x4 >= 0,
15              10-x1^2-2*x2^2-x3^2-2*x4^2+x1+x4 >= 0,
16              5-2*x1^2-x2^2-x3^2-2*x1+x2+x4 >= 0],
17             iprint = 1);
19 /* Output
21    Normal return from subroutine COBYLA
23    NFVALS =  116   F =-4.400000E+01    MAXCV = 3.319345E-12
24    X = 3.532758E-07   9.999990E-01   2.000000E+00  -1.000000E+00
26 [[x1 = 3.53275766748882e-7,x2 = .9999989781691816,
27           x3 = 2.000000039612459,x4 = -1.000000156831474],-44.00000000000451,
28          116, 0]
31 /* True output
33        Output from test problem 8 (Rosen-Suzuki)
35    Normal return from subroutine COBYLA
37    NFVALS =  116   F =-4.400000E+01    MAXCV = 3.321565E-12
38    X = 3.532420E-07   9.999990E-01   2.000000E+00  -1.000000E+00