0656bee7185d313f5b02a3d8b730d3dee064d0f0
[scilab.git] / scilab / modules / optimization / tests / unit_tests / neldermead / neldermead_newdestroy.dia.ref
1 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2 // Copyright (C) 2008-2009 - INRIA - Michael Baudin
3 // Copyright (C) 2010-2011 - DIGITEO - Michael Baudin
4 //
5 // Copyright (C) 2012 - 2016 - Scilab Enterprises
6 //
7 // This file is hereby licensed under the terms of the GNU GPL v2.0,
8 // pursuant to article 5.3.4 of the CeCILL v.2.1.
9 // This file was originally licensed under the terms of the CeCILL v2.1,
10 // and continues to be available under such terms.
11 // For more information, see the COPYING file which you should have received
12 // along with this program.
13 // <-- CLI SHELL MODE -->
14 // <-- ENGLISH IMPOSED -->
15 //
16 // Test basic new/destroy sequence
17 //
18 nm = neldermead_new ();
19 nm = neldermead_destroy(nm);
20 //
21 // Test printing system
22 //
23 nm = neldermead_new ();
24 str = string(nm)
25  str  = 
26 !Nelder-Mead Object:                                                   !
27 !                                                                      !
28 !======================                                                !
29 !                                                                      !
30 !                                                                      !
31 !                                                                      !
32 !Simplex0 Method : axes                                                !
33 !                                                                      !
34 !Simplex0 Length : 1                                                   !
35 !                                                                      !
36 !Simplex0, Pfeffer, Delta Usual : 0.05                                 !
37 !                                                                      !
38 !Simplex0, Pfeffer, Delta Zero : 0.0075                                !
39 !                                                                      !
40 !Simplex0, Given, Coords :                                             !
41 !                                                                      !
42 ![]                                                                    !
43 !                                                                      !
44 !                                                                      !
45 !                                                                      !
46 !Termination parameters                                                !
47 !                                                                      !
48 !Termination on simplex size : T                                       !
49 !                                                                      !
50 !Termination on simplex size, Absolute Tolerance : 0                   !
51 !                                                                      !
52 !Termination on simplex size, Relative Tolerance : 2.220D-16           !
53 !                                                                      !
54 !Termination on simplex size, Initial Simplex Size : 0                 !
55 !                                                                      !
56 !Termination on simplex size + Delta of function value : F             !
57 !                                                                      !
58 !Termination on simplex size + Delta of function value, Absolute Tolera!
59 !nce on Delta F : 2.220D-16                                            !
60 !                                                                      !
61 !Termination on Kelley's Stagnation : F                                !
62 !                                                                      !
63 !Termination on Kelley's Stagnation, Normalization : T                 !
64 !                                                                      !
65 !Termination on Kelley's Stagnation, Alpha0 : 0.0001                   !
66 !                                                                      !
67 !Termination on Kelley's Stagnation, Alpha : 0.0001                    !
68 !                                                                      !
69 !Termination by Box : F                                                !
70 !                                                                      !
71 !Termination by Box, Absolute Tolerance on Function: 0.00001           !
72 !                                                                      !
73 !Termination by Box, Maximum Number of Consecutive Match : 5           !
74 !                                                                      !
75 !Termination by Box, Current Number of Consecutive Match : 0           !
76 !                                                                      !
77 !Termination on Variance : F                                           !
78 !                                                                      !
79 !Termination on Variance, Absolute Tolerance : 0                       !
80 !                                                                      !
81 !Termination on Variance, Relative Tolerance : 2.220D-16               !
82 !                                                                      !
83 !Termination on Variance, Variance of Initial Simplex : 0              !
84 !                                                                      !
85 !                                                                      !
86 !                                                                      !
87 !Algorithms parameters                                                 !
88 !                                                                      !
89 !Method : variable                                                     !
90 !                                                                      !
91 !Reflection Factor (rho) : 1                                           !
92 !                                                                      !
93 !Expansion Factor (chi) : 2                                            !
94 !                                                                      !
95 !Contraction Factor (gamma) : 0.5                                      !
96 !                                                                      !
97 !Shrinkage Factor (sigma) : 0.5                                        !
98 !                                                                      !
99 !Kelley Stagnation : F                                                 !
100 !                                                                      !
101 !Restart Epsilon : 2.220D-16                                           !
102 !                                                                      !
103 !Restart Step : 1                                                      !
104 !                                                                      !
105 !Restart Maximum : 3                                                   !
106 !                                                                      !
107 !Restart Simplex Method : oriented                                     !
108 !                                                                      !
109 !Restart Flag : F                                                      !
110 !                                                                      !
111 !Restart Number : 0                                                    !
112 !                                                                      !
113 !Restart Detection Method : oneill                                     !
114 !                                                                      !
115 !Startup Flag : F                                                      !
116 !                                                                      !
117 !Automatic Checking of Cost Function : T                               !
118 !                                                                      !
119 !Box, Number of Points  : 2n                                           !
120 !                                                                      !
121 !Box, Current Number of Points  : 0                                    !
122 !                                                                      !
123 !Box, Scaling, Factor  : 0.5                                           !
124 !                                                                      !
125 !Box, Scaling, Method  : tox0                                          !
126 !                                                                      !
127 !Box, Scaling, Minimum : 0.00001                                       !
128 !                                                                      !
129 !Box, Bounds Parameter: 0.000001                                       !
130 !                                                                      !
131 !Box, Reflection Coefficient : 1.3                                     !
132 !                                                                      !
133 !                                                                      !
134 !                                                                      !
135 !optbase: <TOPTIM Object>                                              !
136 !                                                                      !
137 !simplex0: <TSIMPLEX Object>                                           !
138 !                                                                      !
139 !simplexopt: <constant Object>                                         !
140 assert_checkequal ( typeof(str) , "string" )
141  ans  =
142   T
143 nm
144  nm  = 
145 Nelder-Mead Object:
146 ======================
147 Simplex0 Method : axes
148 Simplex0 Length : 1
149 Simplex0, Pfeffer, Delta Usual : 0.05
150 Simplex0, Pfeffer, Delta Zero : 0.0075
151 Simplex0, Given, Coords :
152 []
153 Termination parameters
154 Termination on simplex size : T
155 Termination on simplex size, Absolute Tolerance : 0
156 Termination on simplex size, Relative Tolerance : 2.220D-16
157 Termination on simplex size, Initial Simplex Size : 0
158 Termination on simplex size + Delta of function value : F
159 Termination on simplex size + Delta of function value, Absolute Tolerance on Delta F : 2.220D-16
160 Termination on Kelley's Stagnation : F
161 Termination on Kelley's Stagnation, Normalization : T
162 Termination on Kelley's Stagnation, Alpha0 : 0.0001
163 Termination on Kelley's Stagnation, Alpha : 0.0001
164 Termination by Box : F
165 Termination by Box, Absolute Tolerance on Function: 0.00001
166 Termination by Box, Maximum Number of Consecutive Match : 5
167 Termination by Box, Current Number of Consecutive Match : 0
168 Termination on Variance : F
169 Termination on Variance, Absolute Tolerance : 0
170 Termination on Variance, Relative Tolerance : 2.220D-16
171 Termination on Variance, Variance of Initial Simplex : 0
172 Algorithms parameters
173 Method : variable
174 Reflection Factor (rho) : 1
175 Expansion Factor (chi) : 2
176 Contraction Factor (gamma) : 0.5
177 Shrinkage Factor (sigma) : 0.5
178 Kelley Stagnation : F
179 Restart Epsilon : 2.220D-16
180 Restart Step : 1
181 Restart Maximum : 3
182 Restart Simplex Method : oriented
183 Restart Flag : F
184 Restart Number : 0
185 Restart Detection Method : oneill
186 Startup Flag : F
187 Automatic Checking of Cost Function : T
188 Box, Number of Points  : 2n
189 Box, Current Number of Points  : 0
190 Box, Scaling, Factor  : 0.5
191 Box, Scaling, Method  : tox0
192 Box, Scaling, Minimum : 0.00001
193 Box, Bounds Parameter: 0.000001
194 Box, Reflection Coefficient : 1.3
195 optbase: <TOPTIM Object>
196 simplex0: <TSIMPLEX Object>
197 simplexopt: <constant Object>
198 nm = neldermead_destroy(nm);
199 //
200 // optimtestcase --
201 //   Non linear inequality constraints are positive.
202 //    
203 // Arguments
204 //   x: the point where to compute the function
205 //   index : the stuff to compute
206 //
207 function [ f , c , index ] = optimtestcase ( x , index )
208   f = []
209   c = []
210   if ( index == 2 | index == 6 ) then
211     f = x(1)^2 + x(2)^2 + 2.0 * x(3)^2 + x(4)^2 ...
212       - 5.0 * x(1) - 5.0 * x(2) - 21.0 * x(3) + 7.0 * x(4)
213   end
214   if ( index == 5 | index == 6 ) then
215     c1 = - x(1)^2 - x(2)^2 - x(3)^2 - x(4)^2 ...
216               - x(1) + x(2) - x(3) + x(4) + 8
217     c2 = - x(1)^2 - 2.0 * x(2)^2 - x(3)^2 - 2.0 * x(4)^2 ...
218               + x(1) + x(4) + 10.0
219     c3 = - 2.0 * x(1)^2 - x(2)^2 - x(3)^2 - 2.0 * x(1) ...
220               + x(2) + x(4) + 5.0
221     c = [c1 c2 c3]
222   end
223 endfunction
224 //
225 // Test printing system with various options configured
226 //
227 nm = neldermead_new ();
228 nm = neldermead_configure(nm,"-numberofvariables",4);
229 nm = neldermead_configure(nm,"-function",optimtestcase);
230 nm = neldermead_configure(nm,"-x0",[0.0 0.0 0.0 0.0]');
231 nm = neldermead_configure(nm,"-maxiter",200);
232 nm = neldermead_configure(nm,"-maxfunevals",1000);
233 nm = neldermead_configure(nm,"-tolsimplexizerelative",1.e-4);
234 nm = neldermead_configure(nm,"-simplex0method","axes");
235 nm = neldermead_configure(nm,"-method","box");
236 nm = neldermead_configure(nm,"-nbineqconst",3);
237 nm = neldermead_configure(nm,"-simplex0length",20.0);
238 str = string(nm)
239  str  = 
240 !Nelder-Mead Object:                                                   !
241 !                                                                      !
242 !======================                                                !
243 !                                                                      !
244 !                                                                      !
245 !                                                                      !
246 !Simplex0 Method : axes                                                !
247 !                                                                      !
248 !Simplex0 Length : 20                                                  !
249 !                                                                      !
250 !Simplex0, Pfeffer, Delta Usual : 0.05                                 !
251 !                                                                      !
252 !Simplex0, Pfeffer, Delta Zero : 0.0075                                !
253 !                                                                      !
254 !Simplex0, Given, Coords :                                             !
255 !                                                                      !
256 ![]                                                                    !
257 !                                                                      !
258 !                                                                      !
259 !                                                                      !
260 !Termination parameters                                                !
261 !                                                                      !
262 !Termination on simplex size : T                                       !
263 !                                                                      !
264 !Termination on simplex size, Absolute Tolerance : 0                   !
265 !                                                                      !
266 !Termination on simplex size, Relative Tolerance : 0.0001              !
267 !                                                                      !
268 !Termination on simplex size, Initial Simplex Size : 0                 !
269 !                                                                      !
270 !Termination on simplex size + Delta of function value : F             !
271 !                                                                      !
272 !Termination on simplex size + Delta of function value, Absolute Tolera!
273 !nce on Delta F : 2.220D-16                                            !
274 !                                                                      !
275 !Termination on Kelley's Stagnation : F                                !
276 !                                                                      !
277 !Termination on Kelley's Stagnation, Normalization : T                 !
278 !                                                                      !
279 !Termination on Kelley's Stagnation, Alpha0 : 0.0001                   !
280 !                                                                      !
281 !Termination on Kelley's Stagnation, Alpha : 0.0001                    !
282 !                                                                      !
283 !Termination by Box : F                                                !
284 !                                                                      !
285 !Termination by Box, Absolute Tolerance on Function: 0.00001           !
286 !                                                                      !
287 !Termination by Box, Maximum Number of Consecutive Match : 5           !
288 !                                                                      !
289 !Termination by Box, Current Number of Consecutive Match : 0           !
290 !                                                                      !
291 !Termination on Variance : F                                           !
292 !                                                                      !
293 !Termination on Variance, Absolute Tolerance : 0                       !
294 !                                                                      !
295 !Termination on Variance, Relative Tolerance : 2.220D-16               !
296 !                                                                      !
297 !Termination on Variance, Variance of Initial Simplex : 0              !
298 !                                                                      !
299 !                                                                      !
300 !                                                                      !
301 !Algorithms parameters                                                 !
302 !                                                                      !
303 !Method : box                                                          !
304 !                                                                      !
305 !Reflection Factor (rho) : 1                                           !
306 !                                                                      !
307 !Expansion Factor (chi) : 2                                            !
308 !                                                                      !
309 !Contraction Factor (gamma) : 0.5                                      !
310 !                                                                      !
311 !Shrinkage Factor (sigma) : 0.5                                        !
312 !                                                                      !
313 !Kelley Stagnation : F                                                 !
314 !                                                                      !
315 !Restart Epsilon : 2.220D-16                                           !
316 !                                                                      !
317 !Restart Step : 1                                                      !
318 !                                                                      !
319 !Restart Maximum : 3                                                   !
320 !                                                                      !
321 !Restart Simplex Method : oriented                                     !
322 !                                                                      !
323 !Restart Flag : F                                                      !
324 !                                                                      !
325 !Restart Number : 0                                                    !
326 !                                                                      !
327 !Restart Detection Method : oneill                                     !
328 !                                                                      !
329 !Startup Flag : F                                                      !
330 !                                                                      !
331 !Automatic Checking of Cost Function : T                               !
332 !                                                                      !
333 !Box, Number of Points  : 2n                                           !
334 !                                                                      !
335 !Box, Current Number of Points  : 0                                    !
336 !                                                                      !
337 !Box, Scaling, Factor  : 0.5                                           !
338 !                                                                      !
339 !Box, Scaling, Method  : tox0                                          !
340 !                                                                      !
341 !Box, Scaling, Minimum : 0.00001                                       !
342 !                                                                      !
343 !Box, Bounds Parameter: 0.000001                                       !
344 !                                                                      !
345 !Box, Reflection Coefficient : 1.3                                     !
346 !                                                                      !
347 !                                                                      !
348 !                                                                      !
349 !optbase: <TOPTIM Object>                                              !
350 !                                                                      !
351 !simplex0: <TSIMPLEX Object>                                           !
352 !                                                                      !
353 !simplexopt: <constant Object>                                         !
354 assert_checkequal ( typeof(str) , "string" )
355  ans  =
356   T
357 nm
358  nm  = 
359 Nelder-Mead Object:
360 ======================
361 Simplex0 Method : axes
362 Simplex0 Length : 20
363 Simplex0, Pfeffer, Delta Usual : 0.05
364 Simplex0, Pfeffer, Delta Zero : 0.0075
365 Simplex0, Given, Coords :
366 []
367 Termination parameters
368 Termination on simplex size : T
369 Termination on simplex size, Absolute Tolerance : 0
370 Termination on simplex size, Relative Tolerance : 0.0001
371 Termination on simplex size, Initial Simplex Size : 0
372 Termination on simplex size + Delta of function value : F
373 Termination on simplex size + Delta of function value, Absolute Tolerance on Delta F : 2.220D-16
374 Termination on Kelley's Stagnation : F
375 Termination on Kelley's Stagnation, Normalization : T
376 Termination on Kelley's Stagnation, Alpha0 : 0.0001
377 Termination on Kelley's Stagnation, Alpha : 0.0001
378 Termination by Box : F
379 Termination by Box, Absolute Tolerance on Function: 0.00001
380 Termination by Box, Maximum Number of Consecutive Match : 5
381 Termination by Box, Current Number of Consecutive Match : 0
382 Termination on Variance : F
383 Termination on Variance, Absolute Tolerance : 0
384 Termination on Variance, Relative Tolerance : 2.220D-16
385 Termination on Variance, Variance of Initial Simplex : 0
386 Algorithms parameters
387 Method : box
388 Reflection Factor (rho) : 1
389 Expansion Factor (chi) : 2
390 Contraction Factor (gamma) : 0.5
391 Shrinkage Factor (sigma) : 0.5
392 Kelley Stagnation : F
393 Restart Epsilon : 2.220D-16
394 Restart Step : 1
395 Restart Maximum : 3
396 Restart Simplex Method : oriented
397 Restart Flag : F
398 Restart Number : 0
399 Restart Detection Method : oneill
400 Startup Flag : F
401 Automatic Checking of Cost Function : T
402 Box, Number of Points  : 2n
403 Box, Current Number of Points  : 0
404 Box, Scaling, Factor  : 0.5
405 Box, Scaling, Method  : tox0
406 Box, Scaling, Minimum : 0.00001
407 Box, Bounds Parameter: 0.000001
408 Box, Reflection Coefficient : 1.3
409 optbase: <TOPTIM Object>
410 simplex0: <TSIMPLEX Object>
411 simplexopt: <constant Object>
412 nm = neldermead_destroy(nm);