1// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2// Copyright (C) 2008-2009 - INRIA - Michael Baudin
3// Copyright (C) 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//  Reference:
17//
18//    An extension of the simplex method to constrained
19//    nonlinear optimization
20//    M.B. Subrahmanyam
21//    Journal of optimization theory and applications
22//    Vol. 62, August 1989
23//
24//    Gould F.J.
25//    Nonlinear Tolerance Programming
26//    Numerical methods for Nonlinear optimization
27//    Edited by F.A. Lootsma, pp 349-366, 1972
28//
29// optimtestcase --
30//   Non linear inequality constraints are positive.
31//
32// Arguments
33//   x: the point where to compute the function
34//   index : what to compute
35//     if index=2, returns f
36//     if index=5, returns c
37//     if index=6, returns f and c
38// Note
39//  The inequality constraints are expected to be positive.
40//
41function [ f , c , index ] = optimtestcase ( x , index )
42  f = []
43  c = []
44  if ( ( index == 2 ) | ( index == 6 ) ) then
45    f = x(1)^2 + x(2)^2 + 2.0 * x(3)^2 + x(4)^2 ...
46      - 5.0 * x(1) - 5.0 * x(2) - 21.0 * x(3) + 7.0 * x(4)
47  end
48  if ( ( index == 5 ) | ( index == 6 ) ) then
49    c1 = - x(1)^2 - x(2)^2 - x(3)^2 - x(4)^2 ...
50              - x(1) + x(2) - x(3) + x(4) + 8
51    c2 = - x(1)^2 - 2.0 * x(2)^2 - x(3)^2 - 2.0 * x(4)^2 ...
52              + x(1) + x(4) + 10.0
53    c3 = - 2.0 * x(1)^2 - x(2)^2 - x(3)^2 - 2.0 * x(1) ...
54              + x(2) + x(4) + 5.0
55    c = [c1 c2 c3]
56  end
57endfunction
58function [ f , c , index ] = optimtestcase2 ( x , index )
59  f = []
60  c = []
61  x2 = x.^2
62  if ( ( index == 2 ) | ( index == 6 ) ) then
63    f = [1 1 2 1]*x2 + [-5 -5 -21 7]*x
64  end
65  if ( ( index == 5 ) | ( index == 6 ) ) then
66    c1 = [-1 -1 -1 -1]*x2 + [-1 1 -1 1]*x + 8
67    c2 = [-1 -2 -1 -2]*x2 + [1 0 0 1]*x + 10
68    c3 = [-2 -1 -1 0]*x2 + [-2 1 0 1]*x + 5
69    c = [c1 c2 c3]
70  end
71endfunction
72//
73// Test the function.
74//
75xstar = [0.0 1.0 2.0 -1.0]';
76fstar = -44;
77[ f , c , index ] = optimtestcase ( xstar , 6 );
78assert_checkequal ( f , fstar );
79assert_checkequal ( c , [0 1 0] );
80//
81[ f , c , index ] = optimtestcase2 ( xstar , 6 );
82assert_checkequal ( f , fstar );
83assert_checkequal ( c , [0 1 0] );
84//
85// Test with Box algorithm and default axes initial simplex
86//
87nm = neldermead_new ();
88nm = neldermead_configure(nm,"-numberofvariables",4);
89nm = neldermead_configure(nm,"-function",optimtestcase2);
90nm = neldermead_configure(nm,"-x0",[0.0 0.5 1.0 -0.5]');
91nm = neldermead_configure(nm,"-maxiter",400);
92nm = neldermead_configure(nm,"-maxfunevals",1000);
93nm = neldermead_configure(nm,"-tolsimplexizerelative",1.e-2);
94nm = neldermead_configure(nm,"-simplex0method","axes");
95nm = neldermead_configure(nm,"-method","box");
96nm = neldermead_configure(nm,"-nbineqconst",3);
97nm = neldermead_search(nm);
98// Check optimum point
99xopt = neldermead_get(nm,"-xopt");
100assert_checkalmostequal ( xopt , [0.0 1.0 2.0 -1.0]', 1e-1 , 1.e-1);
101// Check optimum point value
102fopt = neldermead_get(nm,"-fopt");
103assert_checkalmostequal ( fopt , -44.0 , 1e-2 );
104// Check status
105status = neldermead_get(nm,"-status");
106assert_checkequal ( status , "tolsize" );
107nm = neldermead_destroy(nm);
108//
109// Test with Box algorithm and restart
110//
111nm = neldermead_new ();
112nm = neldermead_configure(nm,"-numberofvariables",4);
113nm = neldermead_configure(nm,"-function",optimtestcase2);
114nm = neldermead_configure(nm,"-x0",[0.0 0.0 0.0 0.0]');
115nm = neldermead_configure(nm,"-maxiter",200);
116nm = neldermead_configure(nm,"-maxfunevals",300);
117nm = neldermead_configure(nm,"-tolsimplexizerelative",1.e-1);
118nm = neldermead_configure(nm,"-simplex0method","axes");
119nm = neldermead_configure(nm,"-method","box");
120nm = neldermead_configure(nm,"-nbineqconst",3);
121nm = neldermead_search(nm);
122nm = neldermead_restart(nm);
123optimbase_terminate: Exiting: Maximum number of function evaluations has been exceeded
124          - increase MaxFunEvals option.
125// Check optimum point
126xopt = neldermead_get(nm,"-xopt");
127assert_checkalmostequal ( xopt , [0.0 1.0 2.0 -1.0]', 1e-1, 1e-1 );
128// Check optimum point value
129fopt = neldermead_get(nm,"-fopt");
130assert_checkalmostequal ( fopt , -44.0 , 1e-2 );
131// Check status
132status = neldermead_get(nm,"-status");
133assert_checkequal ( status , "maxfuneval" );
134nm = neldermead_destroy(nm);
135//
136// Test with Box algorithm and default axes initial simplex
137// Add bounds and simplex initial length so that there is a need
138// for variable projection.
139//
140nm = neldermead_new ();
141nm = neldermead_configure(nm,"-numberofvariables",4);
142nm = neldermead_configure(nm,"-function",optimtestcase2);
143nm = neldermead_configure(nm,"-x0",[0.0 0.0 0.0 0.0]');
144nm = neldermead_configure(nm,"-maxiter",400);
145nm = neldermead_configure(nm,"-maxfunevals",1000);
146nm = neldermead_configure(nm,"-tolsimplexizerelative",1.e-2);
147nm = neldermead_configure(nm,"-simplex0method","axes");
148nm = neldermead_configure(nm,"-method","box");
149nm = neldermead_configure(nm,"-nbineqconst",3);
150nm = neldermead_configure(nm,"-boundsmin",[-10.0 -10.0 -10.0 -10.0]);
151nm = neldermead_configure(nm,"-boundsmax",[10.0 10.0 10.0 10.0]);
152nm = neldermead_configure(nm,"-simplex0length",20.0);
153nm = neldermead_search(nm);
154// Check optimum point
155xopt = neldermead_get(nm,"-xopt");
156assert_checkalmostequal ( xopt , [0.0 1.0 2.0 -1.0]', 1e-1, 1e-1 );
157// Check optimum point value
158fopt = neldermead_get(nm,"-fopt");
159assert_checkalmostequal ( fopt , -44.0 , 1e-3 );
160// Check status
161status = neldermead_get(nm,"-status");
162assert_checkequal ( status , "tolsize" );
163nm = neldermead_destroy(nm);
164//
165// Test with Box algorithm and randomized bounds simplex.
166// Add bounds and simplex initial length so that there is a need
167// for variable projection.
168// Here the initial simplex is computed with Box randomized bounds method
169// and default number of points in the simplex, i.e. 2n = 2 * 4 = 8.
170//
171// The convergence is not accurate in this case, whatever the
172// value of the relative tolerance on simplex size.
173//
174//
175// Initialize the random number generator, so that the results are always the
176// same.
177//
178rand("seed" , 0)
179nm = neldermead_new ();
180nm = neldermead_configure(nm,"-numberofvariables",4);
181nm = neldermead_configure(nm,"-function",optimtestcase2);
182nm = neldermead_configure(nm,"-x0",[0.0 0.0 0.0 0.0]');
183nm = neldermead_configure(nm,"-maxiter",300);
184nm = neldermead_configure(nm,"-maxfunevals",1000);
185nm = neldermead_configure(nm,"-tolsimplexizerelative",1.e-2);
186nm = neldermead_configure(nm,"-method","box");
187nm = neldermead_configure(nm,"-nbineqconst",3);
188nm = neldermead_configure(nm,"-boundsmin",[-10.0 -10.0 -10.0 -10.0]);
189nm = neldermead_configure(nm,"-boundsmax",[10.0 10.0 10.0 10.0]);
190nm = neldermead_configure(nm,"-simplex0length",20.0);
191nm = neldermead_configure(nm,"-simplex0method","randbounds");
192nm = neldermead_search(nm);
193// Check optimum point
194xopt = neldermead_get(nm,"-xopt");
195assert_checkalmostequal ( xopt , [0.0 1.0 2.0 -1.0]', 1e-0 );
196// Check optimum point value
197fopt = neldermead_get(nm,"-fopt");
198assert_checkalmostequal ( fopt , -44.0 , 1e-1 );
199// Check status
200status = neldermead_get(nm,"-status");
201assert_checkequal ( status , "tolsize" );
202// Check the optimum simplex
203simplexopt = neldermead_get ( nm , "-simplexopt" );
204nbve = optimsimplex_getnbve ( simplexopt );
205assert_checkequal ( nbve , 8 );
206nm = neldermead_destroy(nm);
207//
208// Test with Box algorithm and randomized bounds simplex.
209// Add bounds and simplex initial length so that there is a need
210// for variable projection.
211// Here the initial simplex is computed with Box randomized bounds method
212// and user-defined number of points in the simplex, i.e. 6
213//
214//
215// Initialize the random number generator, so that the results are always the
216// same.
217//
218rand("seed" , 0)
219nm = neldermead_new ();
220nm = neldermead_configure(nm,"-numberofvariables",4);
221nm = neldermead_configure(nm,"-function",optimtestcase2);
222nm = neldermead_configure(nm,"-x0",[0.0 0.0 0.0 0.0]');
223nm = neldermead_configure(nm,"-maxiter",300);
224nm = neldermead_configure(nm,"-maxfunevals",1000);
225nm = neldermead_configure(nm,"-tolsimplexizerelative",1.e-2);
226nm = neldermead_configure(nm,"-method","box");
227nm = neldermead_configure(nm,"-nbineqconst",3);
228nm = neldermead_configure(nm,"-boundsmin",[-10.0 -10.0 -10.0 -10.0]);
229nm = neldermead_configure(nm,"-boundsmax",[10.0 10.0 10.0 10.0]);
230nm = neldermead_configure(nm,"-simplex0length",20.0);
231nm = neldermead_configure(nm,"-simplex0method","randbounds");
232nm = neldermead_configure(nm,"-boxnbpoints",6);
233nm = neldermead_search(nm);
234// Check optimum point
235xopt = neldermead_get(nm,"-xopt");
236assert_checkalmostequal ( xopt , [0.0 1.0 2.0 -1.0]', 1e-1, 1e-1 );
237// Check optimum point value
238fopt = neldermead_get(nm,"-fopt");
239assert_checkalmostequal ( fopt , -44.0 , 1e-2 );
240// Check status
241status = neldermead_get(nm,"-status");
242assert_checkequal ( status , "tolsize" );
243// Check the optimum simplex
244simplexopt = neldermead_get ( nm , "-simplexopt" );
245nbve = optimsimplex_getnbve ( simplexopt );
246assert_checkequal ( nbve , 6 );
247nm = neldermead_destroy(nm);
248//
249// Test with "tocenter"
250//
251rand("seed" , 0)
252nm = neldermead_new ();
253nm = neldermead_configure(nm,"-numberofvariables",4);
254nm = neldermead_configure(nm,"-function",optimtestcase2);
255nm = neldermead_configure(nm,"-x0",[0.0 0.0 0.0 0.0]');
256nm = neldermead_configure(nm,"-maxiter",300);
257nm = neldermead_configure(nm,"-maxfunevals",1000);
258nm = neldermead_configure(nm,"-tolsimplexizerelative",1.e-2);
259nm = neldermead_configure(nm,"-method","box");
260nm = neldermead_configure(nm,"-nbineqconst",3);
261nm = neldermead_configure(nm,"-boundsmin",[-10.0 -10.0 -10.0 -10.0]);
262nm = neldermead_configure(nm,"-boundsmax",[10.0 10.0 10.0 10.0]);
263nm = neldermead_configure(nm,"-simplex0length",20.0);
264nm = neldermead_configure(nm,"-simplex0method","randbounds");
265nm = neldermead_configure(nm,"-boxnbpoints",6);
266nm = neldermead_configure(nm,"-scalingsimplex0","tocenter");
267nm = neldermead_search(nm);
268// Check optimum point
269xopt = neldermead_get(nm,"-xopt");
270assert_checkalmostequal ( xopt , [0.0 1.0 2.0 -1.0]', 1e-1, 1e-1 );
271// Check optimum point value
272fopt = neldermead_get(nm,"-fopt");
273assert_checkalmostequal ( fopt , -44.0 , 1e-2 );
274// Check status
275status = neldermead_get(nm,"-status");
276assert_checkequal ( status , "tolsize" );
277// Check the optimum simplex
278simplexopt = neldermead_get ( nm , "-simplexopt" );
279nbve = optimsimplex_getnbve ( simplexopt );
280assert_checkequal ( nbve , 6 );
281nm = neldermead_destroy(nm);
282//
283// Test with Box algorithm and given simplex.
284// Add bounds and simplex initial length so that there is a need
285// for variable projection.
286// Here the initial simplex is user-defined.
287// Makes sure that all auxiliary computations are performed.
288// I put the solution as the last point, to see what happens
289//
290nm = neldermead_new ();
291nm = neldermead_configure(nm,"-numberofvariables",4);
292nm = neldermead_configure(nm,"-function",optimtestcase2);
293nm = neldermead_configure(nm,"-x0",[0.0 0.0 0.0 0.0]');
294nm = neldermead_configure(nm,"-maxiter",300);
295nm = neldermead_configure(nm,"-maxfunevals",1000);
296nm = neldermead_configure(nm,"-tolsimplexizerelative",1.e-2);
297nm = neldermead_configure(nm,"-method","box");
298nm = neldermead_configure(nm,"-nbineqconst",3);
299nm = neldermead_configure(nm,"-boundsmin",[-10.0 -10.0 -10.0 -10.0]);
300nm = neldermead_configure(nm,"-boundsmax",[10.0 10.0 10.0 10.0]);
301nm = neldermead_configure(nm,"-simplex0method","given");
302coords = [
3030.0 0.0 0.0 0.0
3041.0 0.0 0.0 0.0
3050.0 1.0 0.0 0.0
3060.0 0.0 1.0 0.0
3070.0 0.0 0.0 1.0
3081.0 1.0 1.0 1.0
3090.0 1.0 2.0 -1.0
310];
311nm = neldermead_configure(nm,"-coords0",coords);
312nm = neldermead_search(nm);
313// Check optimum point
314xopt = neldermead_get(nm,"-xopt");
315assert_checkalmostequal ( xopt , [0.0 1.0 2.0 -1.0]', 1e-2 );
316// Check optimum point value
317fopt = neldermead_get(nm,"-fopt");
318assert_checkalmostequal ( fopt , -44.0 , 1e-4 );
319// Check status
320status = neldermead_get(nm,"-status");
321assert_checkequal ( status , "tolsize" );
322// Check the optimum simplex
323simplexopt = neldermead_get ( nm , "-simplexopt" );
324nbve = optimsimplex_getnbve ( simplexopt );
325assert_checkequal ( nbve , 7 );
326nm = neldermead_destroy(nm);
327//
328// Test with Box algorithm and randomized bounds simplex.
329// Test that verbose mode works fine.
330//
331rand("seed" , 0)
332nm = neldermead_new ();
333nm = neldermead_configure(nm,"-numberofvariables",4);
334nm = neldermead_configure(nm,"-function",optimtestcase2);
335nm = neldermead_configure(nm,"-x0",[0.0 0.0 0.0 0.0]');
336nm = neldermead_configure(nm,"-maxiter",5);
337nm = neldermead_configure(nm,"-maxfunevals",1000);
338nm = neldermead_configure(nm,"-tolsimplexizerelative",1.e-3);
339nm = neldermead_configure(nm,"-method","box");
340nm = neldermead_configure(nm,"-nbineqconst",3);
341nm = neldermead_configure(nm,"-verbose",1);
342nm = neldermead_configure(nm,"-verbosetermination",1);
343nm = neldermead_configure(nm,"-boundsmin",[-10.0 -10.0 -10.0 -10.0]);
344nm = neldermead_configure(nm,"-boundsmax",[10.0 10.0 10.0 10.0]);
345nm = neldermead_configure(nm,"-simplex0method","randbounds");
346nm = neldermead_search(nm, "off");
347Function Evaluation #1, index=1, x= [0 0 0 0]
348Function Evaluation #2, index=2, x= [0 0 0 0]
349Function Evaluation #3, index=5, x= [0 0 0 0]
350Function Evaluation #4, index=6, x= [0 0 0 0]
351Function Evaluation #5, index=5, x= [0 0 0 0]
352Scaling initial simplex into nonlinear inequality constraints...
353Scaling vertex #2/8 at [-5.7735027 5.1208771 -9.9955773 -3.3934582]...
354 > After projection into bounds p = [-5.7735027 5.1208771 -9.9955773 -3.3934582]
355Function Evaluation #6, index=5, x= [-5.7735027 5.1208771 -9.9955773 -3.3934582]
356Inequality constraint #1/3 is not satisfied for x
357Scaling inequality constraint with alpha = 0.5
358Function Evaluation #7, index=5, x= [-2.8867513 2.5604385 -4.9977887 -1.6967291]
359Inequality constraint #1/3 is not satisfied for x
360Scaling inequality constraint with alpha = 0.25
361Function Evaluation #8, index=5, x= [-1.4433757 1.2802193 -2.4988943 -0.8483645]
362Inequality constraint #2/3 is not satisfied for x
363Scaling inequality constraint with alpha = 0.125
364Function Evaluation #9, index=5, x= [-0.7216878 0.6401096 -1.2494472 -0.4241823]
365 > After scaling into inequality constraints p = [-0.7216878 0.6401096 -1.2494472 -0.4241823]
366Scaling vertex #3/8 at [3.3076221 2.5678358 6.9949047 3.7146204]...
367 > After projection into bounds p = [3.3076221 2.5678358 6.9949047 3.7146204]
368Function Evaluation #10, index=5, x= [3.3076221 2.5678358 6.9949047 3.7146204]
369Inequality constraint #1/3 is not satisfied for x
370Scaling inequality constraint with alpha = 0.5
371Function Evaluation #11, index=5, x= [1.653811 1.2839179 3.4974524 1.8573102]
372Inequality constraint #1/3 is not satisfied for x
373Scaling inequality constraint with alpha = 0.25
374Function Evaluation #12, index=5, x= [0.8269055 0.6419589 1.7487262 0.9286551]
375 > After scaling into inequality constraints p = [0.8269055 0.6419589 1.7487262 0.9286551]
376Scaling vertex #4/8 at [7.5643296 -8.6325193 1.2169721 3.2471387]...
377 > After projection into bounds p = [7.5643296 -8.6325193 1.2169721 3.2471387]
378Function Evaluation #13, index=5, x= [7.5643296 -8.6325193 1.2169721 3.2471387]
379Inequality constraint #1/3 is not satisfied for x
380Scaling inequality constraint with alpha = 0.5
381Function Evaluation #14, index=5, x= [3.7821648 -4.3162596 0.6084861 1.6235694]
382Inequality constraint #1/3 is not satisfied for x
383Scaling inequality constraint with alpha = 0.25
384Function Evaluation #15, index=5, x= [1.8910824 -2.1581298 0.304243 0.8117847]
385Inequality constraint #1/3 is not satisfied for x
386Scaling inequality constraint with alpha = 0.125
387Function Evaluation #16, index=5, x= [0.9455412 -1.0790649 0.1521215 0.4058923]
388Inequality constraint #3/3 is not satisfied for x
389Scaling inequality constraint with alpha = 0.0625
390Function Evaluation #17, index=5, x= [0.4727706 -0.5395325 0.0760608 0.2029462]
391 > After scaling into inequality constraints p = [0.4727706 -0.5395325 0.0760608 0.2029462]
392Scaling vertex #5/8 at [4.5270135 -6.0297123 0.8851463 -5.3585042]...
393 > After projection into bounds p = [4.5270135 -6.0297123 0.8851463 -5.3585042]
394Function Evaluation #18, index=5, x= [4.5270135 -6.0297123 0.8851463 -5.3585042]
395Inequality constraint #1/3 is not satisfied for x
396Scaling inequality constraint with alpha = 0.5
397Function Evaluation #19, index=5, x= [2.2635068 -3.0148562 0.4425732 -2.6792521]
398Inequality constraint #1/3 is not satisfied for x
399Scaling inequality constraint with alpha = 0.25
400Function Evaluation #20, index=5, x= [1.1317534 -1.5074281 0.2212866 -1.3396261]
401Inequality constraint #1/3 is not satisfied for x
402Scaling inequality constraint with alpha = 0.125
403Function Evaluation #21, index=5, x= [0.5658767 -0.753714 0.1106433 -0.669813]
404 > After scaling into inequality constraints p = [0.5658767 -0.753714 0.1106433 -0.669813]
405Scaling vertex #6/8 at [-5.3755256 -5.6707347 7.6677756 3.0502699]...
406 > After projection into bounds p = [-5.3755256 -5.6707347 7.6677756 3.0502699]
407Function Evaluation #22, index=5, x= [-5.3755256 -5.6707347 7.6677756 3.0502699]
408Inequality constraint #1/3 is not satisfied for x
409Scaling inequality constraint with alpha = 0.5
410Function Evaluation #23, index=5, x= [-2.6877628 -2.8353674 3.8338878 1.5251349]
411Inequality constraint #1/3 is not satisfied for x
412Scaling inequality constraint with alpha = 0.25
413Function Evaluation #24, index=5, x= [-1.3438814 -1.4176837 1.9169439 0.7625675]
414Inequality constraint #1/3 is not satisfied for x
415Scaling inequality constraint with alpha = 0.125
416Function Evaluation #25, index=5, x= [-0.6719407 -0.7088418 0.958472 0.3812837]
417 > After scaling into inequality constraints p = [-0.6719407 -0.7088418 0.958472 0.3812837]
418Scaling vertex #7/8 at [-3.8478185 8.6592324 -5.7079843 -3.7471601]...
419 > After projection into bounds p = [-3.8478185 8.6592324 -5.7079843 -3.7471601]
420Function Evaluation #26, index=5, x= [-3.8478185 8.6592324 -5.7079843 -3.7471601]
421Inequality constraint #1/3 is not satisfied for x
422Scaling inequality constraint with alpha = 0.5
423Function Evaluation #27, index=5, x= [-1.9239093 4.3296162 -2.8539921 -1.87358]
424Inequality constraint #1/3 is not satisfied for x
425Scaling inequality constraint with alpha = 0.25
426Function Evaluation #28, index=5, x= [-0.9619546 2.1648081 -1.4269961 -0.93679]
427Inequality constraint #2/3 is not satisfied for x
428Scaling inequality constraint with alpha = 0.125
429Function Evaluation #29, index=5, x= [-0.4809773 1.0824041 -0.713498 -0.468395]
430 > After scaling into inequality constraints p = [-0.4809773 1.0824041 -0.713498 -0.468395]
431Scaling vertex #8/8 at [-2.767278 -4.1554667 1.3284976 -0.3470561]...
432 > After projection into bounds p = [-2.767278 -4.1554667 1.3284976 -0.3470561]
433Function Evaluation #30, index=5, x= [-2.767278 -4.1554667 1.3284976 -0.3470561]
434Inequality constraint #1/3 is not satisfied for x
435Scaling inequality constraint with alpha = 0.5
436Function Evaluation #31, index=5, x= [-1.383639 -2.0777334 0.6642488 -0.173528]
437Inequality constraint #1/3 is not satisfied for x
438Scaling inequality constraint with alpha = 0.25
439Function Evaluation #32, index=5, x= [-0.6918195 -1.0388667 0.3321244 -0.086764]
440 > After scaling into inequality constraints p = [-0.6918195 -1.0388667 0.3321244 -0.086764]
441Function Evaluation #33, index=2, x= [0 0 0 0]
442Function Evaluation #34, index=2, x= [-0.7216878 0.6401096 -1.2494472 -0.4241823]
443Function Evaluation #35, index=2, x= [0.8269055 0.6419589 1.7487262 0.9286551]
444Function Evaluation #36, index=2, x= [0.4727706 -0.5395325 0.0760608 0.2029462]
445Function Evaluation #37, index=2, x= [0.5658767 -0.753714 0.1106433 -0.669813]
446Function Evaluation #38, index=2, x= [-0.6719407 -0.7088418 0.958472 0.3812837]
447Function Evaluation #39, index=2, x= [-0.4809773 1.0824041 -0.713498 -0.468395]
448Function Evaluation #40, index=2, x= [-0.6918195 -1.0388667 0.3321244 -0.086764]
449Step #1 : order
450=================================================================
451Iteration #1 (total = 1)
452Function Eval #40
453Xopt : [0.8269055 0.6419589 1.7487262 0.9286551]
454Fopt : -29.492616
455DeltaFv : 57.402362
456Center : [-0.0876091 -0.0845603 0.1578852 -0.0170337]
457Size : 3.6355683
458Optim Simplex Object:
459=====================
460nbve: 8
461n: 4
462x: 8-by-4 matrix
463fv: 8-by-1 matrix
464Reflect
465xbar=[0.0029736 -0.1880846 0.3589327 0.0411304]
466_boxlinesearch
467> xhigh=[-0.7216878 0.6401096 -1.2494472 -0.4241823], fhigh=27.909746
468> xbar=[0.0029736 -0.1880846 0.3589327 0.0411304]
469> xr = [0.9450335 -1.264737 2.4498264 0.6460369]
470Function Evaluation #41, index=5, x= [0.9450335 -1.264737 2.4498264 0.6460369]
471Inequality constraint #1/3 is not satisfied for x
472Function Evaluation #42, index=5, x= [0.4740036 -0.7264108 1.4043795 0.3435837]
473Function Evaluation #43, index=2, x= [0.4740036 -0.7264108 1.4043795 0.3435837]
474xr=[0.4740036 -0.7264108 1.4043795 0.3435837], f(xr)=-21.009883
475  > Perform Reflection
476Sort
477=================================================================
478Iteration #2 (total = 2)
479Function Eval #43
480Xopt : [0.8269055 0.6419589 1.7487262 0.9286551]
481Fopt : -29.492616
482DeltaFv : 40.830666
483Center : [0.0618524 -0.2553754 0.4896135 0.0789371]
484Size : 3.14942
485Optim Simplex Object:
486=====================
487nbve: 8
488n: 4
489x: 8-by-4 matrix
490fv: 8-by-1 matrix
491  > Termination ?
492  > iterations=2 >= maxiter=5
493  > funevals=43 >= maxfunevals=1000
494  > e(x)=0.413244 < 1.490D-08 * 0.5612439 + 0
495  > Terminate = F, status = continue
496  > simplex size=3.14942 < 0 + 0.001 * 2.239716
497  > Terminate = F, status = continue
498Reflect
499xbar=[0.1393995 -0.4464867 0.6614866 0.1571274]
500_boxlinesearch
501> xhigh=[-0.4809773 1.0824041 -0.713498 -0.468395], fhigh=11.33805
502> xbar=[0.1393995 -0.4464867 0.6614866 0.1571274]
503> xr = [0.9458893 -2.4340447 2.4489666 0.9703065]
504Function Evaluation #44, index=5, x= [0.9458893 -2.4340447 2.4489666 0.9703065]
505Inequality constraint #1/3 is not satisfied for x
506Function Evaluation #45, index=5, x= [0.5426444 -1.4402657 1.5552266 0.5637169]
507Inequality constraint #1/3 is not satisfied for x
508Function Evaluation #46, index=5, x= [0.3410219 -0.9433762 1.1083566 0.3604222]
509Function Evaluation #47, index=2, x= [0.3410219 -0.9433762 1.1083566 0.3604222]
510xr=[0.3410219 -0.9433762 1.1083566 0.3604222], f(xr)=-14.147695
511  > Perform Reflection
512Sort
513=================================================================
514Iteration #3 (total = 3)
515Function Eval #47
516Xopt : [0.8269055 0.6419589 1.7487262 0.9286551]
517Fopt : -29.492616
518DeltaFv : 32.350085
519Center : [0.1646023 -0.5085979 0.7173453 0.1825392]
520Size : 2.8582402
521Optim Simplex Object:
522=====================
523nbve: 8
524n: 4
525x: 8-by-4 matrix
526fv: 8-by-1 matrix
527  > Termination ?
528  > iterations=3 >= maxiter=5
529  > funevals=47 >= maxfunevals=1000
530  > e(x)=0.3705056 < 1.490D-08 * 0.9130556 + 0
531  > Terminate = F, status = continue
532  > simplex size=2.8582402 < 0 + 0.001 * 2.239716
533  > Terminate = F, status = continue
534Reflect
535xbar=[0.2869482 -0.4328452 0.7723769 0.2210111]
536_boxlinesearch
537> xhigh=[-0.6918195 -1.0388667 0.3321244 -0.086764], fhigh=2.8574697
538> xbar=[0.2869482 -0.4328452 0.7723769 0.2210111]
539> xr = [1.5593463 0.3549827 1.3447051 0.6211188]
540Function Evaluation #48, index=5, x= [1.5593463 0.3549827 1.3447051 0.6211188]
541Inequality constraint #3/3 is not satisfied for x
542Function Evaluation #49, index=5, x= [0.9231472 -0.0389312 1.058541 0.4210649]
543Function Evaluation #50, index=2, x= [0.9231472 -0.0389312 1.058541 0.4210649]
544xr=[0.9231472 -0.0389312 1.058541 0.4210649], f(xr)=-20.430956
545  > Perform Reflection
546Sort
547=================================================================
548Iteration #4 (total = 4)
549Function Eval #50
550Xopt : [0.8269055 0.6419589 1.7487262 0.9286551]
551Fopt : -29.492616
552DeltaFv : 30.217137
553Center : [0.3664731 -0.383606 0.8081474 0.2460178]
554Size : 2.6934096
555Optim Simplex Object:
556=====================
557nbve: 8
558n: 4
559x: 8-by-4 matrix
560fv: 8-by-1 matrix
561  > Termination ?
562  > iterations=4 >= maxiter=5
563  > funevals=50 >= maxfunevals=1000
564  > e(x)=0.2620103 < 1.490D-08 * 0.9975385 + 0
565  > Terminate = F, status = continue
566  > simplex size=2.6934096 < 0 + 0.001 * 2.239716
567  > Terminate = F, status = continue
568Reflect
569xbar=[0.3512877 -0.3613307 0.9127312 0.2521709]
570_boxlinesearch
571> xhigh=[0.4727706 -0.5395325 0.0760608 0.2029462], fhigh=0.7245215
572> xbar=[0.3512877 -0.3613307 0.9127312 0.2521709]
573> xr = [0.19336 -0.1296685 2.0004028 0.3161631]
574Function Evaluation #51, index=5, x= [0.19336 -0.1296685 2.0004028 0.3161631]
575Function Evaluation #52, index=2, x= [0.19336 -0.1296685 2.0004028 0.3161631]
576xr=[0.19336 -0.1296685 2.0004028 0.3161631], f(xr)=-31.956391
577  > Perform Reflection
578Sort
579=================================================================
580Iteration #5 (total = 5)
581Function Eval #52
582Xopt : [0.19336 -0.1296685 2.0004028 0.3161631]
583Fopt : -31.956391
584DeltaFv : 31.956391
585Center : [0.3315468 -0.332373 1.0486902 0.26017]
586Size : 2.2520083
587Optim Simplex Object:
588=====================
589nbve: 8
590n: 4
591x: 8-by-4 matrix
592fv: 8-by-1 matrix
593  > Termination ?
594  > iterations=5 >= maxiter=5
595  > Terminate = T, status = maxiter
596  > Terminate = T, status = maxiter
597Terminate with status : maxiter
598nm = neldermead_destroy(nm);
599