Skip to content
This repository has been archived by the owner on Nov 19, 2020. It is now read-only.

Nelder-mead solver not converged #335

Closed
maiqing86 opened this issue Oct 24, 2016 · 7 comments
Closed

Nelder-mead solver not converged #335

maiqing86 opened this issue Oct 24, 2016 · 7 comments

Comments

@maiqing86
Copy link

Hi, I tried to use the Nelder-mead solver for a customized optimization. I found with some initial inputs, the solver provided by accord.net can not converged. Actually the solver stops immediately after the 2nd iteration. However, if I feed the same initial input to the Nelder-mead solver provided by Microsoft Solver Foundation 3.1, the optimization can be carried on and get converged without any problem. Does anyone know how to enable the Nelder-mead solver in accord.net work in this case?

@cesarsouza
Copy link
Member

Hi there,

I know it might be a bit late, but do you still have an example of the code that doesn't converge, so I could work on the issue?

Regards,
Cesar

@arubiomoreno
Copy link

arubiomoreno commented Jul 12, 2017

Please, check again this issue, as I am facing this problem as well.
TL;DR: The problem is that the variables are not being modified between iterations.
I provide a working example that replicates the problem:

If you combine 2 parabolas, x^2-2*x and y^2+4*y to create some kind of valley, you get something like this:

plot
for which the minimum is x=1, y=-2 (the minimum of each parabola).

Now, I start my NelderMead on x=0.5, y=0 (you may encounter the issue with other initial value as well).

class Program
{
	public static Double eval(Double[] val)
	{
		// WxMaxima command: plot3d(y^2+4*y+x^2-2*x,[x,-3,5], [y,-5,3],[grid,8,8]);
		Double x = val[0];
		Double y = val[1];
		Double ret = y * y + 4 * y + x * x - 2 * x;

		Debug.WriteLine("{2}; x={0}; y={1}", x, y, ret);

		return ret;
	}

	static void Main(string[] args)
	{
		// This values are relevant for my RealWorld(TM) scenario
		Double[] init = new double[] { 0.5, 0 };

		NelderMead nm = new NelderMead(2, eval);
		nm.Minimize(init);

		// Solution
		Debug.WriteLine("Minimum:");
		Debug.WriteLine("{2}; x={0}; y={1}", nm.Solution[0], nm.Solution[1], nm.Value);
	}
}

And i get this output:

-0.75; x=0.5; y=0
-0.75; x=0.5; y=0
Minimum:
-0.75; x=0.5; y=0

Perhaps I am doing something wrong?

@arubiomoreno
Copy link

arubiomoreno commented Jul 12, 2017

Tried another example. I don't really understand what the algorithm is trying to accomplish.
image
image

public static Double eval2(Double[] val)
{
	// plot3d(y^2+4*y+x^2-2*x+(2*x^2-18*x)/(6*x^2-50*x+109)*(-y^2+5*y)/(2*y^2-8*y+9) ,[x,-4,6], [y,-6,4],[grid,80,80]);
	Double x = val[0];
	Double y = val[1];
	Double ret = y * y + 4 * y + x * x - 2 * x + (2 * x * x - 18 * x) / (6 * x * x - 50 * x + 109) * (-y * y + 5 * y) / (2 * y * y - 8 * y + 9);

	Debug.WriteLine("{2}; x={0}; y={1}", x, y, ret);

	return ret;
}

static void Main(string[] args)
{
	// Used this because (0,0) does nothing.
	Double[] init = new double[] { 1, 1 };

	NelderMead nm = new NelderMead(2, eval2);
	nm.Minimize(init);

	// Solution
	Debug.WriteLine("Minimum:");
	Debug.WriteLine("{2}; x={0}; y={1}", nm.Solution[0], nm.Solution[1], nm.Value);
}

Output

