0.5.0
Loading...
Searching...
No Matches
AmbiguityResolution.cpp
Go to the documentation of this file.
1// This file is part of INSTINCT, the INS Toolkit for Integrated
2// Navigation Concepts and Training by the Institute of Navigation of
3// the University of Stuttgart, Germany.
4//
5// This Source Code Form is subject to the terms of the Mozilla Public
6// License, v. 2.0. If a copy of the MPL was not distributed with this
7// file, You can obtain one at https://mozilla.org/MPL/2.0/.
8
9/// @file AmbiguityResolution.cpp
10/// @brief Ambiguity resolution algorithms
11/// @author T. Topp (topp@ins.uni-stuttgart.de)
12/// @date 2023-09-20
13
15#include <imgui.h>
16
21
22namespace NAV
23{
24
25const char* to_string(AmbiguityResolutionStrategy ambiguityResolutionStrategy)
26{
27 switch (ambiguityResolutionStrategy)
28 {
30 return "Continuous";
32 return "Fix and Hold";
34 break;
35 }
36 return "";
37}
38
40{
41 switch (decorrelationAlgorithm)
42 {
44 return "None";
46 return "Z-Transformation";
48 break;
49 }
50 return "";
51}
52
54{
55 switch (searchAlgorithm)
56 {
58 return "None";
60 return "Integer Rounding (IR)";
62 return "Integer Bootstrapping (IB)";
64 return "Integer least-squares (ILS) Search (LAMBDA)";
66 return "Integer least-squares (ILS) Search-And-Shrink (MLAMBDA)";
68 break;
69 }
70 return "";
71}
72
74{
75 switch (searchAlgorithm)
76 {
78 return "None";
80 return "Integer Rounding (IR)";
82 return "Integer Bootstrapping (IB)";
84 return "ILS Search (LAMBDA)";
86 return "ILS Search-And-Shrink (MLAMBDA)";
88 break;
89 }
90 return "";
91}
92
94{
95 switch (validationAlgorithm)
96 {
98 return "None";
100 return "Difference Test";
102 return "Projector Test";
104 return "Ratio Test (critical value)";
106 return "Ratio Test (failure rate)";
108 break;
109 }
110 return "";
111}
112
113bool GuiAmbiguityResolution(const char* id, AmbiguityResolutionParameters& params, float width)
114{
115 bool changed = false;
116
117 if (params.searchAlgorithm == AmbiguityResolutionParameters::SearchAlgorithm::None) { ImGui::BeginDisabled(); }
118 ImGui::SetNextItemWidth(width - ImGui::GetStyle().IndentSpacing);
119 changed |= gui::widgets::EnumCombo(fmt::format("Decorrelation Algorithm##{}", id).c_str(), params.decorrelationAlgorithm);
120 if (params.searchAlgorithm == AmbiguityResolutionParameters::SearchAlgorithm::None) { ImGui::EndDisabled(); }
121
122 ImGui::SetNextItemWidth(width - ImGui::GetStyle().IndentSpacing);
123 changed |= gui::widgets::EnumComboAbbreviation(fmt::format("Search Algorithm##{}", id).c_str(), params.searchAlgorithm);
124
125 changed |= ImGui::Checkbox(fmt::format("Partial fixing##{}", id).c_str(), &params.partialFixing);
126
127 if (params.searchAlgorithm == AmbiguityResolutionParameters::SearchAlgorithm::None) { ImGui::BeginDisabled(); }
128 {
129 ImGui::SetNextItemWidth(width - ImGui::GetStyle().IndentSpacing);
130 changed |= gui::widgets::EnumCombo(fmt::format("Validation Algorithm##{}", id).c_str(), params.validationAlgorithm);
131
133 {
134 changed |= ImGui::Checkbox(fmt::format("Validate with Bootstrapped Upper Bound##{}", id).c_str(), &params.validationBootstrappedSuccessRate);
135 ImGui::SameLine();
136 gui::widgets::HelpMarker("Bootstrapped failure rate is an upper bound for the ILS failure rate\n"
137 "and can be analytically calculated. If the bootstrapped failure rate is\n"
138 "smaller than the selected failure rate, the ratio test can be skipped.");
139 }
140
141 ImGui::SetNextItemWidth(width - ImGui::GetStyle().IndentSpacing);
143 {
144 changed |= ImGui::InputDouble(fmt::format("Critical Value c (R2 - R1 ≥ c)##{}", id).c_str(), &params.validationTestCriticalValueC, 0.0, 0.0, "%.3g");
145 }
147 {
148 changed |= ImGui::InputDoubleL(fmt::format("Critical Value µ ∈ (0, 1] (R1/R2 ≤ µ)##{}", id).c_str(), &params.validationTestCriticalValueMu, 1e-10, 1.0, 0.0, 0.0, "%.3g");
149 }
151 {
152 changed |= ImGui::InputDoubleL(fmt::format("Critical Value µ ∈ (0, 1]##{}", id).c_str(), &params.validationTestCriticalValueMu, 1e-10, 1.0, 0.0, 0.0, "%.3g");
153 }
155 {
156 int item_current = 0;
157 for (size_t i = 0; i < AmbiguityResolutionParameters::allowedFailureRateValues.size(); i++)
158 {
160 {
161 item_current = static_cast<int>(i);
162 break;
163 }
164 }
165 if (ImGui::Combo(fmt::format("Failure rate##{}", id).c_str(), &item_current, "0.1 %\0001 %\0\0"))
166 {
168 changed = true;
169 }
170 }
171 }
172 if (params.searchAlgorithm == AmbiguityResolutionParameters::SearchAlgorithm::None) { ImGui::EndDisabled(); }
173
174 return changed;
175}
176
178{
179 j = json{
180 { "decorrelationAlgorithm", obj.decorrelationAlgorithm },
181 { "searchAlgorithm", obj.searchAlgorithm },
182 { "partialFixing", obj.partialFixing },
183 { "validationBootstrappedSuccessRate", obj.validationBootstrappedSuccessRate },
184 { "validationAlgorithm", obj.validationAlgorithm },
185 { "validationTestCriticalValueC", obj.validationTestCriticalValueC },
186 { "validationTestCriticalValueMu", obj.validationTestCriticalValueMu },
187 { "validationRatioTestFailureRate", obj.validationRatioTestFailureRate },
188 };
189}
190
192{
193 if (j.contains("decorrelationAlgorithm")) { j.at("decorrelationAlgorithm").get_to(obj.decorrelationAlgorithm); }
194 if (j.contains("searchAlgorithm")) { j.at("searchAlgorithm").get_to(obj.searchAlgorithm); }
195 if (j.contains("partialFixing")) { j.at("partialFixing").get_to(obj.partialFixing); }
196 if (j.contains("validationBootstrappedSuccessRate")) { j.at("validationBootstrappedSuccessRate").get_to(obj.validationBootstrappedSuccessRate); }
197 if (j.contains("validationAlgorithm")) { j.at("validationAlgorithm").get_to(obj.validationAlgorithm); }
198 if (j.contains("validationTestCriticalValueC")) { j.at("validationTestCriticalValueC").get_to(obj.validationTestCriticalValueC); }
199 if (j.contains("validationTestCriticalValueMu")) { j.at("validationTestCriticalValueMu").get_to(obj.validationTestCriticalValueMu); }
200 if (j.contains("validationRatioTestFailureRate")) { j.at("validationRatioTestFailureRate").get_to(obj.validationRatioTestFailureRate); }
201}
202
203} // namespace NAV
Ambiguity resolution algorithms.
Combo representing an enumeration.
Combo representing an enumeration.
nlohmann::json json
json namespace
Text Help Marker (?) with Tooltip.
ImGui extensions.
bool InputDoubleL(const char *label, double *v, double v_min, double v_max, double step, double step_fast, const char *format, ImGuiInputTextFlags flags)
Shows a value limited InputText GUI element for 'double'.
Definition imgui_ex.cpp:294
bool EnumCombo(const char *label, T &enumeration, size_t startIdx=0)
Combo representing an enumeration.
Definition EnumCombo.hpp:30
void HelpMarker(const char *desc, const char *symbol="(?)")
Text Help Marker, e.g. '(?)', with Tooltip.
bool EnumComboAbbreviation(const char *label, T &enumeration, size_t startIdx=0)
Combo representing an enumeration and use abbreviations to display in the preview.
void to_json(json &j, const Node &node)
Converts the provided node into a json object.
Definition Node.cpp:990
AmbiguityResolutionStrategy
Ambiguity resolution strategies.
@ FixAndHold
Do not change the ambiguity once it is fixed.
@ COUNT
Amount of items in the enum.
@ Continuous
Estimate ambiguities every epoch.
const char * to_string_short(AmbiguityResolutionParameters::SearchAlgorithm searchAlgorithm)
Converts the enum to a string.
const char * to_string(gui::widgets::PositionWithFrame::ReferenceFrame refFrame)
Converts the enum to a string.
void from_json(const json &j, Node &node)
Converts the provided json object into a node object.
Definition Node.cpp:1007
bool GuiAmbiguityResolution(const char *id, AmbiguityResolutionParameters &params, float width)
Shows a ComboBox to select the ambiguity resolution algorithms.
Ambiguity resolution algorithms and parameters.
bool validationBootstrappedSuccessRate
Validation with Bootstrapped success rate (Bootstrapped failure rate is an upper bound for the ILS fa...
@ RatioTestFailureRate
Accept if , but with calculated from given failure rate (see verhagen2013 Verhagen 2013,...
@ None
Do not validate the solution (always accept the integer solution, if one is found)
SearchAlgorithm searchAlgorithm
Search algorithm.
double validationTestCriticalValueC
Critical value c for the the difference test.
double validationTestCriticalValueMu
Critical value µ for the the ratio and projector test (0, 1].
double validationRatioTestFailureRate
Failure rate for the ratio test (used to calculate µ)
DecorrelationAlgorithm
Decorrelation algorithms.
static constexpr std::array< double, 2 > allowedFailureRateValues
Possible failure rates for the look-up tables.
DecorrelationAlgorithm decorrelationAlgorithm
Decorrelation algorithm.
ValidationAlgorithm validationAlgorithm
Validation algorithm.
bool partialFixing
Attempt partial fixing of ambiguities.
@ IntegerLeastSquaresSearchAndShrink
Integer least-squares (ILS) Search-and-Shrink (MLAMBDA)
@ IntegerLeastSquaresSearch
Integer least-squares (ILS) Search (LAMBDA)