Class NonLinearFingerprintPositionAndRadioSourceEstimator<P extends com.irurueta.geometry.Point<?>>

Direct Known Subclasses:
NonLinearFingerprintPositionAndRadioSourceEstimator2D, NonLinearFingerprintPositionAndRadioSourceEstimator3D

public abstract class NonLinearFingerprintPositionAndRadioSourceEstimator<P extends com.irurueta.geometry.Point<?>> extends FingerprintPositionAndRadioSourceEstimator<P>
Base class for position and radio source estimators based only on located fingerprints containing RSSI readings. All implementations of this class estimate the position of a new fingerprint and the position of all radio sources associated to fingerprints whose location is known. All implementations solve the problem in a non-linear way using Levenberg-Marquardt algorithm.
  • Field Details

    • FALLBACK_RSSI_STANDARD_DEVIATION

      public static final double FALLBACK_RSSI_STANDARD_DEVIATION
      Default RSSI standard deviation assumed for provided fingerprints as a fallback when none can be determined.
      See Also:
    • DEFAULT_PROPAGATE_FINGERPRINT_RSSI_STANDARD_DEVIATION

      public static final boolean DEFAULT_PROPAGATE_FINGERPRINT_RSSI_STANDARD_DEVIATION
      Indicates that by default measured RSSI standard deviation of closest fingerprint must be propagated into measured RSSI reading variance at unknown location.
      See Also:
    • DEFAULT_PROPAGATE_PATHLOSS_EXPONENT_STANDARD_DEVIATION

      public static final boolean DEFAULT_PROPAGATE_PATHLOSS_EXPONENT_STANDARD_DEVIATION
      Indicates that by default path-loss exponent standard deviation of radio source must be propagated into measured RSSI reading variance at unknown location.
      See Also:
    • DEFAULT_PROPAGATE_FINGERPRINT_POSITION_COVARIANCE

      public static final boolean DEFAULT_PROPAGATE_FINGERPRINT_POSITION_COVARIANCE
      Indicates that by default covariance of closest fingerprint position must be propagated into measured RSSI reading variance at unknown location.
      See Also:
    • DEFAULT_PROPAGATE_RADIO_SOURCE_POSITION_COVARIANCE

      public static final boolean DEFAULT_PROPAGATE_RADIO_SOURCE_POSITION_COVARIANCE
      Indicates that by default covariance of radio source position must be propagated into measured RSSI reading variance at unknown location.
      See Also:
    • TINY

      private static final double TINY
      Small value to be used as machine precision.
      See Also:
    • mInitialLocatedSources

      protected List<? extends RadioSourceLocated<P extends com.irurueta.geometry.Point<?>>> mInitialLocatedSources
      Initial sources whose location is known. If provided, their location will be used as initial values, but after executing this estimator they will be refined.
    • initialPosition

      private P extends com.irurueta.geometry.Point<?> initialPosition
      Initial position to start the estimation. This should be a value close to the expected solution. If no value is provided, the average position among all selected nearest located fingerprints will be used.
    • useSourcesPathLossExponentWhenAvailable

      protected boolean useSourcesPathLossExponentWhenAvailable
      Indicates whether path loss exponent of provided sources must be used when available (if true), or if fallback path loss exponent must be used instead.
    • fallbackRssiStandardDeviation

      private double fallbackRssiStandardDeviation
      RSSI standard deviation fallback value to use when none can be determined from provided readings. This fallback value is only used if no variance is propagated or the resulting value is too small to allow convergence to a solution.
    • propagateFingerprintRssiStandardDeviation

      private boolean propagateFingerprintRssiStandardDeviation
      Indicates whether measured RSSI standard deviation of closest fingerprint must be propagated into measured RSSI reading variance at unknown location.
    • propagatePathlossExponentStandardDeviation

      private boolean propagatePathlossExponentStandardDeviation
      Indicates whether path-loss exponent standard deviation of radio source must be propagated into measured RSSI reading variance at unknown location.
    • propagateFingerprintPositionCovariance

      private boolean propagateFingerprintPositionCovariance
      Indicates whether covariance of closest fingerprint position must be propagated into measured RSSI reading variance at unknown location.
    • propagateRadioSourcePositionCovariance

      private boolean propagateRadioSourcePositionCovariance
      Indicates whether covariance of radio source position must be propagated into measured RSSI reading variance at unknown location.
    • fitter

      private final com.irurueta.numerical.fitting.LevenbergMarquardtMultiDimensionFitter fitter
      Levenberg-Marquardt fitter to find a non-linear solution.
    • covariance

      private com.irurueta.algebra.Matrix covariance
      Estimated covariance matrix for estimated non-located fingerprint position and estimated located radio sources position.
    • estimatedPositionCovariance

      private com.irurueta.algebra.Matrix estimatedPositionCovariance
      Covariance of estimated position for non-located fingerprint.
    • chiSq

      private double chiSq
      Estimated chi square value.
  • Constructor Details

    • NonLinearFingerprintPositionAndRadioSourceEstimator

      protected NonLinearFingerprintPositionAndRadioSourceEstimator()
      Constructor.
    • NonLinearFingerprintPositionAndRadioSourceEstimator

      protected NonLinearFingerprintPositionAndRadioSourceEstimator(FingerprintPositionAndRadioSourceEstimatorListener<P> listener)
      Constructor.
      Parameters:
      listener - listener in charge of handling events.
    • NonLinearFingerprintPositionAndRadioSourceEstimator

      protected NonLinearFingerprintPositionAndRadioSourceEstimator(List<? extends RssiFingerprintLocated<? extends RadioSource,? extends RssiReading<? extends RadioSource>,P>> locatedFingerprints, RssiFingerprint<? extends RadioSource,? extends RssiReading<? extends RadioSource>> fingerprint)
      Constructor.
      Parameters:
      locatedFingerprints - located fingerprints containing RSSI readings.
      fingerprint - fingerprint containing readings at an unknown location for provided located fingerprints.
      Throws:
      IllegalArgumentException - if either non located fingerprint or located fingerprints are null.
    • NonLinearFingerprintPositionAndRadioSourceEstimator

      protected NonLinearFingerprintPositionAndRadioSourceEstimator(List<? extends RssiFingerprintLocated<? extends RadioSource,? extends RssiReading<? extends RadioSource>,P>> locatedFingerprints, RssiFingerprint<? extends RadioSource,? extends RssiReading<? extends RadioSource>> fingerprint, FingerprintPositionAndRadioSourceEstimatorListener<P> listener)
      Constructor.
      Parameters:
      locatedFingerprints - located fingerprints containing RSSI readings.
      fingerprint - fingerprint containing readings at an unknown location for provided located fingerprints.
      listener - listener in charge of handling events.
      Throws:
      IllegalArgumentException - if either non located fingerprint or located fingerprints are null.
    • NonLinearFingerprintPositionAndRadioSourceEstimator

      protected NonLinearFingerprintPositionAndRadioSourceEstimator(List<? extends RssiFingerprintLocated<? extends RadioSource,? extends RssiReading<? extends RadioSource>,P>> locatedFingerprints, RssiFingerprint<? extends RadioSource,? extends RssiReading<? extends RadioSource>> fingerprint, P initialPosition)
      Constructor.
      Parameters:
      locatedFingerprints - located fingerprints containing RSSI readings.
      fingerprint - fingerprint containing readings at an unknown location for provided located fingerprints.
      initialPosition - initial position to be assumed on non located fingerprint or null if unknown.
      Throws:
      IllegalArgumentException - if either non located fingerprint or located fingerprints are null.
    • NonLinearFingerprintPositionAndRadioSourceEstimator

      protected NonLinearFingerprintPositionAndRadioSourceEstimator(List<? extends RssiFingerprintLocated<? extends RadioSource,? extends RssiReading<? extends RadioSource>,P>> locatedFingerprints, RssiFingerprint<? extends RadioSource,? extends RssiReading<? extends RadioSource>> fingerprint, P initialPosition, FingerprintPositionAndRadioSourceEstimatorListener<P> listener)
      Constructor.
      Parameters:
      locatedFingerprints - located fingerprints containing RSSI readings.
      fingerprint - fingerprint containing readings at an unknown location for provided located fingerprints.
      initialPosition - initial position to be assumed on non located fingerprint or null if unknown.
      listener - listener in charge of handling events.
      Throws:
      IllegalArgumentException - if either non located fingerprint or located fingerprints are null.
    • NonLinearFingerprintPositionAndRadioSourceEstimator

      protected NonLinearFingerprintPositionAndRadioSourceEstimator(List<? extends RssiFingerprintLocated<? extends RadioSource,? extends RssiReading<? extends RadioSource>,P>> locatedFingerprints, RssiFingerprint<? extends RadioSource,? extends RssiReading<? extends RadioSource>> fingerprint, List<? extends RadioSourceLocated<P>> initialLocatedSources)
      Constructor.
      Parameters:
      locatedFingerprints - located fingerprints containing RSSI readings.
      fingerprint - fingerprint containing readings at an unknown location for provided located fingerprints.
      initialLocatedSources - sources containing initial location to be refined or null if unknown.
      Throws:
      IllegalArgumentException - if either non located fingerprint or located fingerprints are null.
    • NonLinearFingerprintPositionAndRadioSourceEstimator

      protected NonLinearFingerprintPositionAndRadioSourceEstimator(List<? extends RssiFingerprintLocated<? extends RadioSource,? extends RssiReading<? extends RadioSource>,P>> locatedFingerprints, RssiFingerprint<? extends RadioSource,? extends RssiReading<? extends RadioSource>> fingerprint, List<? extends RadioSourceLocated<P>> initialLocatedSources, FingerprintPositionAndRadioSourceEstimatorListener<P> listener)
      Constructor.
      Parameters:
      locatedFingerprints - located fingerprints containing RSSI readings.
      fingerprint - fingerprint containing readings at an unknown location for provided located fingerprints.
      initialLocatedSources - sources containing initial location to be refined or null if unknown.
      listener - listener in charge of handling events.
      Throws:
      IllegalArgumentException - if either non located fingerprint or located fingerprints are null.
    • NonLinearFingerprintPositionAndRadioSourceEstimator

      protected NonLinearFingerprintPositionAndRadioSourceEstimator(List<? extends RssiFingerprintLocated<? extends RadioSource,? extends RssiReading<? extends RadioSource>,P>> locatedFingerprints, RssiFingerprint<? extends RadioSource,? extends RssiReading<? extends RadioSource>> fingerprint, P initialPosition, List<? extends RadioSourceLocated<P>> initialLocatedSources)
      Constructor.
      Parameters:
      locatedFingerprints - located fingerprints containing RSSI readings.
      fingerprint - fingerprint containing readings at an unknown location for provided located fingerprints.
      initialPosition - initial position to be assumed on non located fingerprint or null if unknown.
      initialLocatedSources - sources containing initial location to be refined or null if unknown.
      Throws:
      IllegalArgumentException - if either non located fingerprint or located fingerprints are null.
    • NonLinearFingerprintPositionAndRadioSourceEstimator

      protected NonLinearFingerprintPositionAndRadioSourceEstimator(List<? extends RssiFingerprintLocated<? extends RadioSource,? extends RssiReading<? extends RadioSource>,P>> locatedFingerprints, RssiFingerprint<? extends RadioSource,? extends RssiReading<? extends RadioSource>> fingerprint, P initialPosition, List<? extends RadioSourceLocated<P>> initialLocatedSources, FingerprintPositionAndRadioSourceEstimatorListener<P> listener)
      Constructor.
      Parameters:
      locatedFingerprints - located fingerprints containing RSSI readings.
      fingerprint - fingerprint containing readings at an unknown location for provided located fingerprints.
      initialPosition - initial position to be assumed on non located fingerprint or null if unknown.
      initialLocatedSources - sources containing initial location to be refined or null if unknown.
      listener - listener in charge of handling events.
      Throws:
      IllegalArgumentException - if either non located fingerprint or located fingerprints are null.
  • Method Details

    • getInitialLocatedSources

      public List<RadioSourceLocated<P>> getInitialLocatedSources()
      Gets initial radio sources whose location is known.
      Returns:
      initial radio sources.
    • setInitialLocatedSources

      public void setInitialLocatedSources(List<? extends RadioSourceLocated<P>> initialLocatedSources) throws com.irurueta.navigation.LockedException
      Sets initial radio sources whose location is known.
      Parameters:
      initialLocatedSources - initial radio sources.
      Throws:
      com.irurueta.navigation.LockedException - if estimator is locked.
    • getInitialPosition

      public P getInitialPosition()
      Gets initial position to start the solving algorithm. This should be a value close to the expected solution. If no value is provided, the average position among all selected nearest located fingerprints will be used.
      Returns:
      initial position to start the solving algorithm or null.
    • setInitialPosition

      public void setInitialPosition(P initialPosition) throws com.irurueta.navigation.LockedException
      Sets initial position to start the solving algorithm. This should be a value close to the expected solution. If no value is provided, the average position among all selected nearest located fingerprints will be used.
      Parameters:
      initialPosition - initial position to start the solving algorithm or null.
      Throws:
      com.irurueta.navigation.LockedException - if estimator is locked.
    • getCovariance

      public com.irurueta.algebra.Matrix getCovariance()
      Gets estimated covariance matrix for estimated non-located fingerprint position and estimated located radio sources position.
      Returns:
      estimated covariance matrix for estimated non-located fingerprint position and estimated located radio sources position.
    • getEstimatedPositionCovariance

      public com.irurueta.algebra.Matrix getEstimatedPositionCovariance()
      Gets covariance of estimated position for non-located fingerprint.
      Returns:
      covariance of estimated position for non-located fingerprint.
    • getChiSq

      public double getChiSq()
      Gets estimated chi square value.
      Returns:
      estimated chi square value.
    • getUseSourcesPathLossExponentWhenAvailable

      public boolean getUseSourcesPathLossExponentWhenAvailable()
      Indicates whether path loss exponent of provided sources must be used when available (if true), or if fallback path loss exponent must be used instead.
      Returns:
      true to use path loss exponent of provided sources when available, false otherwise.
    • setUseSourcesPathLossExponentWhenAvailable

      public void setUseSourcesPathLossExponentWhenAvailable(boolean useSourcesPathLossExponentWhenAvailable) throws com.irurueta.navigation.LockedException
      Specifies whether path loss exponent of provided sources must be used when available (if true), or if fallback path loss exponent must be used instead.
      Parameters:
      useSourcesPathLossExponentWhenAvailable - true to use path loss exponent of provided sources when available, false otherwise.
      Throws:
      com.irurueta.navigation.LockedException - if estimator is locked.
    • getFallbackRssiStandardDeviation

      public double getFallbackRssiStandardDeviation()
      Gets RSSI standard deviation fallback value to use when none can be determined from provided readings.
      Returns:
      RSSI standard deviation fallback.
    • setFallbackRssiStandardDeviation

      public void setFallbackRssiStandardDeviation(double fallbackRssiStandardDeviation) throws com.irurueta.navigation.LockedException
      Sets RSSI standard deviation fallback value to use when none can be determined from provided readings.
      Parameters:
      fallbackRssiStandardDeviation - RSSI standard deviation fallback
      Throws:
      com.irurueta.navigation.LockedException - if estimator is locked.
      IllegalArgumentException - if provided value is smaller than TINY.
    • isFingerprintRssiStandardDeviationPropagated

      public boolean isFingerprintRssiStandardDeviationPropagated()
      Indicates whether measured RSSI standard deviation of closest fingerprint must be propagated into measured RSSI reading variance at unknown location.
      Returns:
      true to propagate RSSI standard deviation of closest fingerprint, false otherwise.
    • setFingerprintRssiStandardDeviationPropagated

      public void setFingerprintRssiStandardDeviationPropagated(boolean propagateFingerprintRssiStandardDeviation) throws com.irurueta.navigation.LockedException
      Specifies whether measured RSSI standard deviation of closest fingerprint must be propagated into measured RSSI reading variance at unknown location.
      Parameters:
      propagateFingerprintRssiStandardDeviation - true to propagate RSSI standard deviation of closest fingerprint, false otherwise.
      Throws:
      com.irurueta.navigation.LockedException - if estimator is locked.
    • isPathlossExponentStandardDeviationPropagated

      public boolean isPathlossExponentStandardDeviationPropagated()
      Indicates whether path-loss exponent standard deviation of radio source must be propagated into measured RSSI reading variance at unknown location.
      Returns:
      true to propagate path-loss exponent standard deviation of radio source, false otherwise.
    • setPathlossExponentStandardDeviationPropagated

      public void setPathlossExponentStandardDeviationPropagated(boolean propagatePathlossExponentStandardDeviation) throws com.irurueta.navigation.LockedException
      Specifies whether path-loss exponent standard deviation of radio source must be propagated into measured RSSI reading variance at unknown location.
      Parameters:
      propagatePathlossExponentStandardDeviation - true to propagate path-loss exponent standard deviation of radio source, false otherwise.
      Throws:
      com.irurueta.navigation.LockedException - if estimator is locked.
    • isFingerprintPositionCovariancePropagated

      public boolean isFingerprintPositionCovariancePropagated()
      Indicates whether covariance of closest fingerprint position must be propagated into measured RSSI reading variance at unknown location.
      Returns:
      true to propagate fingerprint position covariance, false otherwise.
    • setFingerprintPositionCovariancePropagated

      public void setFingerprintPositionCovariancePropagated(boolean propagateFingerprintPositionCovariance) throws com.irurueta.navigation.LockedException
      Specifies whether covariance of closest fingerprint position must be propagated into measured RSSI reading variance at unknown location.
      Parameters:
      propagateFingerprintPositionCovariance - true to propagate fingerprint position covariance, false otherwise.
      Throws:
      com.irurueta.navigation.LockedException - if estimator is locked.
    • isRadioSourcePositionCovariancePropagated

      public boolean isRadioSourcePositionCovariancePropagated()
      Indicates whether covariance of radio source position must be propagated into measured RSSI reading variance at unknown location.
      Returns:
      true to propagate radio source position covariance, false otherwise.
    • setRadioSourcePositionCovariancePropagated

      public void setRadioSourcePositionCovariancePropagated(boolean propagateRadioSourcePositionCovariance) throws com.irurueta.navigation.LockedException
      Specifies whether covariance of radio source position must be propagated into measured RSSI reading variance at unknown location.
      Parameters:
      propagateRadioSourcePositionCovariance - true to propagate radio source position covariance, false otherwise.
      Throws:
      com.irurueta.navigation.LockedException - if estimator is locked.
    • estimate

      public void estimate() throws com.irurueta.navigation.LockedException, com.irurueta.navigation.NotReadyException, FingerprintEstimationException
      Estimates position and radio sources based on provided located radio sources and readings of such radio sources at an unknown location.
      Specified by:
      estimate in class BaseFingerprintPositionAndRadioSourceEstimator<P extends com.irurueta.geometry.Point<?>,FingerprintPositionAndRadioSourceEstimatorListener<P extends com.irurueta.geometry.Point<?>>>
      Throws:
      com.irurueta.navigation.LockedException - if estimator is locked.
      com.irurueta.navigation.NotReadyException - if estimator is not ready.
      FingerprintEstimationException - if estimation fails for some other reason.
    • propagateVariances

      protected abstract Double propagateVariances(double pathlossExponent, P fingerprintPosition, P radioSourcePosition, P estimatedPosition, Double pathlossExponentVariance, com.irurueta.algebra.Matrix fingerprintPositionCovariance, com.irurueta.algebra.Matrix radioSourcePositionCovariance)
      Propagates provided variances into RSSI differences.
      Parameters:
      pathlossExponent - path-loss exponent.
      fingerprintPosition - position of closest located fingerprint.
      radioSourcePosition - radio source position associated to fingerprint reading.
      estimatedPosition - position to be estimated. Usually this is equal to the initial position used by a non-linear algorithm.
      pathlossExponentVariance - variance of path-loss exponent or null if unknown.
      fingerprintPositionCovariance - covariance of fingerprint position or null if unknown.
      radioSourcePositionCovariance - covariance of radio source position or null if unknown.
      Returns:
      variance of RSSI difference measured at non located fingerprint reading.
    • createRadioSource

      private RadioSourceLocated<P> createRadioSource(RadioSource source, P sourcePosition, com.irurueta.algebra.Matrix sourceCovariance)
      Creates a located radio source from provided radio source, position and covariance.
      Parameters:
      source - radio source.
      sourcePosition - radio source position.
      sourceCovariance - radio source position covariance.
      Returns:
      located radio source.
    • buildData

      private void buildData(List<Double> allPowerDiffs, List<P> allFingerprintPositions, List<P> allInitialSourcesPositions, List<RadioSource> allSourcesToBeEstimated, List<Integer> allSourcesIndices, List<Double> allPathLossExponents, List<Double> allStandardDeviations, P nearestFingerprintsCentroid)
      Builds data required to solve the problem. This method takes into account current nearest fingerprints and discards those readings belonging to radio sources not having enough data to be estimated.
      Parameters:
      allPowerDiffs - list of received power differences of RSSI readings between a located fingerprint and an unknown fingerprint for a given radio source.
      allFingerprintPositions - positions of all located fingerprints being taken into account.
      allInitialSourcesPositions - initial positions of all radio sources to be taken into account. If initial located sources where provided, their positions will be used, otherwise the centroid of all located fingerprints associated to a radio source will be used as initial position.
      allSourcesToBeEstimated - all radio sources that will be estimated.
      allSourcesIndices - indices indicating the position radio source being used within the list of sources for current reading.
      allPathLossExponents - list of path loss exponents.
      allStandardDeviations - list of standard deviations for readings being used.
      nearestFingerprintsCentroid - centroid of nearest fingerprints being taken into account.
    • setupFitter

      private List<RadioSource> setupFitter() throws com.irurueta.numerical.fitting.FittingException
      Setups fitter to solve positions.
      Returns:
      list of radio sources whose location will be estimated.
      Throws:
      com.irurueta.numerical.fitting.FittingException - if Levenberg-Marquardt fitting fails.
    • totalReadingsForSource

      private int totalReadingsForSource(RadioSource source, List<RssiFingerprintLocated<RadioSource,RssiReading<RadioSource>,P>> fingerprints, P centroid)
      Gets the total number of readings associated to provided radio source. This method uses only current nearest fingerprints.
      Parameters:
      source - radio source to be checked
      fingerprints - fingerprints where search is made.
      centroid - centroid to be computed.
      Returns:
      total number of readings associated to provided radio source.