3.67179487179487; x=1; y=1
3.67179008134145; x=1.00001; y=1
3.67184324367373; x=1.00001; y=1.00001
3.67174170944063; x=1; y=0.99999
3.67169094235047; x=0.999995; y=0.99998
3.67168615201753; x=1.000005; y=0.99998
3.6716317923353; x=1.0000075; y=0.99997
3.67153265337171; x=0.9999925; y=0.99995
3.67140393964348; x=0.99998375; y=0.999925
3.67134479040772; x=0.999996249999999; y=0.999914999999999
3.67117171573155; x=0.999996874999999; y=0.999882499999999
3.67094386395396; x=0.999973124999999; y=0.999837499999999
3.67059990218279; x=0.999955937499999; y=0.999771249999999
3.67036768361586; x=0.999969062499999; y=0.999728749999999
3.66984956482315; x=0.999961718749998; y=0.999630624999998
3.66927776119648; x=0.999920781249998; y=0.999519374999997
3.66833080523777; x=0.999882734374997; y=0.999337812499997
3.66758050696088; x=0.999888515624996; y=0.999197187499996
3.6660708795153; x=0.999854804687495; y=0.998910156249994
3.6645522100594; x=0.999775820312494; y=0.998617343749993
3.66190371335516; x=0.999682871093741; y=0.998110703124991
3.65964408766509; x=0.999654941406239; y=0.997683046874988
3.65530128296835; x=0.99954104492186; y=0.996855664062484
3.65113489076077; x=0.999369111328107; y=0.99605621093748
3.64366840910935; x=0.999126264648413; y=0.994629238281223
3.63706836968455; x=0.998984438476532; y=0.993374199218717
3.62465520662672; x=0.998635222167927; y=0.991005947265581
3.61302891976654; x=0.99822044189448; y=0.98877952148432
3.59190556782282; x=0.99756014038079; y=0.984741450195237
3.57291225784504; x=0.997069097900304; y=0.981118159179594
3.53757258680028; x=0.996040514526249; y=0.97436261962878
3.50488091590689; x=0.994965432739112; y=0.968098122558436
3.44510864536337; x=0.993130538024704; y=0.956644210204864
3.3909546041429; x=0.991610912170164; y=0.946265379638407
3.2908382008963; x=0.988636298064851; y=0.927027344359992
3.19893622930509; x=0.985726321563306; y=0.909308934936076
3.03077960367804; x=0.980569225081835; y=0.876782092589724
2.87836545100248; x=0.976074985121981; y=0.847165226744852
2.5989254583119; x=0.96754720867062; y=0.792425735014846
2.34525438107114; x=0.959480135687604; y=0.742180483244578
1.88625937527326; x=0.94490205449898; y=0.649757052686871
1.4769332951304; x=0.931880038087765; y=0.565400695111993
0.748746631919739; x=0.90753544459073; y=0.409709996373127
0.115423752144577; x=0.884890290419091; y=0.267041314045153
-0.958580864052685; x=0.843561831293326; y=0.00434910356030627
-0.958580864052685; x=0.843561831293326; y=0.00434910356030627
Minimum:
-0.958580864052685; x=0.843561831293326; y=0.00434910356030627

By the way, if you start in (0,0) it does not even move. It does 2 Iterations on (0,0) and then finishes.
Edit: Probably when one or more input variables reach 0 it stops giving new values?

@arubiomoreno
Copy link

arubiomoreno commented Jul 13, 2017

In case it helps, I post here the results for the SolverFoundation implementation, starting at (0,0).

First function:

