Class ModelerUtils
- java.lang.Object
-
- com.facebook.openwifi.rrm.modules.ModelerUtils
-
public class ModelerUtils extends Object
Modeler utilities.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static double
calculateTPCMetrics(int sampleSpace, double[][] rxPowerBest, double[][] sinrDB)
Get the coverage metrics for the TPC algorithm designstatic double[][]
generateHeatMap(int sampleSpace, int numOfAPs, double[][][] rxPower)
Get the heatmap over the mapstatic double[][][]
generateRxPower(int sampleSpace, int numOfAPs, List<Double> apLocX, List<Double> apLocY, List<Double> txPower)
Get the RX power over the map for all the APsstatic double[][]
generateSinr(int sampleSpace, int numOfAPs, double[][][] rxPower)
Get the max SINR over the mapstatic Map<String,Map<String,List<AggregatedState>>>
getAggregatedStates(Modeler.DataModel dataModel, long obsoletionPeriodMs, long refTimeMs)
This method aggregates States by bssid/station key pair and radio info.static Map<String,Map<String,WifiScanEntry>>
getAggregatedWifiScans(Modeler.DataModel dataModel, long obsoletionPeriodMs, Aggregator<Double> agg)
For each AP, for each other AP that sent a wifiscan entry to that AP, this method calculates an aggregate wifiscan entry with an aggregated RSSI.static Map<String,Map<String,WifiScanEntry>>
getAggregatedWifiScans(Modeler.DataModel dataModel, long obsoletionPeriodMs, Aggregator<Double> agg, long refTimeMs)
Compute aggregated wifiscans using a given reference time.static String
getBand(State.Radio radio, Map<String,Capabilities.Phy> capabilityPhy)
Return the radio's band, or null if band cannot be foundstatic String
getBssidStationKeyPair(String bssid, String station)
Create a key pair consisted of bssid and station stringstatic Map<String,StateInfo>
getLatestState(Map<String,List<StateInfo>> latestStates)
This method gets the most recent State from latestStates per device.
-
-
-
Method Detail
-
generateRxPower
public static double[][][] generateRxPower(int sampleSpace, int numOfAPs, List<Double> apLocX, List<Double> apLocY, List<Double> txPower)
Get the RX power over the map for all the APs- Parameters:
sampleSpace
- the boundary of the spacenumOfAPs
- the number of APsapLocX
- the location x of the APsapLocY
- the location y of the APstxPower
- the TX power of the APs- Returns:
- the RX power of location x, location y, and AP index
-
generateHeatMap
public static double[][] generateHeatMap(int sampleSpace, int numOfAPs, double[][][] rxPower)
Get the heatmap over the map- Parameters:
sampleSpace
- the boundary of the spacenumOfAPs
- the number of APsrxPower
- the RX power of location x, location y, and AP index- Returns:
- the max RX power of location x and location y
-
generateSinr
public static double[][] generateSinr(int sampleSpace, int numOfAPs, double[][][] rxPower)
Get the max SINR over the map- Parameters:
sampleSpace
- the boundary of the spacenumOfAPs
- the number of APsrxPower
- the RX power of location x, location y, and AP index- Returns:
- the max SINR of location x and location y
-
calculateTPCMetrics
public static double calculateTPCMetrics(int sampleSpace, double[][] rxPowerBest, double[][] sinrDB)
Get the coverage metrics for the TPC algorithm design- Parameters:
sampleSpace
- the boundary of the spacerxPowerBest
- the max RX power of location x and location ysinrDB
- the max SINR of location x and location y- Returns:
- the combined metric of over and under coverage, infinity if error
-
getAggregatedWifiScans
public static Map<String,Map<String,WifiScanEntry>> getAggregatedWifiScans(Modeler.DataModel dataModel, long obsoletionPeriodMs, Aggregator<Double> agg)
For each AP, for each other AP that sent a wifiscan entry to that AP, this method calculates an aggregate wifiscan entry with an aggregated RSSI. If no non-obsolete entry exists, the latest wifiscan entry is used instead.- Parameters:
dataModel
- the data model which includes the latest wifiscan entriesobsoletionPeriodMs
- for each (scanning AP, responding AP) tuple, the maximum amount of time (in milliseconds) it is worth aggregating over, starting from the most recent scan entry for that tuple, and working backwards in time. An entry exactlyobsoletionPeriodMs
ms earlier than the most recent entry is considered non-obsolete (i.e., the "non-obsolete" window is inclusive). Must be non-negative.agg
- an aggregator to calculate the aggregated RSSI given recent wifiscan entries' RSSIs.- Returns:
- a map from AP serial number to a map from BSSID to a
WifiScanEntry
object. This object is an "aggregated wifiscan entry" unless there is no non-obsolete wifiscan entry, in which case the latest wifiscan entry is used. An aggregated entry is just the latest entry with itssignal
attribute modified to be the aggregated signal value instead of the value in just the most recent entry for that (AP serial number, BSSID) tuple. The returned map will only map an (AP, BSSID) to an entry if an least one entry from that BSSID to that AP exists inModeler.DataModel.latestWifiScans
-
getAggregatedWifiScans
public static Map<String,Map<String,WifiScanEntry>> getAggregatedWifiScans(Modeler.DataModel dataModel, long obsoletionPeriodMs, Aggregator<Double> agg, long refTimeMs)
Compute aggregated wifiscans using a given reference time.
-
getAggregatedStates
public static Map<String,Map<String,List<AggregatedState>>> getAggregatedStates(Modeler.DataModel dataModel, long obsoletionPeriodMs, long refTimeMs)
This method aggregates States by bssid/station key pair and radio info. if two States of the same bssid/station match in channel, channel width and tx_power need to be aggregated to oneAggregatedState
. Currently only mcs and rssi fields are being aggregated. They are ofList<Integer>
type in AggregatedState, which list all the values over the time.- Parameters:
dataModel
- the data model which includes the latest recorded StatesobsoletionPeriodMs
- the maximum amount of time (in milliseconds) it is worth aggregating over, starting from the most recent States and working backwards in time. A State exactlyobsoletionPeriodMs
ms earlier than the most recent State is considered non-obsolete (i.e., the "non-obsolete" window is inclusive). Must be non-negative.refTimeMs
- the reference time were passed to make testing easier- Returns:
- map from serial number to a map from bssid_station String pair to a list of AggregatedState
-
getLatestState
public static Map<String,StateInfo> getLatestState(Map<String,List<StateInfo>> latestStates)
This method gets the most recent State from latestStates per device.- Parameters:
latestStates
- list of latest States per device- Returns:
- map from device String to latest State
-
getBssidStationKeyPair
public static String getBssidStationKeyPair(String bssid, String station)
Create a key pair consisted of bssid and station string
-
getBand
public static String getBand(State.Radio radio, Map<String,Capabilities.Phy> capabilityPhy)
Return the radio's band, or null if band cannot be found
-
-