@@ -201,6 +201,29 @@ public void Rat43_TRNCG_Dif()
201201 }
202202 }
203203
204+ [ Test ]
205+ public void Rat43_BasinHopping ( )
206+ {
207+ // Local Minimizer: LevenbergMarquardtMinimizer
208+ var obj = ObjectiveFunction . NonlinearModel ( Rat43Model , Rat43X , Rat43Y , accuracyOrder : 6 ) ;
209+ var solver = new BasinHopping ( localMinimizer : new LevenbergMarquardtMinimizer ( ) ) ;
210+ var result = solver . FindMinimum ( obj , Rat43Start2 ) ;
211+
212+ for ( var i = 0 ; i < result . MinimizingPoint . Count ; i ++ )
213+ {
214+ AssertHelpers . AlmostEqualRelative ( Rat43Pbest [ i ] , result . MinimizingPoint [ i ] , 2 ) ;
215+ }
216+
217+ // Local Minimizer: TrustRegionNewtonCGMinimizer
218+ solver = new BasinHopping ( localMinimizer : new TrustRegionNewtonCGMinimizer ( ) ) ;
219+ result = solver . FindMinimum ( obj . Fork ( ) , Rat43Start2 ) ;
220+
221+ for ( var i = 0 ; i < result . MinimizingPoint . Count ; i ++ )
222+ {
223+ AssertHelpers . AlmostEqualRelative ( Rat43Pbest [ i ] , result . MinimizingPoint [ i ] , 2 ) ;
224+ }
225+ }
226+
204227 [ Test ]
205228 public void Rat43_Bfgs_Dif ( )
206229 {
@@ -411,6 +434,42 @@ public void BoxBod_TRNCG_Dif()
411434 }
412435 }
413436
437+ [ Test ]
438+ public void BoxBod_BasinHopping ( )
439+ {
440+ // Local minimizer: LevenbergMarquardtMinimizer
441+
442+ var obj = ObjectiveFunction . NonlinearModel ( BoxBodModel , BoxBodX , BoxBodY , accuracyOrder : 2 ) ;
443+ var solver = new BasinHopping ( localMinimizer : new LevenbergMarquardtMinimizer ( ) ) ;
444+ var result = solver . FindMinimum ( obj , BoxBodStart2 ) ;
445+
446+ for ( var i = 0 ; i < result . MinimizingPoint . Count ; i ++ )
447+ {
448+ AssertHelpers . AlmostEqualRelative ( BoxBodPbest [ i ] , result . MinimizingPoint [ i ] , 3 ) ;
449+ AssertHelpers . AlmostEqualRelative ( BoxBodPstd [ i ] , result . StandardErrors [ i ] , 3 ) ;
450+ }
451+
452+ // Local Minimizer: TrustRegionDogLegMinimizer
453+ solver = new BasinHopping ( localMinimizer : new TrustRegionDogLegMinimizer ( ) ) ;
454+ result = solver . FindMinimum ( obj . Fork ( ) , BoxBodStart2 ) ;
455+
456+ for ( var i = 0 ; i < result . MinimizingPoint . Count ; i ++ )
457+ {
458+ AssertHelpers . AlmostEqualRelative ( BoxBodPbest [ i ] , result . MinimizingPoint [ i ] , 3 ) ;
459+ AssertHelpers . AlmostEqualRelative ( BoxBodPstd [ i ] , result . StandardErrors [ i ] , 3 ) ;
460+ }
461+
462+ // Local minimizer: TrustRegionNewtonCGMinimizer
463+ solver = new BasinHopping ( localMinimizer : new TrustRegionNewtonCGMinimizer ( ) ) ;
464+ result = solver . FindMinimum ( obj . Fork ( ) , BoxBodStart2 ) ;
465+
466+ for ( var i = 0 ; i < result . MinimizingPoint . Count ; i ++ )
467+ {
468+ AssertHelpers . AlmostEqualRelative ( BoxBodPbest [ i ] , result . MinimizingPoint [ i ] , 3 ) ;
469+ AssertHelpers . AlmostEqualRelative ( BoxBodPstd [ i ] , result . StandardErrors [ i ] , 3 ) ;
470+ }
471+ }
472+
414473 [ Test ]
415474 public void BoxBod_Bfgs_Der ( )
416475 {
0 commit comments