-0.0217893868042013; x=0.0241481456572267; y=0.00647047612756302
0.0842766303737808; x=0.00647047612756302; y=0.0241481456572267
0; x=0; y=0
-0.0110509434021007; x=0.0120740728286134; y=0.00323523806378151
-0.105441017177982; x=0.0176776695296637; y=-0.0176776695296637
-0.198893590953864; x=0.023281266230714; y=-0.0385905771231089
-0.110849301379032; x=0.0237147059439704; y=-0.0160600504977729
-0.220057977758065; x=0.0474294118879407; y=-0.0321201009955459
-0.327626029137097; x=0.0711441178319111; y=-0.0481801514933188
-0.26385551317048; x=0.0472126920313126; y=-0.0433853643082138
-0.49988648328676; x=0.0702772384053984; y=-0.0932412047439907
-0.729882297153039; x=0.0933417847794842; y=-0.143097045179768
-0.531129651426318; x=0.0822429513056977; y=-0.0956385983365432
-0.849903797836273; x=0.141204636380681; y=-0.152686619549977
-1.15521603018373; x=0.200166321455665; y=-0.209734640763412
-0.946512176363695; x=0.146754053117575; y=-0.17641584297159
-1.52107581382467; x=0.222363988403238; y=-0.304651534449861
-2.05131694152002; x=0.297973923688902; y=-0.432887225928131
-1.61810733668195; x=0.249070122572283; y=-0.321310933345772
-2.39430936595695; x=0.404798460365082; y=-0.499524821511776
-3.05848838497805; x=0.560526798157881; y=-0.67773870967778
-2.58712422849562; x=0.429250360923392; y=-0.555312967802956
-3.67522467229091; x=0.658334400391118; y=-0.900891294842499
-4.41951736156959; x=0.887418439858845; y=-1.24646962188204
-3.84658112225148; x=0.723972619008363; y=-0.962104165779911
-4.71875438730302; x=1.14997131432782; y=-1.49132110563169
-4.66783673667462; x=1.57597000964729; y=-2.02053804548347
-4.60135743968289; x=1.01869487709333; y=-1.36889536375687
-4.76899547632132; x=1.47686295602879; y=-2.06005201783596
-3.56140249489334; x=1.93503103496424; y=-2.75120867191504
-4.85145318078983; x=1.31341713517831; y=-1.77568656173382
-4.36029808433013; x=1.73941583049777; y=-2.3049035015856
-4.7508716356397; x=1.10041778751858; y=-1.51107809180793
-4.87070439006884; x=1.28864037177368; y=-1.78556505482194
-4.81103717457865; x=1.42730942921954; y=-2.0798090040122
-4.53975274083247; x=1.5659784866654; y=-2.37405295320245
-4.79072779808049; x=1.45208619262416; y=-2.06993051092408
-3.95861057351832; x=1.80375459772975; y=-2.62878293004022
-4.87979639023546; x=1.27625199007137; y=-1.790504301366
-4.87204567263086; x=1.35178070964545; y=-1.9351566526891
-4.91260702774947; x=1.22669846326212; y=-1.81026128754225
-4.89067954167714; x=1.10161621687879; y=-1.68536592239539
-4.89691318162297; x=1.25147522666675; y=-1.80038279445413
-4.76479584191654; x=1.07564102411395; y=-1.52095658489605
-4.88122434644465; x=1.33939232794314; y=-1.94009589923316
-4.90430492047948; x=1.28304539560263; y=-1.8751785933877
-4.91438167854732; x=1.28983880113389; y=-1.9598528854094
-4.91002666443898; x=1.29663220666515; y=-2.0445271774311
-4.92008544025314; x=1.25826863219801; y=-1.88505708647582
-4.93972588421946; x=1.17714493645287; y=-1.83001827371849
-4.94014567834361; x=1.09602124070774; y=-1.77497946096115
-4.94519953589466; x=1.19293002092081; y=-1.86741617318528
-4.9689780667378; x=1.15916157857951; y=-1.92457105882831
-4.98394262027888; x=1.1253931362382; y=-1.98172594447134
-4.97294585348397; x=1.11070718847297; y=-1.87835270271625
-4.95404919955358; x=0.931575575812045; y=-1.79685252002309
-4.98693176736542; x=1.02848435602512; y=-1.88928923224721
-4.99846194717902; x=0.960947471342512; y=-2.00359900353327
-4.97473621778442; x=0.8934105866599; y=-2.11790877481934
-4.99808248558288; x=1.04317030379036; y=-1.99266247400231
-4.94052592883239; x=1.15476503176867; y=-2.18847242798153
-4.9887645729157; x=0.987372939801201; y=-1.8947574970127
-4.9967494547786; x=0.974160205571856; y=-1.94917825027299
-4.96169478584719; x=0.822927274905511; y=-1.91663055607463
-4.99632872545763; x=1.04977667090503; y=-1.96545209737216
-4.99973178960447; x=1.00536207112377; y=-1.98452555045272
-4.99393518176494; x=1.02335120244634; y=-2.07429360389274
-4.99892896375074; x=1.01435663678506; y=-2.02940957717273
-4.9995751366311; x=0.987652054063783; y=-2.016504290353
-4.98988995895292; x=0.925527437222538; y=-2.06755648333384
-4.99956837965082; x=1.01871436248441; y=-1.99097819386258
-4.99962266194988; x=1.01653549963473; y=-2.01019388551766
-4.99451633400513; x=1.07212352792695; y=-2.01678876750204
-4.9998256849039; x=0.988741485488621; y=-2.00689644452547
-4.99998497329226; x=1.00372792398651; y=-1.99893731919402
-4.99895792674962; x=0.993099211187972; y=-1.96846506121532
-4.99973183203146; x=0.998413567587243; y=-1.98370119020467
-4.99993665071646; x=0.993577526537932; y=-1.99529881736507
-4.9990038651644; x=0.968440690591458; y=-1.99961944086755
-4.99991514726085; x=1.00614594451117; y=-1.99313850561383
-4.99999346510162; x=0.997443714999895; y=-2.00001747506965
-4.99972077464011; x=0.996473862412547; y=-2.01633375993462
-4.999929439008; x=0.997928641293569; y=-1.99185933263716
-4.99993958322334; x=1.00203729290237; y=-1.99249891912549
-4.99928534707793; x=1.01533310031612; y=-1.97810139372552
-4.99997865087173; x=0.995389389195495; y=-1.99969768182548
-4.99997101681967; x=0.996659015244532; y=-1.99577850723132
-4.99983294350758; x=0.987172085977895; y=-1.99841850884881
-4.99996732489912; x=1.00140247987785; y=-1.99445850642257
-4.99998888944004; x=0.998395934536673; y=-1.99707809412403
-4.99999343220322; x=0.998863227779777; y=-2.00229685561089
-4.99994306729754; x=0.999330521022881; y=-2.00751561709776
-4.9999907473522; x=0.997126308487636; y=-2.00099726871819
-4.99989208769703; x=0.992850137097421; y=-2.0075360310138
-4.99999429638919; x=0.999264394182743; y=-1.99772788757038
-4.99999912339706; x=0.99906381098126; y=-2.00001237159064
-4.99999239511218; x=1.00273823276703; y=-2.00032706135579
-4.9999991593559; x=1.00090102187414; y=-2.00016971647321
-4.99999888814219; x=1.00008270802844; y=-1.9989488020218
-4.99997895089134; x=1.00130218827711; y=-1.9956007484327
-4.99999933432144; x=0.99947296790411; y=-2.00062282881634
-4.9999998080009; x=1.00018699488913; y=-2.00039627264478
-4.99998937667068; x=1.00110959559551; y=-2.00306465771918
-4.99999904506279; x=0.999725694535935; y=-1.99906208010758
-4.9999998080009; x=1.00018699488913; y=-2.00039627264478
-4.99999658520353; x=1.00064829524232; y=-2.00173046518198
-4.99999992474878; x=0.999956344712531; y=-1.99972917637618
-4.99999988760206; x=0.99971465630832; y=-2.00017600259626
-4.99999780084268; x=0.998528290742498; y=-2.00018228871931
-4.99999987535467; x=1.00030783909123; y=-2.00017285953474
-4.99999998015249; x=1.00013209190188; y=-1.99995101795546
-4.99999885443499; x=1.00079121589965; y=-1.99927920709457
-4.99999987868053; x=0.999802529902996; y=-2.0002869233859
-4.99999998539984; x=0.999879437307763; y=-2.00000804988104
-4.99999967406438; x=0.999451035524295; y=-1.99984324022734
-4.99999998304983; x=1.0000936381995; y=-2.00009045470789
-4.99999999124219; x=1.00002499145601; y=-1.99990981554203
-4.99999972040491; x=1.00024745300903; y=-1.99953270769817
-4.99999998288623; x=0.999913760679505; y=-2.00009836946397
-4.99999999107267; x=1.0000036994395; y=-2.00009441208593
-4.99999978611738; x=1.00005105416647; y=-2.00045964779568
-4.99999999182062; x=0.999980022076016; y=-1.99991179423105
-4.99999999864228; x=1.00003683013776; y=-2.00000112446947
-4.99999996519296; x=1.00015989959601; y=-1.99990387947498
-4.99999999691492; x=0.999975295408631; y=-2.00004974696672
-4.9999999991311; x=0.999977658742323; y=-1.99998077059889
-4.99999996424869; x=0.999861679285149; y=-1.99987108648988
-4.99999999746093; x=1.00003564847091; y=-2.00003561265339
-4.99999999814849; x=1.00000547193977; y=-2.00004267981005
-4.9999999689189; x=1.00003092180353; y=-2.00017356538905
-4.99999999942924; x=0.999992747007893; y=-1.99997723702055
-4.99999999975715; x=1.0000141977394; y=-2.00000642483697
-4.99999999581897; x=1.00005310007017; y=-1.99996310270722
-4.99999999918358; x=0.999994746574016; y=-2.00002808590185
-4.99999999995381; x=0.999993746790955; y=-2.0000026614612
-4.99999999676364; x=0.999951845110999; y=-1.99996971026901
-4.99999999941775; x=1.00001469763093; y=-2.00001913705729
-4.99999999998286; x=1.00000372231941; y=-1.99999818703892
-4.99999999883312; x=1.00001269806481; y=-1.999968288176
-4.99999999982685; x=0.999999234446714; y=-2.00001313647039
-4.99999999996076; x=0.999995990727304; y=-1.99999518674547
-4.99999999865663; x=0.999977283823675; y=-1.99997123643365
-4.99999999992015; x=1.00000534417912; y=-2.00000716190138
-4.99999999989175; x=1.00000228931292; y=-2.00001014918588
-4.99999999800573; x=1.00001183161794; y=-2.00004306135121
-4.99999999995406; x=0.999997518160405; y=-1.99999369310322
-4.99999999999777; x=1.00000143116976; y=-2.0000004275023
-4.999999999836; x=1.00000362789281; y=-1.99998771853422
-4.99999999995847; x=1.00000252953128; y=-1.99999407301826
-4.99999999996258; x=1.00000002384584; y=-1.99999388306074
-4.99999999959575; x=0.999994703512572; y=-1.9999806042201
-4.99999999999252; x=1.00000268401248; y=-2.00000052248106
-4.9999999999859; x=1.00000260677188; y=-1.99999729774966
-4.99999999993997; x=1.00000769538336; y=-2.0000009023961
-4.99999999997971; x=1.00000006246614; y=-1.99999549542644
-4.99999999999415; x=1.00000137323931; y=-1.99999800895375
-4.99999999999617; x=1.00000021694734; y=-2.00000194488924
-4.99999999996453; x=0.999999060655369; y=-2.00000588082473
-4.99999999999637; x=1.00000145047991; y=-2.00000123368515
-4.99999999994333; x=1.00000283849368; y=-2.00000697194386
-4.99999999999675; x=1.00000075647303; y=-1.99999836455579
-4.99999999999974; x=1.00000048671018; y=-2.00000015472252
-4.99999999999703; x=0.999998289407887; y=-1.99999978696398
-4.99999999998439; x=0.99999609210559; y=-1.99999941920543
-4.99999999999892; x=0.999999522940457; y=-1.99999907575989
Minimum:
-4.99999999999703; x=0.999998289407887; y=-1.99999978696398

