@@ -13,14 +13,6 @@ public class State
1313{
1414 public State ( ConfigLoader cl )
1515 {
16- IEnumerable < Floor > GetFloorsByIds ( string [ ] ? floorIds )
17- {
18- if ( floorIds == null ) yield break ;
19- foreach ( var floorId in floorIds )
20- if ( Floors . TryGetValue ( floorId , out var floor ) )
21- yield return floor ;
22- }
23-
2416 void LoadConfig ( Config c )
2517 {
2618 Config = c ;
@@ -56,12 +48,13 @@ void LoadConfig(Config c)
5648 NamesToTrack = namesToTrack ;
5749 ConfigDeviceByName = configDeviceByName ;
5850
59- Weighting = c . Weighting ? . Algorithm switch
51+ var w = c ? . Locators ? . NealderMead ? . Weighting ;
52+ Weighting = w ? . Algorithm switch
6053 {
6154 "equal" => new EqualWeighting ( ) ,
62- "gaussian" => new GaussianWeighting ( c . Weighting ? . Props ) ,
63- "exponential" => new ExponentialWeighting ( c . Weighting ? . Props ) ,
64- _ => new GaussianWeighting ( c . Weighting ? . Props ) ,
55+ "gaussian" => new GaussianWeighting ( w ? . Props ) ,
56+ "exponential" => new ExponentialWeighting ( w ? . Props ) ,
57+ _ => new GaussianWeighting ( w ? . Props ) ,
6558 } ;
6659 foreach ( var device in Devices . Values ) device . Check = true ;
6760 }
@@ -100,7 +93,6 @@ public OptimizationSnapshot TakeOptimizationSnapshot()
10093 Tx = tx ,
10194 Rx = rx ,
10295 } ) ;
103-
10496 }
10597
10698 if ( OptimizationSnaphots . Count > Config ? . Optimization . MaxSnapshots ) OptimizationSnaphots . RemoveAt ( 0 ) ;
@@ -109,11 +101,44 @@ public OptimizationSnapshot TakeOptimizationSnapshot()
109101 return os ;
110102 }
111103
104+ IEnumerable < Floor > GetFloorsByIds ( string [ ] ? floorIds )
105+ {
106+ if ( floorIds == null )
107+ {
108+ foreach ( var floor in Floors . Values )
109+ yield return floor ;
110+ }
111+ else
112+ foreach ( var floorId in floorIds )
113+ if ( Floors . TryGetValue ( floorId , out var floor ) )
114+ yield return floor ;
115+ }
116+
112117 public IEnumerable < Scenario > GetScenarios ( Device device )
113118 {
114- foreach ( var floor in Floors . Values ) yield return new Scenario ( Config , new NelderMeadMultilateralizer ( device , floor , this ) , floor . Name ) ;
115- //yield return new Scenario(_state.Config, new MultiFloorMultilateralizer(device, _state), "Multifloor");
116- yield return new Scenario ( Config , new NearestNode ( device ) , "NearestNode" ) ;
119+ var nealderMead = Config ? . Locators ? . NealderMead ;
120+ var nadarayaWatson = Config ? . Locators ? . NadarayaWatson ;
121+ var nearestNode = Config ? . Locators ? . NearestNode ;
122+
123+ if ( ( nealderMead ? . Enabled ?? false ) || ( nadarayaWatson ? . Enabled ?? false ) || ( nearestNode ? . Enabled ?? false ) )
124+ {
125+ if ( nealderMead ? . Enabled ?? false )
126+ foreach ( var floor in GetFloorsByIds ( nealderMead ? . Floors ) )
127+ yield return new Scenario ( Config , new NelderMeadMultilateralizer ( device , floor , this ) , floor . Name ) ;
128+
129+ if ( nadarayaWatson ? . Enabled ?? false )
130+ foreach ( var floor in GetFloorsByIds ( nadarayaWatson ? . Floors ) )
131+ yield return new Scenario ( Config , new NadarayaWatsonMultilateralizer ( device , floor , this ) , floor . Name ) ;
132+
133+ if ( nearestNode ? . Enabled ?? false )
134+ yield return new Scenario ( Config , new NearestNode ( device ) , "NearestNode" ) ;
135+ }
136+ else
137+ {
138+ Log . Warning ( "No locators enabled, using default NelderMead" ) ;
139+ foreach ( var floor in Floors . Values )
140+ yield return new Scenario ( Config , new NelderMeadMultilateralizer ( device , floor , this ) , floor . Name ) ;
141+ }
117142 }
118143
119144 public bool ShouldTrack ( Device device )
0 commit comments