19 #include "gtest/gtest.h" 25 TEST(ProbabilityValuesTest, OddsConversions) {
33 TEST(ProbabilityValuesTest, OddsConversionsCorrespondenceCost) {
45 TEST(ProbabilityValuesTest,
46 ProbabilityValueToCorrespondenceCostValueConversions) {
47 for (
uint16 i = 0; i < 32768; ++i) {
57 TEST(ProbabilityValuesTest,
58 ProbabilityValueToCorrespondenceCostValueConversionsWithUpdateMarker) {
59 for (
uint16 i = 1; i < 32768; ++i) {
69 TEST(ProbabilityValuesTest, ConversionLookUpTable) {
71 for (
uint16 i = 1; i < 32768; ++i) {
77 TEST(ProbabilityValuesTest, CellUpdate) {
78 std::vector<uint16> probability_table =
80 std::vector<uint16> correspondence_table =
82 uint16 cell_pg_pre_update = 0;
83 uint16 cell_cg_pre_update = 0;
84 uint16 cell_pg_post_update = probability_table[cell_pg_pre_update];
85 uint16 cell_cg_post_update = correspondence_table[cell_cg_pre_update];
88 EXPECT_NEAR(p_post, 1.f - c_post, 1e-6);
89 int num_evaluations = 5000;
90 for (
int i_probability = 0; i_probability < num_evaluations;
92 float p = (
static_cast<float>(i_probability) /
93 static_cast<float>(num_evaluations)) *
107 EXPECT_NEAR(cell_pg_pre_update, 32768 - cell_cg_pre_update, 1)
108 <<
"p " << p <<
" p_value " << p_value <<
" cvalue " << cvalue
111 cell_pg_post_update = probability_table[cell_pg_pre_update];
112 cell_cg_post_update = correspondence_table[cell_cg_pre_update];
115 EXPECT_NEAR(p_post, 1.f - c_post, 5e-5)
116 <<
"p " << p <<
" " << p_post - 1.f + c_post;
120 TEST(ProbabilityValuesTest, MultipleCellUpdate) {
121 std::vector<uint16> probability_table =
123 std::vector<uint16> correspondence_table =
125 uint16 cell_pg_post_update = probability_table[0];
126 uint16 cell_cg_post_update = correspondence_table[0];
129 EXPECT_NEAR(p_post, 1.f - c_post, 1e-6);
130 int num_evaluations = 5000;
131 for (
int i_probability = 0; i_probability < num_evaluations;
133 float p = (
static_cast<float>(i_probability) /
134 static_cast<float>(num_evaluations)) *
138 cell_cg_post_update =
141 for (
int i_update = 0; i_update < 20; ++i_update) {
142 cell_pg_post_update =
144 cell_cg_post_update =
149 EXPECT_NEAR(p_post, 1.f - c_post, 5e-5)
150 <<
"p " << p <<
" p_post " << p_post <<
" " << p_post - 1.f + c_post;
154 TEST(ProbabilityValuesTest, EqualityLookupTableToApplyOdds) {
156 std::vector<uint16> correspondence_table =
158 for (
int i = 0; i < 32768; ++i) {
160 probability_table[i],
167 correspondence_table[i], 1);
uint16 ProbabilityValueToCorrespondenceCostValue(uint16 probability_value)
std::vector< uint16 > ComputeLookupTableToApplyOdds(const float odds)
std::vector< uint16 > ComputeLookupTableToApplyCorrespondenceCostOdds(float odds)
float ProbabilityFromOdds(const float odds)
float ValueToCorrespondenceCost(const uint16 value)
int RoundToInt(const float x)
constexpr float kMinProbability
constexpr float kMaxCorrespondenceCost
float ValueToProbability(const uint16 value)
constexpr float kMaxProbability
float CorrespondenceCostToProbability(const float correspondence_cost)
uint16 CorrespondenceCostValueToProbabilityValue(uint16 correspondence_cost_value)
float Odds(float probability)
float ProbabilityToCorrespondenceCost(const float probability)
uint16 ProbabilityToValue(const float probability)
T Clamp(const T value, const T min, const T max)
uint16 CorrespondenceCostToValue(const float correspondence_cost)
constexpr uint16 kUpdateMarker
constexpr float kMinCorrespondenceCost
TEST(TrajectoryConnectivityStateTest, UnknownTrajectory)