Second function, does not find the minimum but the local:

-0.0218039075459764; x=0.0241481456572267; y=0.00647047612756302
0.0842620208956724; x=0.00647047612756302; y=0.0241481456572267
0; x=0; y=0
-0.011054550248746; x=0.0120740728286134; y=0.00323523806378151
-0.105412518151573; x=0.0176776695296637; y=-0.0176776695296637
-0.198812655497001; x=0.023281266230714; y=-0.0385905771231089
-0.110814456322448; x=0.0237147059439704; y=-0.0160600504977729
-0.21991896336133; x=0.0474294118879407; y=-0.0321201009955459
-0.327314027859557; x=0.0711441178319111; y=-0.0481801514933188
-0.263670036436645; x=0.0472126920313126; y=-0.0433853643082138
-0.499307894532133; x=0.0702772384053984; y=-0.0932412047439907
-0.728731376879458; x=0.0933417847794842; y=-0.143097045179768
-0.53043329268762; x=0.0822429513056977; y=-0.0956385983365432
-0.848025586706; x=0.141204636380681; y=-0.152686619549977
-1.15161289441118; x=0.200166321455665; y=-0.209734640763412
-0.944286392625532; x=0.146754053117575; y=-0.17641584297159
-1.51554735849885; x=0.222363988403238; y=-0.304651534449861
-2.04127787316411; x=0.297973923688902; y=-0.432887225928131
-1.61157740220791; x=0.249070122572283; y=-0.321310933345772
-2.37852509678943; x=0.404798460365082; y=-0.499524821511776
-3.02984665239168; x=0.560526798157881; y=-0.67773870967778
-2.56891048670065; x=0.429250360923392; y=-0.555312967802956
-3.63360727810652; x=0.658334400391118; y=-0.900891294842499
-4.34630583538812; x=0.887418439858845; y=-1.24646962188204
-3.79778449703923; x=0.723972619008363; y=-0.962104165779911
-4.60288353573462; x=1.14997131432782; y=-1.49132110563169
-4.4470282206161; x=1.57597000964729; y=-2.02053804548347
-4.50831113330141; x=1.01869487709333; y=-1.36889536375687
-4.57177817104846; x=1.47686295602879; y=-2.06005201783596
-4.69810314858786; x=1.31341713517831; y=-1.77568656173382
-4.08225302732976; x=1.73941583049777; y=-2.3049035015856
-4.64200725887078; x=1.10041778751858; y=-1.51107809180793
-4.62318768674854; x=1.1251945509232; y=-1.50119959871981
-3.77743476511878; x=0.773526145817612; y=-0.94234717960367
-4.71015556689572; x=1.30102875347599; y=-1.78062580827788
-4.70538305673186; x=1.20072327049728; y=-1.64585195004291
-4.7545858837405; x=1.25147522666674; y=-1.80038279445413
-4.75044500165106; x=1.3022271828362; y=-1.95491363886534
-4.73312601236264; x=1.27625199007137; y=-1.790504301366
-4.59908685700412; x=1.45208619262416; y=-2.06993051092408
-4.71563337125611; x=1.18833488879497; y=-1.65079119658697
-4.74179992698773; x=1.21990505773086; y=-1.72558699552055
-4.75289632666026; x=1.13878136198572; y=-1.67054818276321
-4.76146313297758; x=1.19512829432623; y=-1.73546548860867
-4.79298292345231; x=1.2019216998575; y=-1.82013978063037
-4.81018193004851; x=1.20871510538876; y=-1.90481407265207
-4.7855386414347; x=1.23009516602775; y=-1.8525984335531
-4.73342373667859; x=1.32140897006978; y=-2.03464868434298
-4.77980167872157; x=1.18443826400674; y=-1.76157330815815
-4.80025424238389; x=1.19657668469775; y=-1.83319369040511
-4.83739678057109; x=1.14167814272875; y=-1.8660045863561
-4.86602955640132; x=1.08677960075975; y=-1.89881548230708
-4.84212466149148; x=1.14774735307426; y=-1.90181477747957
-4.86288844951142; x=1.11105644214177; y=-2.04205624680099
-4.86972832761115; x=1.09891802145076; y=-1.97043586455404
-4.89522612267991; x=0.989120937512768; y=-2.03605765645601
-4.88679847185544; x=0.879323853574773; y=-2.10167944835798
-4.88776422233721; x=1.03795026913626; y=-1.96743656938154
-4.88988155580273; x=0.964844096130748; y=-1.89281689196209
-4.89782595087941; x=0.976982516821758; y=-1.96443727420905
-4.89575604099394; x=0.867185432883763; y=-2.03005906611102
-4.8599210718915; x=0.757388348945768; y=-2.09568085801299
-4.89945036612546; x=0.928153185198266; y=-2.03305836128351
-4.86728813279897; x=0.891462274265784; y=-2.17329983060493
-4.89987740833254; x=0.946498640664507; y=-1.9629376266228
-4.90057343995693; x=0.906842036774135; y=-1.99649834636691
-4.8883133860202; x=0.824563136035502; y=-1.95693903627782
-4.90010589499781; x=0.947981487143452; y=-2.01627800141146
-4.90069942629626; x=0.947240063903979; y=-1.98960781401713
-4.88892220428675; x=1.0272946949242; y=-1.94915656192324
-4.90031491040878; x=0.907212748393871; y=-2.00983344006408
-4.90066323720102; x=0.927597117768661; y=-2.01305572073777
-4.89574000058055; x=0.908695594872816; y=-2.06317381485273
-4.90098368296616; x=0.937047879216584; y=-1.98799667368028
-4.90100019631339; x=0.922130313805227; y=-1.99891505687218
-4.89985702046221; x=0.896279140467003; y=-1.9815521123329
-4.90080789413535; x=0.93505590047434; y=-2.00759652914182
-4.90099205638805; x=0.936051889845462; y=-1.99779660141105
-4.89963082585088; x=0.964891031297052; y=-1.98575976275803
-4.90090812982159; x=0.921632319119666; y=-2.00381502073756
-4.90106974287877; x=0.929340099168125; y=-1.99590584720892
-4.90098755537192; x=0.923624297861911; y=-1.98421516527603
-4.90056135477726; x=0.917908496555697; y=-1.97252448334313
-4.90103727429122; x=0.930336088539247; y=-1.98610591947816
-4.90038940136287; x=0.939039857958828; y=-1.96839681821875
-4.90106984280522; x=0.925984203829457; y=-1.99496047010786
-4.90105900691111; x=0.924804250845684; y=-1.98958781769194
-4.90081208302693; x=0.912560622474784; y=-1.9911789617036
-4.90106164034642; x=0.930926065031134; y=-1.98879224568611
-4.90108149998368; x=0.928455134430295; y=-1.99187635789699
-4.90100756664674; x=0.93328597099868; y=-1.99953755051795
-4.9010655190104; x=0.930870552714488; y=-1.99570695420747
-4.90107417510618; x=0.928427378271972; y=-1.99533371215766
-4.90098914987717; x=0.925928691512811; y=-2.00187517862921
-4.90108010210559; x=0.929676721651553; y=-1.99206297892189
-4.90108061486776; x=0.927830462740505; y=-1.99351172451487
-4.90106621245926; x=0.924790372766522; y=-1.99131649482228
-4.90107710067991; x=0.926310417753514; y=-1.99241410966858
-4.90108163179725; x=0.927993569702533; y=-1.99223854429523
-4.90107037470368; x=0.93000293557561; y=-1.98951661848261
-4.90107888397024; x=0.928998252639072; y=-1.99087758138892
-4.90107996886464; x=0.929337487145312; y=-1.9914702801554
-4.90106174673274; x=0.932364556537111; y=-1.99052645064223
-4.90108117086996; x=0.927823952449413; y=-1.99194219491199
-4.9010815521767; x=0.928750337050483; y=-1.99200258691694
-4.90108158713115; x=0.928502421461894; y=-1.99312759244496
-4.90107898879566; x=0.928254505873306; y=-1.99425259797298
-4.90108185481697; x=0.928163186955654; y=-1.99253489367848
-4.90107833519492; x=0.926649652259754; y=-1.99300680843506
-4.90108163752693; x=0.928919954303603; y=-1.99229893630018
-4.90108182721269; x=0.928711187882749; y=-1.99271326437257
-4.90107959980728; x=0.929598423316085; y=-1.99348433383315
-4.90108185950325; x=0.928267570166081; y=-1.99232772964228
-4.90108186153611; x=0.928593762234842; y=-1.99231333297123
-4.90108080383884; x=0.92868510300779; y=-1.9914990734975
-4.90108189084707; x=0.928548091848368; y=-1.9927204627081
-4.90108193500112; x=0.928407831007225; y=-1.99252409617519
-4.90108158028455; x=0.927895707710846; y=-1.9927492560502
-4.90108186778868; x=0.928663892655414; y=-1.99241151623769
-4.9010819063855; x=0.928605992251891; y=-1.99256598947289
-4.90108159366674; x=0.928944414337701; y=-1.9928042493035
-4.90108192789413; x=0.928436781208986; y=-1.99244685955759
-4.90108193142963; x=0.928492436528677; y=-1.99258366113284
-4.90108187511906; x=0.92832098040194; y=-1.992755806028
-4.90108191826828; x=0.928406708465309; y=-1.99266973358042
-4.90108193562393; x=0.928421744837147; y=-1.992558296569
-4.90108189331525; x=0.928295397825927; y=-1.99239613042991
-4.90108192535527; x=0.928358571331537; y=-1.99247721349946
-4.90108192846298; x=0.928397676270261; y=-1.99246203652852
-4.90108185265968; x=0.928388644075214; y=-1.99225433947662
-4.90108193411539; x=0.928402192367785; y=-1.99256588505447
-4.90108193481847; x=0.928419486788386; y=-1.99250637230603
-4.90108193463471; x=0.928480402245234; y=-1.9925355311126
-4.90108192480396; x=0.928541317702083; y=-1.99256468991917
-4.90108193621334; x=0.92844129730651; y=-1.99255070808353
-4.90108192303304; x=0.928445813404033; y=-1.99265455660948
-4.90108193474117; x=0.928439039257748; y=-1.99249878382056
-4.90108193548602; x=0.928459720751491; y=-1.99251715746658
-4.90108192524055; x=0.928517249135197; y=-1.99246842987869
-4.90108193625272; x=0.928430956559638; y=-1.99254152126053
-4.90108193596609; x=0.928434997908693; y=-1.99252015254054
-4.90108193241984; x=0.928389593572152; y=-1.99250477396849
-4.90108193591011; x=0.928457700076964; y=-1.99252784182657
-4.90108193631558; x=0.928444328318301; y=-1.99253468154355
-4.9010819352607; x=0.928449617378854; y=-1.99257057926654
-4.9010819361168; x=0.928446972848577; y=-1.99255263040504
-4.9010819362845; x=0.928438964704108; y=-1.99254707583278
-4.90108193519497; x=0.928420229331252; y=-1.992566309839
-4.90108193628029; x=0.928448332390536; y=-1.99253745882968
-4.90108193635031; x=0.928439644475087; y=-1.9925394900451
-4.90108193612225; x=0.928432316101596; y=-1.99252634968516
-4.90108193629397; x=0.928435980288342; y=-1.99253291986513
-4.90108193633305; x=0.928442156339439; y=-1.9925351893474
-4.90108193607068; x=0.928453356119239; y=-1.99252885743428
-4.90108193633572; x=0.928436556449538; y=-1.99253835530396
-4.90108193632229; x=0.92843626836894; y=-1.99253563758455
-4.90108193604778; x=0.928424204347344; y=-1.99253381633942
-4.90108193634086; x=0.928442300379738; y=-1.99253654820711
-4.9010819363478; x=0.928439428414638; y=-1.99253745175554
-4.90108193633485; x=0.928442876540934; y=-1.99254198364595
-4.90108193634967; x=0.928441152477786; y=-1.99253971770074
-4.90108193634809; x=0.928441726428762; y=-1.99253813295393
-4.90108193630367; x=0.928446896407985; y=-1.99253791060389
-4.901081936349; x=0.92843914143915; y=-1.99253824412895
-4.90108193635097; x=0.928440146958468; y=-1.99253898091484
-4.90108193633971; x=0.928437993537199; y=-1.99254141362258
-4.90108193634858; x=0.928441223669103; y=-1.99253776456098
-4.90108193635097; x=0.928440146958468; y=-1.99253898091484
-4.90108193634801; x=0.928439070247833; y=-1.99254019726871
-4.90108193635044; x=0.928440685313786; y=-1.99253837273791
-4.90108193635057; x=0.928440918895786; y=-1.99253904521933
Minimum:
-4.90108193635044; x=0.928440685313786; y=-1.99253837273791

@cesarsouza
Copy link
Member

Hi @arubiomoreno,

Thanks a lot for the informative examples. After some initial investigation, I could find at least one issue with the current code, in which the initial values of certain class variables are not being properly set and are causing the algorithm to terminate early after very few iterations.

This will likely be fixed in a next release.

Regards,
Cesar

@arubiomoreno
Copy link

arubiomoreno commented Jul 24, 2017

Many thanks for this.
Until 3.7.0 reaches nuget, I am using this workaround:

NelderMead nm = new NelderMead(...);
nm.GetType().GetField("minf_max", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).SetValue(nm, Double.NegativeInfinity); // TODO: Remove when 3.7.0 is released

I post it here in case it is useful for someone

@cesarsouza
Copy link
Member

cesarsouza commented Aug 22, 2017

Fixed in v3.7.0.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants