1 /* examples nicked from mailing list circa 2014-06-22
7 "minimize a quadratic" $
8 f(x1,x2):= x1^2 + x2^2 - x1*x2$
11 bf_fmin_cobyla (f(x1,x2), [x1,x2], [2.1,1], iprint=1, rhobeg=1e0, rhoend=1.0e-17, maxfun=150);
15 Normal return from subroutine COBYLA
16 NFVALS = 143 F = 1.128155E-34 MAXCV = 0.000000E+00
17 X =-1.128375E-18 1.001223E-17
19 [[x1=-1.128374744692965b-18,x2=1.001222755889425b-17],1.128154749711177b-34,143,0]
22 "previous example with iprint=2" $
23 bf_fmin_cobyla (f(x1,x2), [x1,x2], [2.1,1], iprint=2, rhobeg=1e0, rhoend=1.0e-17, maxfun=150);
25 " ... with iprint=3" $
26 bf_fmin_cobyla (f(x1,x2), [x1,x2], [2.1,1], iprint=3, rhobeg=1e0, rhoend=1.0e-17, maxfun=150);
31 bf_fmin_cobyla (gamma(x), [x], [1], iprint=2, rhobeg=1e0, rhoend=1.0e-17, maxfun=4);
35 The initial value of RHO is 1.000000E+00 and PARMU is set to zero.
36 NFVALS = 1 F = 1.000000E+00 MAXCV = 0.000000E+00
38 Reduction in RHO to 5.000000E-01 and PARMU = 0.000000E+00
39 NFVALS = 2 F = 1.000000E+00 MAXCV = 0.000000E+00
41 Reduction in RHO to 2.500000E-01 and PARMU = 0.000000E+00
42 NFVALS = 2 F = 1.000000E+00 MAXCV = 0.000000E+00
44 Return from subroutine COBYLA because the MAXFUN limit has been reached.
45 NFVALS = 4 F = 8.889136E-01 MAXCV = 0.000000E+00
47 (%o9) [[x=1.375b0],8.889135691562253b-1,4,1]
50 "previous example with iprint=1" $
51 bf_fmin_cobyla (gamma(x), [x], [1], iprint=1, rhobeg=1e0, rhoend=1.0e-17, maxfun=4);
53 " ... with iprint=3" $
54 bf_fmin_cobyla (gamma(x), [x], [1], iprint=3, rhobeg=1e0, rhoend=1.0e-17, maxfun=4);
56 "a function where lbfgs method would not perform well" $
57 f(x1,x2,x3):= max(abs(x1),abs(x2),abs(x3)) * 1007/1024 + min(abs(x1),abs(x2),abs(x3)) * 441/1024$
60 bf_fmin_cobyla (f(x1,x2,x3), [x1,x2,x3], [1,5,19], iprint=1, rhobeg=3e0, rhoend=1.0e-32, maxfun=1000);
64 Normal return from subroutine COBYLA
65 NFVALS = 462 F = 1.169500E-32 MAXCV = 0.000000E+00
66 X =-1.069009E-32 -4.749207E-33 -2.745488E-33
68 [[x1=-1.0690085067152158121096757933995b-32,x2=-4.7492069082040329311843970327941b-33,x3=-2.745488086010246824405303995104b-33],
69 1.1694996004446037185065599903685b-32,462,0]
72 "previous example with iprint=2" $
73 bf_fmin_cobyla (f(x1,x2,x3), [x1,x2,x3], [1,5,19], iprint=2, rhobeg=3e0, rhoend=1.0e-32, maxfun=1000);
75 " ... with iprint=3" $
76 bf_fmin_cobyla (f(x1,x2,x3), [x1,x2,x3], [1,5,19], iprint=3, rhobeg=3e0, rhoend=1.0e-32, maxfun=1000);
78 "same as the one before, with constraints this time" $
80 (f(x1,x2,x3), [x1,x2,x3], [1,5,19], constraints = [x1<=x2, x2<=x3, x3>=1],
81 iprint=1, rhobeg=3e0, rhoend=1.0e-32, maxfun=1000);
85 Normal return from subroutine COBYLA
86 NFVALS = 349 F = 9.833984E-01 MAXCV = 0.000000E+00
87 X = 6.896214E-33 8.576641E-02 1.000000E+00
89 [[x1=6.8962137487746352759712810153327b-33,x2=8.5766410691610366464841298096234b-2,x3=1.0b0],9.833984375b-1,349,0]
92 "previous example with iprint=2" $
94 (f(x1,x2,x3), [x1,x2,x3], [1,5,19], constraints = [x1<=x2, x2<=x3, x3>=1],
95 iprint=2, rhobeg=3e0, rhoend=1.0e-32, maxfun=1000);
97 " ... with iprint=3" $
99 (f(x1,x2,x3), [x1,x2,x3], [1,5,19], constraints = [x1<=x2, x2<=x3, x3>=1],
100 iprint=3, rhobeg=3e0, rhoend=1.0e-32, maxfun=1000);