Class RobustLaterationSolver<P extends com.irurueta.geometry.Point<?>>
java.lang.Object
com.irurueta.navigation.lateration.RobustLaterationSolver<P>
- Type Parameters:
P
- aPoint
type.
- Direct Known Subclasses:
RobustLateration2DSolver
,RobustLateration3DSolver
public abstract class RobustLaterationSolver<P extends com.irurueta.geometry.Point<?>>
extends Object
This is an abstract class to robustly solve the lateration problem by finding the best
pairs of positions and distances among the provided ones.
Implementations of this class should be able to detect and discard outliers in order to find
the best solution.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected double
Amount of confidence expressed as a value between 0.0 and 1.0 (which is equivalent to 100%).protected com.irurueta.algebra.Matrix
Estimated covariance of estimated position.static final double
Constant defining default confidence of the estimated result, which is 99%.static final boolean
Indicates that covariance is kept by default after refining result.static final int
Default maximum allowed number of iterations.static final float
Default amount of progress variation before notifying a change in estimation progress.static final boolean
Indicates that by default preliminary solutions are refined.static final boolean
Indicates that result is refined by default using a non-linear lateration solver (which uses Levenberg-Marquardt fitter).static final com.irurueta.numerical.robust.RobustEstimatorMethod
Default robust estimator method when none is provided.static final boolean
Indicates that by default an homogeneous linear solver is used either to estimate preliminary solutions or an initial solution for preliminary solutions that will be later refined.private static final boolean
Indicates that by default a linear solver is used for preliminary solution estimation.protected double[]
Euclidean distances from static nodes to mobile node.protected double[]
Standard deviations of provided distances.static final double
Minimum allowed distance for a given circle or sphere.protected P
Estimated position.protected P
Initial position to use as a starting point to find a new solution.protected com.irurueta.numerical.robust.InliersData
Data related to inliers found after estimation.protected boolean
Indicates whether covariance must be kept after refining result.protected RobustLaterationSolverListener<P>
Listener to be notified of events such as when solving starts, ends or its progress significantly changes.protected boolean
Indicates if this instance is locked because lateration is being solved.static final double
Maximum allowed confidence value.static final float
Maximum allowed value for progress delta.protected int
Maximum allowed number of iterations.static final double
Minimum allowed confidence value.static final int
Minimum allowed number of iterations.static final float
Minimum allowed value for progress delta.protected P[]
Known positions of static nodes.protected int
Size of subsets to be checked during robust estimation.protected float
Amount of progress variation before notifying a progress change during estimation.protected boolean
Indicates whether preliminary solutions must be refined after an initial linear solution is found.protected boolean
Indicates whether result must be refined using a non-linear lateration solver over found inliers.protected boolean
Indicates whether an homogeneous linear solver is used either to estimate preliminary solutions or an initial solution for preliminary solutions that will be later refined.protected boolean
Indicates whether a linear solver is used or not (either homogeneous or inhomogeneous) for preliminary solutions. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Constructor.protected
Constructor.protected
RobustLaterationSolver
(P[] positions, double[] distances) Constructor.protected
RobustLaterationSolver
(P[] positions, double[] distances, double[] distanceStandardDeviations) Constructor.protected
RobustLaterationSolver
(P[] positions, double[] distances, double[] distanceStandardDeviations, RobustLaterationSolverListener<P> listener) Constructor.protected
RobustLaterationSolver
(P[] positions, double[] distances, RobustLaterationSolverListener<P> listener) Constructor. -
Method Summary
Modifier and TypeMethodDescriptiondouble
Returns amount of confidence expressed as a value between 0.0 and 1.0 (which is equivalent to 100%).com.irurueta.algebra.Matrix
Gets estimated covariance of estimated position if available.double[]
Gets euclidean distances from static nodes to mobile node.double[]
Gets standard deviations of provided distances.Gets estimated position.Gets initial position to use as a starting point to find a new solution.com.irurueta.numerical.robust.InliersData
Gets data related to inliers found after estimation.Gets listener to be notified of events raised by this instance.int
Returns maximum allowed number of iterations.abstract com.irurueta.numerical.robust.RobustEstimatorMethod
Returns method being used for robust estimation.abstract int
Minimum required number of positions and distances.abstract int
Gets number of dimensions of provided points.P[]
Gets known positions of static nodes.int
Gets size of subsets to be checked during robust estimation.float
Returns amount of progress variation before notifying a progress change during estimation.double[]
Returns quality scores corresponding to each pair of positions and distances (i.e. sample).protected void
internalSetPositionsAndDistances
(P[] positions, double[] distances) Internally sets known positions and Euclidean distances.protected void
internalSetPositionsDistancesAndStandardDeviations
(P[] positions, double[] distances, double[] distanceStandardDeviations) Internally sets known positions, Euclidean distances and the respective standard deviations of measured distances.boolean
Indicates whether covariance must be kept after refining result.boolean
Indicates whether an homogeneous linear solver is used either to estimate preliminary solutions or an initial solution for preliminary solutions that will be later refined.boolean
Indicates whether a linear solver is used or not (either homogeneous or inhomogeneous) for preliminary solutions.boolean
isLocked()
Returns boolean indicating if solver is locked because estimation is under progress.boolean
Indicates whether preliminary solutions must be refined after an initial linear solution is found.boolean
isReady()
Indicates whether solver is ready to find a solution.boolean
Indicates whether result must be refined using a non-linear solver over found inliers.void
setConfidence
(double confidence) Sets amount of confidence expressed as a value between 0.0 and 1.0 (which is equivalent to 100%).void
setCovarianceKept
(boolean keepCovariance) Specifies whether covariance must be kept after refining result.void
setHomogeneousLinearSolverUsed
(boolean useHomogeneousLinearSolver) Specifies whether an homogeneous linear solver is used either to estimate preliminary solutions or an initial solution for preliminary solutions that will be later refined.void
setInitialPosition
(P initialPosition) Sets initial position to use as a starting point to find a new solution.void
setLinearSolverUsed
(boolean linearSolverUsed) Specifies whether a linear solver is used or not (either homogeneous or inhomogeneous) for preliminary solutions.void
setListener
(RobustLaterationSolverListener<P> listener) Sets listener to be notified of events raised by this instance.void
setMaxIterations
(int maxIterations) Sets maximum allowed number of iterations.void
setPositionsAndDistances
(P[] positions, double[] distances) Sets known positions and Euclidean distances.void
setPositionsDistancesAndStandardDeviations
(P[] positions, double[] distances, double[] distanceStandardDeviations) Sets known positions, Euclidean distances and the respective standard deviations of measured distances.void
setPreliminarySolutionRefined
(boolean preliminarySolutionRefined) Specifies whether preliminary solutions must be refined after an initial linear solution is found.void
setPreliminarySubsetSize
(int preliminarySubsetSize) Sets size of subsets to be checked during robust estimation.void
setProgressDelta
(float progressDelta) Sets amount of progress variation before notifying a progress change during estimation.void
setQualityScores
(double[] qualityScores) Sets quality scores corresponding to each pair of positions and distances (i.e. sample).void
setResultRefined
(boolean refineResult) Specifies whether result must be refined using a non-linear solver over found inliers.abstract P
solve()
Solves the lateration problem.
-
Field Details
-
DEFAULT_USE_LINEAR_SOLVER
private static final boolean DEFAULT_USE_LINEAR_SOLVERIndicates that by default a linear solver is used for preliminary solution estimation. The result obtained on each preliminary solution might be later refined.- See Also:
-
DEFAULT_USE_HOMOGENEOUS_LINEAR_SOLVER
public static final boolean DEFAULT_USE_HOMOGENEOUS_LINEAR_SOLVERIndicates that by default an homogeneous linear solver is used either to estimate preliminary solutions or an initial solution for preliminary solutions that will be later refined.- See Also:
-
DEFAULT_REFINE_PRELIMINARY_SOLUTIONS
public static final boolean DEFAULT_REFINE_PRELIMINARY_SOLUTIONSIndicates that by default preliminary solutions are refined.- See Also:
-
DEFAULT_ROBUST_METHOD
public static final com.irurueta.numerical.robust.RobustEstimatorMethod DEFAULT_ROBUST_METHODDefault robust estimator method when none is provided. -
DEFAULT_REFINE_RESULT
public static final boolean DEFAULT_REFINE_RESULTIndicates that result is refined by default using a non-linear lateration solver (which uses Levenberg-Marquardt fitter).- See Also:
-
DEFAULT_KEEP_COVARIANCE
public static final boolean DEFAULT_KEEP_COVARIANCEIndicates that covariance is kept by default after refining result.- See Also:
-
DEFAULT_PROGRESS_DELTA
public static final float DEFAULT_PROGRESS_DELTADefault amount of progress variation before notifying a change in estimation progress. By default, this is set to 5%.- See Also:
-
MIN_PROGRESS_DELTA
public static final float MIN_PROGRESS_DELTAMinimum allowed value for progress delta.- See Also:
-
MAX_PROGRESS_DELTA
public static final float MAX_PROGRESS_DELTAMaximum allowed value for progress delta.- See Also:
-
DEFAULT_CONFIDENCE
public static final double DEFAULT_CONFIDENCEConstant defining default confidence of the estimated result, which is 99%. This means that with a probability of 99% estimation will be accurate because chosen sub-samples will be inliers.- See Also:
-
DEFAULT_MAX_ITERATIONS
public static final int DEFAULT_MAX_ITERATIONSDefault maximum allowed number of iterations.- See Also:
-
MIN_CONFIDENCE
public static final double MIN_CONFIDENCEMinimum allowed confidence value.- See Also:
-
MAX_CONFIDENCE
public static final double MAX_CONFIDENCEMaximum allowed confidence value.- See Also:
-
MIN_ITERATIONS
public static final int MIN_ITERATIONSMinimum allowed number of iterations.- See Also:
-
EPSILON
public static final double EPSILONMinimum allowed distance for a given circle or sphere.- See Also:
-
positions
Known positions of static nodes. -
distances
protected double[] distancesEuclidean distances from static nodes to mobile node. -
listener
Listener to be notified of events such as when solving starts, ends or its progress significantly changes. -
initialPosition
Initial position to use as a starting point to find a new solution. This is optional, but if provided, when no linear solvers are used, this is taken into account. If linear solvers are used, this is ignored. -
useLinearSolver
protected boolean useLinearSolverIndicates whether a linear solver is used or not (either homogeneous or inhomogeneous) for preliminary solutions. -
useHomogeneousLinearSolver
protected boolean useHomogeneousLinearSolverIndicates whether an homogeneous linear solver is used either to estimate preliminary solutions or an initial solution for preliminary solutions that will be later refined. -
refinePreliminarySolutions
protected boolean refinePreliminarySolutionsIndicates whether preliminary solutions must be refined after an initial linear solution is found. -
estimatedPosition
Estimated position. -
locked
protected boolean lockedIndicates if this instance is locked because lateration is being solved. -
progressDelta
protected float progressDeltaAmount of progress variation before notifying a progress change during estimation. -
confidence
protected double confidenceAmount of confidence expressed as a value between 0.0 and 1.0 (which is equivalent to 100%). The amount of confidence indicates the probability that the estimated result is correct. Usually this value will be close to 1.0, but not exactly 1.0. -
maxIterations
protected int maxIterationsMaximum allowed number of iterations. When the maximum number of iterations is exceeded, result will not be available, however an approximate result will be available for retrieval. -
inliersData
protected com.irurueta.numerical.robust.InliersData inliersDataData related to inliers found after estimation. -
refineResult
protected boolean refineResultIndicates whether result must be refined using a non-linear lateration solver over found inliers. If true, inliers will be computed and kept in any implementation regardless of the settings. -
keepCovariance
protected boolean keepCovarianceIndicates whether covariance must be kept after refining result. This setting is only taken into account if result is refined. -
covariance
protected com.irurueta.algebra.Matrix covarianceEstimated covariance of estimated position. This is only available when result has been refined and covariance is kept. -
distanceStandardDeviations
protected double[] distanceStandardDeviationsStandard deviations of provided distances. -
preliminarySubsetSize
protected int preliminarySubsetSizeSize of subsets to be checked during robust estimation.
-
-
Constructor Details
-
RobustLaterationSolver
protected RobustLaterationSolver()Constructor. -
RobustLaterationSolver
Constructor.- Parameters:
positions
- known positions of static nodes.distances
- euclidean distances from static nodes to mobile node.- Throws:
IllegalArgumentException
- if either positions or distances are null, don't have the same length or their length is smaller than required (3 for 2D points or 4 for 3D points).
-
RobustLaterationSolver
protected RobustLaterationSolver(P[] positions, double[] distances, double[] distanceStandardDeviations) Constructor.- Parameters:
positions
- known positions of static nodes.distances
- euclidean distances from static nodes to mobile node.distanceStandardDeviations
- standard deviations of provided measured distances.- Throws:
IllegalArgumentException
- if either positions, distances or standard deviations are null, don't have the same length or their length is smaller than required (3 for 2D points or 4 for 3D points).
-
-
Method Details
-
getListener
Gets listener to be notified of events raised by this instance.- Returns:
- listener to be notified of events raised by this instance.
-
getInitialPosition
Gets initial position to use as a starting point to find a new solution. This is optional, but if provided, when no linear solvers are used, this is taken into account. If linear solvers are used, this is ignored.- Returns:
- an initial position.
-
setInitialPosition
Sets initial position to use as a starting point to find a new solution. This is optional, but if provided, when no linear solvers are used, this is taken into account. If linear solvers are used, this is ignored.- Parameters:
initialPosition
- an initial position.- Throws:
LockedException
- if instance is busy solving the lateration problem.
-
isLinearSolverUsed
public boolean isLinearSolverUsed()Indicates whether a linear solver is used or not (either homogeneous or inhomogeneous) for preliminary solutions.- Returns:
- true if a linear solver is used, false otherwise.
-
setLinearSolverUsed
Specifies whether a linear solver is used or not (either homogeneous or inhomogeneous) for preliminary solutions.- Parameters:
linearSolverUsed
- true if a linear solver is used, false otherwise.- Throws:
LockedException
- if instance is busy solving the lateration problem.
-
isHomogeneousLinearSolverUsed
public boolean isHomogeneousLinearSolverUsed()Indicates whether an homogeneous linear solver is used either to estimate preliminary solutions or an initial solution for preliminary solutions that will be later refined.- Returns:
- true if homogeneous linear solver is used, false otherwise.
-
setHomogeneousLinearSolverUsed
public void setHomogeneousLinearSolverUsed(boolean useHomogeneousLinearSolver) throws LockedException Specifies whether an homogeneous linear solver is used either to estimate preliminary solutions or an initial solution for preliminary solutions that will be later refined.- Parameters:
useHomogeneousLinearSolver
- true if homogeneous linear solver is used, false otherwise.- Throws:
LockedException
- if instance is busy solving the lateration problem.
-
isPreliminarySolutionRefined
public boolean isPreliminarySolutionRefined()Indicates whether preliminary solutions must be refined after an initial linear solution is found. If no initial solution is found using a linear solver, a non-linear solver will be used regardless of this value using an average solution as the initial value to be refined.- Returns:
- true if preliminary solutions must be refined after an initial linear solution, false otherwise.
-
setPreliminarySolutionRefined
public void setPreliminarySolutionRefined(boolean preliminarySolutionRefined) throws LockedException Specifies whether preliminary solutions must be refined after an initial linear solution is found. If no initial solution is found using a linear solver, a non-linear solver will be used regardless of this value using an average solution as the initial value to be refined.- Parameters:
preliminarySolutionRefined
- true if preliminary solutions must be refined after an initial linear solution, false otherwise.- Throws:
LockedException
- if instance is busy solving the lateration problem.
-
isLocked
public boolean isLocked()Returns boolean indicating if solver is locked because estimation is under progress.- Returns:
- true if solver is locked, false otherwise.
-
getProgressDelta
public float getProgressDelta()Returns amount of progress variation before notifying a progress change during estimation.- Returns:
- amount of progress variation before notifying a progress change during estimation.
-
setProgressDelta
Sets amount of progress variation before notifying a progress change during estimation.- Parameters:
progressDelta
- amount of progress variation before notifying a progress change during estimation.- Throws:
IllegalArgumentException
- if progress delta is less than zero or greater than 1.LockedException
- if this solver is locked because an estimation is being computed.
-
getConfidence
public double getConfidence()Returns amount of confidence expressed as a value between 0.0 and 1.0 (which is equivalent to 100%). The amount of confidence indicates the probability that the estimated result is correct. Usually this value will be close to 1.0, but not exactly 1.0.- Returns:
- amount of confidence as a value between 0.0 and 1.0.
-
setConfidence
Sets amount of confidence expressed as a value between 0.0 and 1.0 (which is equivalent to 100%). The amount of confidence indicates the probability that the estimated result is correct. Usually this value will be close to 1.0, but not exactly 1.0.- Parameters:
confidence
- confidence to be set as a value between 0.0 and 1.0.- Throws:
IllegalArgumentException
- if provided value is not between 0.0 and 1.0.LockedException
- if solver is locked because an estimation is being computed.
-
getMaxIterations
public int getMaxIterations()Returns maximum allowed number of iterations. If maximum allowed number of iterations is achieved without converging to a result when calling solve(), a RobustEstimatorException will be raised.- Returns:
- maximum allowed number of iterations.
-
setMaxIterations
Sets maximum allowed number of iterations. When the maximum number of iterations is exceeded, result will not be available, however an approximate result will be available for retrieval.- Parameters:
maxIterations
- maximum allowed number of iterations to be set.- Throws:
IllegalArgumentException
- if provided value is less than 1.LockedException
- if this solver is locked because an estimation is being computed.
-
getInliersData
public com.irurueta.numerical.robust.InliersData getInliersData()Gets data related to inliers found after estimation.- Returns:
- data related to inliers found after estimation.
-
isResultRefined
public boolean isResultRefined()Indicates whether result must be refined using a non-linear solver over found inliers.- Returns:
- true to refine result, false to simply use result found by robust estimator without further refining.
-
setResultRefined
Specifies whether result must be refined using a non-linear solver over found inliers.- Parameters:
refineResult
- true to refine result, false to simply use result found by robust estimator without further refining.- Throws:
LockedException
- if solver is locked.
-
isCovarianceKept
public boolean isCovarianceKept()Indicates whether covariance must be kept after refining result. This setting is only taken into account if result is refined.- Returns:
- true if covariance must be kept after refining result, false otherwise.
-
setCovarianceKept
Specifies whether covariance must be kept after refining result. This setting is only taken into account if result is refined.- Parameters:
keepCovariance
- true if covariance must be kept after refining result, false otherwise.- Throws:
LockedException
- if estimator is locked.
-
getPositions
Gets known positions of static nodes.- Returns:
- known positions of static nodes.
-
getDistances
public double[] getDistances()Gets euclidean distances from static nodes to mobile node.- Returns:
- euclidean distances from static nodes to mobile node.
-
getDistanceStandardDeviations
public double[] getDistanceStandardDeviations()Gets standard deviations of provided distances. This is used during refinement.- Returns:
- standard deviations of provided distances.
-
isReady
public boolean isReady()Indicates whether solver is ready to find a solution.- Returns:
- true if solver is ready, false otherwise.
-
getQualityScores
public double[] getQualityScores()Returns quality scores corresponding to each pair of positions and distances (i.e. sample). The larger the score value the better the quality of the sample. This implementation always returns null. Subclasses using quality scores must implement proper behavior.- Returns:
- quality scores corresponding to each sample.
-
setQualityScores
Sets quality scores corresponding to each pair of positions and distances (i.e. sample). The larger the score value the better the quality of the sample. This implementation makes no action. Subclasses using quality scores must implement proper behaviour.- Parameters:
qualityScores
- quality scores corresponding to each pair of matched points.- Throws:
IllegalArgumentException
- if provided quality scores length is smaller than minimum required samples.LockedException
- if robust solver is locked because an estimation is already in progress.
-
getCovariance
public com.irurueta.algebra.Matrix getCovariance()Gets estimated covariance of estimated position if available. This is only available when result has been refined and covariance is kept.- Returns:
- estimated covariance or null.
-
setPositionsAndDistances
Sets known positions and Euclidean distances. If any distance value is zero or negative, it will be fixed assuming an EPSILON value.- Parameters:
positions
- known positions of static nodes.distances
- euclidean distances from static nodes to mobile node.- Throws:
IllegalArgumentException
- if either positions or distances are null, don't have the same length or their length is smaller than required (2 points).LockedException
- if instance is busy solving the lateration problem.
-
setPositionsDistancesAndStandardDeviations
public void setPositionsDistancesAndStandardDeviations(P[] positions, double[] distances, double[] distanceStandardDeviations) throws LockedException Sets known positions, Euclidean distances and the respective standard deviations of measured distances. If any distance value is zero or negative, it will be fixed assuming an EPSILON value.- Parameters:
positions
- known positions of static nodes.distances
- euclidean distances from static nodes to mobile node.distanceStandardDeviations
- standard deviations of provided measured distances.- Throws:
IllegalArgumentException
- if either positions, distances or standard deviations are null, don't have the same length of their length is smaller than required (2 points).LockedException
- if instance is busy solving the lateration problem.
-
getEstimatedPosition
Gets estimated position.- Returns:
- estimated position.
-
getNumberOfDimensions
public abstract int getNumberOfDimensions()Gets number of dimensions of provided points.- Returns:
- number of dimensions of provided points.
-
getMinRequiredPositionsAndDistances
public abstract int getMinRequiredPositionsAndDistances()Minimum required number of positions and distances. This value will depend on actual implementation and whether we are solving a 2D or 3D problem.- Returns:
- minimum required number of positions and distances.
-
getPreliminarySubsetSize
public int getPreliminarySubsetSize()Gets size of subsets to be checked during robust estimation. This has to be at leastgetMinRequiredPositionsAndDistances()
.- Returns:
- size of subsets to be checked during robust estimation.
-
setPreliminarySubsetSize
Sets size of subsets to be checked during robust estimation. This has to be at leastgetMinRequiredPositionsAndDistances()
.- Parameters:
preliminarySubsetSize
- size of subsets to be checked during robust estimation.- Throws:
LockedException
- if instance is busy solving the lateration problem.IllegalArgumentException
- if provided value is less thangetMinRequiredPositionsAndDistances()
.
-
solve
public abstract P solve() throws LockedException, NotReadyException, com.irurueta.numerical.robust.RobustEstimatorExceptionSolves the lateration problem.- Returns:
- estimated position.
- Throws:
LockedException
- if instance is busy solving the lateration problem.NotReadyException
- if solver is not ready.com.irurueta.numerical.robust.RobustEstimatorException
- if estimation fails for any reason (i.e. numerical instability, no solution available, etc).
-
getMethod
public abstract com.irurueta.numerical.robust.RobustEstimatorMethod getMethod()Returns method being used for robust estimation.- Returns:
- method being used for robust estimation.
-
internalSetPositionsAndDistances
Internally sets known positions and Euclidean distances. If any distance value is zero or negative, it will be fixed assuming an EPSILON value.- Parameters:
positions
- known positions of static nodes.distances
- euclidean distances from static nodes to mobile node.- Throws:
IllegalArgumentException
- if either positions or distances are null, don't have the same length or their length is smaller than required (2 points).
-
internalSetPositionsDistancesAndStandardDeviations
protected void internalSetPositionsDistancesAndStandardDeviations(P[] positions, double[] distances, double[] distanceStandardDeviations) Internally sets known positions, Euclidean distances and the respective standard deviations of measured distances. If any distance value is zero or negative, it will be fixed assuming an EPSILON value.- Parameters:
positions
- known positions of static nodes.distances
- euclidean distances from static nodes to mobile node.distanceStandardDeviations
- standard deviations of provided measured distances.- Throws:
IllegalArgumentException
- if either positions or distances are null, don't have the same length or their length is smaller than required (2 points).
-