From 6395e4a41829e7112cd5bb0d2714b4a706944678 Mon Sep 17 00:00:00 2001 From: Ivan Morozko Date: Thu, 3 Oct 2024 15:45:48 +0400 Subject: [PATCH] NOT NEEDED, JUST FOR TESTING: Add test that verifies ADCs on airport.csv --- src/tests/test_dc_structures.cpp | 39 ++++ .../test_dc_structures_correct_results.h | 205 ++++++++++++++++++ 2 files changed, 244 insertions(+) diff --git a/src/tests/test_dc_structures.cpp b/src/tests/test_dc_structures.cpp index aacc6b28b..ad555e950 100644 --- a/src/tests/test_dc_structures.cpp +++ b/src/tests/test_dc_structures.cpp @@ -556,4 +556,43 @@ TEST_F(FastADC, DenialConstraints) { } } +TEST(FastADCAirport, RealDenialConstraints) { + CSVParser parser{kAirport}; + auto table = model::ColumnLayoutTypedRelationData::CreateFrom(parser, true, true); + auto col_data = std::move(table->GetColumnData()); + + PredicateIndexProvider pred_index_provider; + PredicateProvider pred_provider; + IntIndexProvider int_prov; + DoubleIndexProvider double_prov; + StringIndexProvider string_prov; + + PredicateBuilder predicate_builder(&pred_provider, &pred_index_provider, true); + predicate_builder.BuildPredicateSpace(col_data); + + PliShardBuilder plibuilder(&int_prov, &double_prov, &string_prov); + plibuilder.BuildPliShards(col_data); + + EvidenceAuxStructuresBuilder aux_builder(predicate_builder); + aux_builder.BuildAll(); + + EvidenceSetBuilder evidence_set_builder(plibuilder.pli_shards, aux_builder.GetPredicatePacks()); + evidence_set_builder.BuildEvidenceSet(aux_builder.GetCorrectionMap(), + aux_builder.GetCardinalityMask()); + + ApproxEvidenceInverter dcbuilder(predicate_builder, 0.01, + std::move(evidence_set_builder.evidence_set)); + auto dcs = dcbuilder.BuildDenialConstraints(); + + std::vector result = std::move(dcs.GetResult()); + std::set ordered_result( + std::make_move_iterator(result.begin()), std::make_move_iterator(result.end())); + + for (size_t i = 0; i < expected_real_denial_constraints.size(); i++) { + std::string dc = std::next(ordered_result.begin(), i)->ToString(); + EXPECT_EQ(dc, expected_real_denial_constraints[i]) + << "Unexpected denial constraint: " << dc; + } +} + } // namespace tests diff --git a/src/tests/test_dc_structures_correct_results.h b/src/tests/test_dc_structures_correct_results.h index b9bda4d03..5851ca667 100644 --- a/src/tests/test_dc_structures_correct_results.h +++ b/src/tests/test_dc_structures_correct_results.h @@ -550,3 +550,208 @@ std::vector expected_denial_constraints = { "¬{ t.D == s.D ∧ t.F == s.F }", "¬{ t.D == s.D ∧ t.G == s.G }", "¬{ t.E == s.E }"}; + +std::vector expected_real_denial_constraints = { + "¬{ t.continent != s.continent ∧ t.iso_country == s.iso_country }", + "¬{ t.continent != s.continent ∧ t.municipality == s.municipality }", + "¬{ t.continent == s.continent ∧ t.gps_code != s.gps_code ∧ t.gps_code == s.local_code ∧ " + "t.local_code == s.local_code }", + "¬{ t.continent == s.continent ∧ t.gps_code == s.gps_code ∧ t.gps_code != s.local_code }", + "¬{ t.continent == s.continent ∧ t.gps_code == s.gps_code ∧ t.local_code != s.local_code }", + "¬{ t.continent == s.continent ∧ t.gps_code == s.gps_code ∧ t.local_code == s.local_code }", + "¬{ t.continent == s.continent ∧ t.gps_code == s.local_code ∧ t.local_code != s.local_code " + "}", + "¬{ t.continent == s.continent ∧ t.iso_country != s.iso_country ∧ t.gps_code == s.gps_code " + "∧ t.gps_code == s.local_code }", + "¬{ t.continent == s.continent ∧ t.iso_region != s.iso_region ∧ t.municipality != " + "s.municipality ∧ t.gps_code == s.gps_code ∧ t.gps_code == s.local_code }", + "¬{ t.continent == s.continent ∧ t.municipality == s.municipality }", + "¬{ t.coordinates == s.coordinates }", + "¬{ t.elevation_ft != s.elevation_ft ∧ t.continent != s.continent ∧ t.gps_code == " + "s.gps_code ∧ t.gps_code == s.local_code ∧ t.local_code != s.local_code }", + "¬{ t.elevation_ft != s.elevation_ft ∧ t.continent == s.continent ∧ t.gps_code == " + "s.gps_code ∧ t.gps_code == s.local_code }", + "¬{ t.elevation_ft != s.elevation_ft ∧ t.continent == s.continent ∧ t.iso_country != " + "s.iso_country ∧ t.gps_code == s.gps_code }", + "¬{ t.elevation_ft != s.elevation_ft ∧ t.municipality == s.municipality }", + "¬{ t.elevation_ft < s.elevation_ft ∧ t.continent == s.continent ∧ t.gps_code == " + "s.local_code ∧ t.local_code == s.local_code }", + "¬{ t.elevation_ft < s.elevation_ft ∧ t.continent == s.continent ∧ t.iso_country != " + "s.iso_country ∧ t.municipality != s.municipality ∧ t.gps_code == s.local_code }", + "¬{ t.elevation_ft <= s.elevation_ft ∧ t.continent != s.continent ∧ t.gps_code == " + "s.gps_code ∧ t.gps_code != s.local_code }", + "¬{ t.elevation_ft <= s.elevation_ft ∧ t.continent == s.continent ∧ t.gps_code != " + "s.gps_code ∧ t.gps_code == s.local_code }", + "¬{ t.elevation_ft <= s.elevation_ft ∧ t.continent == s.continent ∧ t.gps_code == " + "s.gps_code }", + "¬{ t.elevation_ft <= s.elevation_ft ∧ t.continent == s.continent ∧ t.iso_country != " + "s.iso_country ∧ t.gps_code != s.local_code ∧ t.local_code == s.local_code }", + "¬{ t.elevation_ft <= s.elevation_ft ∧ t.continent == s.continent ∧ t.iso_country != " + "s.iso_country ∧ t.gps_code == s.local_code ∧ t.local_code == s.local_code }", + "¬{ t.elevation_ft <= s.elevation_ft ∧ t.gps_code != s.gps_code ∧ t.gps_code == " + "s.local_code ∧ t.local_code != s.local_code }", + "¬{ t.elevation_ft <= s.elevation_ft ∧ t.municipality == s.municipality }", + "¬{ t.elevation_ft == s.elevation_ft ∧ t.continent != s.continent ∧ t.gps_code == " + "s.local_code }", + "¬{ t.elevation_ft == s.elevation_ft ∧ t.continent != s.continent ∧ t.municipality != " + "s.municipality ∧ t.local_code == s.local_code }", + "¬{ t.elevation_ft == s.elevation_ft ∧ t.continent == s.continent }", + "¬{ t.elevation_ft == s.elevation_ft ∧ t.gps_code != s.gps_code }", + "¬{ t.elevation_ft == s.elevation_ft ∧ t.gps_code != s.local_code }", + "¬{ t.elevation_ft == s.elevation_ft ∧ t.gps_code == s.gps_code }", + "¬{ t.elevation_ft == s.elevation_ft ∧ t.iso_country != s.iso_country ∧ t.gps_code == " + "s.local_code ∧ t.local_code == s.local_code }", + "¬{ t.elevation_ft == s.elevation_ft ∧ t.iso_country == s.iso_country }", + "¬{ t.elevation_ft == s.elevation_ft ∧ t.local_code != s.local_code }", + "¬{ t.elevation_ft == s.elevation_ft ∧ t.municipality != s.municipality ∧ t.gps_code == " + "s.local_code }", + "¬{ t.elevation_ft > s.elevation_ft ∧ t.continent == s.continent ∧ t.gps_code == " + "s.local_code }", + "¬{ t.elevation_ft > s.elevation_ft ∧ t.iso_country != s.iso_country ∧ t.gps_code != " + "s.gps_code ∧ t.gps_code == s.local_code ∧ t.local_code != s.local_code }", + "¬{ t.elevation_ft > s.elevation_ft ∧ t.iso_region != s.iso_region ∧ t.gps_code != " + "s.gps_code ∧ t.gps_code == s.local_code ∧ t.local_code != s.local_code }", + "¬{ t.elevation_ft > s.elevation_ft ∧ t.municipality != s.municipality ∧ t.gps_code != " + "s.gps_code ∧ t.gps_code == s.local_code ∧ t.local_code != s.local_code }", + "¬{ t.elevation_ft >= s.elevation_ft ∧ t.continent != s.continent ∧ t.gps_code != " + "s.gps_code ∧ t.gps_code == s.local_code ∧ t.local_code != s.local_code }", + "¬{ t.elevation_ft >= s.elevation_ft ∧ t.continent == s.continent ∧ t.gps_code != " + "s.gps_code ∧ t.gps_code == s.local_code }", + "¬{ t.elevation_ft >= s.elevation_ft ∧ t.continent == s.continent ∧ t.gps_code == " + "s.local_code ∧ t.local_code == s.local_code }", + "¬{ t.elevation_ft >= s.elevation_ft ∧ t.continent == s.continent ∧ t.iso_country != " + "s.iso_country ∧ t.gps_code == s.local_code }", + "¬{ t.elevation_ft >= s.elevation_ft ∧ t.gps_code == s.gps_code ∧ t.gps_code != " + "s.local_code }", + "¬{ t.elevation_ft >= s.elevation_ft ∧ t.gps_code == s.gps_code ∧ t.gps_code == " + "s.local_code ∧ t.local_code != s.local_code }", + "¬{ t.gps_code == s.gps_code ∧ t.gps_code != s.local_code ∧ t.local_code == s.local_code }", + "¬{ t.ident == s.gps_code }", + "¬{ t.ident == s.ident }", + "¬{ t.ident == s.local_code }", + "¬{ t.iso_country != s.iso_country ∧ t.municipality == s.municipality }", + "¬{ t.iso_country == s.iso_country ∧ t.gps_code == s.gps_code }", + "¬{ t.iso_country == s.iso_country ∧ t.gps_code == s.local_code }", + "¬{ t.iso_country == s.iso_country ∧ t.local_code == s.local_code }", + "¬{ t.iso_country == s.iso_country ∧ t.municipality == s.municipality }", + "¬{ t.iso_region == s.iso_region }", + "¬{ t.municipality == s.municipality ∧ t.gps_code != s.gps_code }", + "¬{ t.municipality == s.municipality ∧ t.gps_code != s.local_code }", + "¬{ t.municipality == s.municipality ∧ t.gps_code == s.gps_code }", + "¬{ t.municipality == s.municipality ∧ t.gps_code == s.local_code }", + "¬{ t.municipality == s.municipality ∧ t.local_code != s.local_code }", + "¬{ t.municipality == s.municipality ∧ t.local_code == s.local_code }", + "¬{ t.name == s.name }", + "¬{ t.type != s.type ∧ t.continent == s.continent ∧ t.gps_code != s.gps_code ∧ t.gps_code " + "== s.local_code }", + "¬{ t.type != s.type ∧ t.continent == s.continent ∧ t.gps_code == s.gps_code }", + "¬{ t.type != s.type ∧ t.continent == s.continent ∧ t.gps_code == s.local_code ∧ " + "t.local_code == s.local_code }", + "¬{ t.type != s.type ∧ t.elevation_ft < s.elevation_ft ∧ t.continent != s.continent ∧ " + "t.gps_code == s.gps_code ∧ t.gps_code == s.local_code }", + "¬{ t.type != s.type ∧ t.elevation_ft < s.elevation_ft ∧ t.continent == s.continent ∧ " + "t.iso_country != s.iso_country ∧ t.local_code == s.local_code }", + "¬{ t.type != s.type ∧ t.elevation_ft < s.elevation_ft ∧ t.gps_code == s.gps_code ∧ " + "t.local_code == s.local_code }", + "¬{ t.type != s.type ∧ t.elevation_ft <= s.elevation_ft ∧ t.continent == s.continent ∧ " + "t.gps_code != s.gps_code ∧ t.local_code == s.local_code }", + "¬{ t.type != s.type ∧ t.elevation_ft <= s.elevation_ft ∧ t.continent == s.continent ∧ " + "t.gps_code != s.local_code ∧ t.local_code == s.local_code }", + "¬{ t.type != s.type ∧ t.elevation_ft <= s.elevation_ft ∧ t.continent == s.continent ∧ " + "t.gps_code == s.local_code }", + "¬{ t.type != s.type ∧ t.elevation_ft <= s.elevation_ft ∧ t.gps_code == s.gps_code ∧ " + "t.local_code != s.local_code }", + "¬{ t.type != s.type ∧ t.elevation_ft <= s.elevation_ft ∧ t.gps_code == s.local_code ∧ " + "t.local_code != s.local_code }", + "¬{ t.type != s.type ∧ t.elevation_ft == s.elevation_ft ∧ t.continent != s.continent }", + "¬{ t.type != s.type ∧ t.elevation_ft == s.elevation_ft ∧ t.gps_code == s.local_code }", + "¬{ t.type != s.type ∧ t.elevation_ft == s.elevation_ft ∧ t.iso_country != s.iso_country }", + "¬{ t.type != s.type ∧ t.elevation_ft == s.elevation_ft ∧ t.local_code == s.local_code }", + "¬{ t.type != s.type ∧ t.elevation_ft == s.elevation_ft ∧ t.municipality != s.municipality " + "}", + "¬{ t.type != s.type ∧ t.elevation_ft > s.elevation_ft ∧ t.continent != s.continent ∧ " + "t.gps_code != s.gps_code ∧ t.gps_code == s.local_code ∧ t.local_code == s.local_code }", + "¬{ t.type != s.type ∧ t.elevation_ft > s.elevation_ft ∧ t.iso_country != s.iso_country ∧ " + "t.gps_code == s.local_code ∧ t.local_code != s.local_code }", + "¬{ t.type != s.type ∧ t.elevation_ft >= s.elevation_ft ∧ t.continent != s.continent ∧ " + "t.gps_code == s.local_code ∧ t.local_code != s.local_code }", + "¬{ t.type != s.type ∧ t.elevation_ft >= s.elevation_ft ∧ t.continent != s.continent ∧ " + "t.municipality != s.municipality ∧ t.gps_code != s.gps_code ∧ t.gps_code == s.local_code " + "∧ t.local_code == s.local_code }", + "¬{ t.type != s.type ∧ t.elevation_ft >= s.elevation_ft ∧ t.continent == s.continent ∧ " + "t.gps_code != s.local_code ∧ t.local_code == s.local_code }", + "¬{ t.type != s.type ∧ t.elevation_ft >= s.elevation_ft ∧ t.continent == s.continent ∧ " + "t.gps_code == s.local_code }", + "¬{ t.type != s.type ∧ t.gps_code != s.gps_code ∧ t.gps_code == s.local_code ∧ " + "t.local_code != s.local_code }", + "¬{ t.type != s.type ∧ t.gps_code == s.gps_code ∧ t.gps_code != s.local_code }", + "¬{ t.type != s.type ∧ t.municipality == s.municipality }", + "¬{ t.type == s.type ∧ t.continent != s.continent ∧ t.gps_code == s.gps_code ∧ " + "t.local_code == s.local_code }", + "¬{ t.type == s.type ∧ t.continent == s.continent ∧ t.gps_code != s.gps_code ∧ t.gps_code " + "== s.local_code }", + "¬{ t.type == s.type ∧ t.continent == s.continent ∧ t.gps_code == s.gps_code }", + "¬{ t.type == s.type ∧ t.continent == s.continent ∧ t.gps_code == s.local_code ∧ " + "t.local_code == s.local_code }", + "¬{ t.type == s.type ∧ t.continent == s.continent ∧ t.iso_country != s.iso_country ∧ " + "t.gps_code != s.local_code ∧ t.local_code == s.local_code }", + "¬{ t.type == s.type ∧ t.continent == s.continent ∧ t.iso_country != s.iso_country ∧ " + "t.gps_code == s.local_code }", + "¬{ t.type == s.type ∧ t.continent == s.continent ∧ t.iso_region != s.iso_region ∧ " + "t.gps_code == s.local_code }", + "¬{ t.type == s.type ∧ t.continent == s.continent ∧ t.municipality != s.municipality ∧ " + "t.gps_code == s.local_code }", + "¬{ t.type == s.type ∧ t.elevation_ft != s.elevation_ft ∧ t.continent == s.continent ∧ " + "t.gps_code == s.local_code }", + "¬{ t.type == s.type ∧ t.elevation_ft != s.elevation_ft ∧ t.iso_country != s.iso_country ∧ " + "t.gps_code == s.gps_code ∧ t.local_code == s.local_code }", + "¬{ t.type == s.type ∧ t.elevation_ft != s.elevation_ft ∧ t.municipality != s.municipality " + "∧ t.gps_code == s.gps_code ∧ t.local_code == s.local_code }", + "¬{ t.type == s.type ∧ t.elevation_ft < s.elevation_ft ∧ t.continent != s.continent ∧ " + "t.gps_code != s.gps_code ∧ t.gps_code == s.local_code ∧ t.local_code == s.local_code }", + "¬{ t.type == s.type ∧ t.elevation_ft < s.elevation_ft ∧ t.continent != s.continent ∧ " + "t.gps_code == s.gps_code }", + "¬{ t.type == s.type ∧ t.elevation_ft < s.elevation_ft ∧ t.continent == s.continent ∧ " + "t.local_code == s.local_code }", + "¬{ t.type == s.type ∧ t.elevation_ft <= s.elevation_ft ∧ t.continent == s.continent ∧ " + "t.gps_code != s.gps_code ∧ t.local_code == s.local_code }", + "¬{ t.type == s.type ∧ t.elevation_ft <= s.elevation_ft ∧ t.continent == s.continent ∧ " + "t.gps_code != s.local_code ∧ t.local_code == s.local_code }", + "¬{ t.type == s.type ∧ t.elevation_ft <= s.elevation_ft ∧ t.continent == s.continent ∧ " + "t.gps_code == s.local_code }", + "¬{ t.type == s.type ∧ t.elevation_ft <= s.elevation_ft ∧ t.continent == s.continent ∧ " + "t.iso_country != s.iso_country ∧ t.local_code == s.local_code }", + "¬{ t.type == s.type ∧ t.elevation_ft <= s.elevation_ft ∧ t.continent == s.continent ∧ " + "t.municipality != s.municipality ∧ t.local_code == s.local_code }", + "¬{ t.type == s.type ∧ t.elevation_ft <= s.elevation_ft ∧ t.gps_code == s.gps_code ∧ " + "t.gps_code == s.local_code }", + "¬{ t.type == s.type ∧ t.elevation_ft <= s.elevation_ft ∧ t.gps_code == s.gps_code ∧ " + "t.local_code != s.local_code }", + "¬{ t.type == s.type ∧ t.elevation_ft <= s.elevation_ft ∧ t.gps_code == s.gps_code ∧ " + "t.local_code == s.local_code }", + "¬{ t.type == s.type ∧ t.elevation_ft <= s.elevation_ft ∧ t.gps_code == s.local_code ∧ " + "t.local_code != s.local_code }", + "¬{ t.type == s.type ∧ t.elevation_ft == s.elevation_ft }", + "¬{ t.type == s.type ∧ t.elevation_ft > s.elevation_ft ∧ t.continent != s.continent ∧ " + "t.gps_code != s.gps_code ∧ t.gps_code == s.local_code }", + "¬{ t.type == s.type ∧ t.elevation_ft > s.elevation_ft ∧ t.continent != s.continent ∧ " + "t.gps_code == s.local_code ∧ t.local_code == s.local_code }", + "¬{ t.type == s.type ∧ t.elevation_ft > s.elevation_ft ∧ t.gps_code == s.gps_code ∧ " + "t.gps_code == s.local_code }", + "¬{ t.type == s.type ∧ t.elevation_ft >= s.elevation_ft ∧ t.continent != s.continent ∧ " + "t.gps_code == s.gps_code ∧ t.gps_code == s.local_code }", + "¬{ t.type == s.type ∧ t.elevation_ft >= s.elevation_ft ∧ t.continent != s.continent ∧ " + "t.municipality != s.municipality ∧ t.gps_code != s.gps_code ∧ t.gps_code == s.local_code " + "}", + "¬{ t.type == s.type ∧ t.elevation_ft >= s.elevation_ft ∧ t.continent == s.continent ∧ " + "t.gps_code != s.local_code ∧ t.local_code == s.local_code }", + "¬{ t.type == s.type ∧ t.elevation_ft >= s.elevation_ft ∧ t.continent == s.continent ∧ " + "t.gps_code == s.local_code }", + "¬{ t.type == s.type ∧ t.elevation_ft >= s.elevation_ft ∧ t.gps_code != s.gps_code ∧ " + "t.gps_code == s.local_code ∧ t.local_code == s.local_code }", + "¬{ t.type == s.type ∧ t.elevation_ft >= s.elevation_ft ∧ t.gps_code == s.local_code ∧ " + "t.local_code != s.local_code }", + "¬{ t.type == s.type ∧ t.gps_code != s.gps_code ∧ t.gps_code == s.local_code ∧ " + "t.local_code != s.local_code }", + "¬{ t.type == s.type ∧ t.gps_code == s.gps_code ∧ t.gps_code != s.local_code }", + "¬{ t.type == s.type ∧ t.municipality == s.municipality }"};