From e62d16d7b1c42163de7b21ab74a780c3c1cf8e45 Mon Sep 17 00:00:00 2001 From: Arnur Nigmetov Date: Sat, 16 Oct 2021 13:01:59 -0700 Subject: Change example in matching distance --- matching/example/module_example.cpp | 88 +++++++++++++++++++++++-------------- 1 file changed, 55 insertions(+), 33 deletions(-) diff --git a/matching/example/module_example.cpp b/matching/example/module_example.cpp index aec38c2..6fa2e5a 100644 --- a/matching/example/module_example.cpp +++ b/matching/example/module_example.cpp @@ -5,61 +5,83 @@ using namespace md; int main(int /*argc*/, char** /*argv*/) { - // create generators. - // A generator is a point in plane, - // generators are stored in a vector of points: - PointVec gens_a; - - // module A will have one generator that appears at point (0, 0) - gens_a.emplace_back(0, 0); - - // relations are stored in a vector of relations using RelationVec = ModulePresentation::RelVec; + using Relation = ModulePresentation::Relation; + + // Module A (three rectangles) + PointVec gens_a; RelationVec rels_a; - // A relation is a struct with position and column - using Relation = ModulePresentation::Relation; - // at this point the relation rel_a_1 will appear: - Point rel_a_1_position { 1, 1 }; + // First rectangle + gens_a.emplace_back(-3, -1); - // vector IndexVec contains non-zero indices of the corresponding relation - // (we work over Z/2). Since we have one generator only, the relation - // contains only one entry, 0 + Point rel_a_1_position { -3, 3 }; IndexVec rel_a_1_components { 0 }; - - // construct a relation from position and column: Relation rel_a_1 { rel_a_1_position, rel_a_1_components }; - - // and add it to a vector of relations rels_a.push_back(rel_a_1); - // after populating vectors of generators and relations - // construct a module: - ModulePresentation module_a { gens_a, rels_a }; + Point rel_a_2_position { 1, -1 }; + IndexVec rel_a_2_components { 0 }; + Relation rel_a_2 { rel_a_2_position, rel_a_2_components }; + rels_a.push_back(rel_a_2); + // Second rectangle + gens_a.emplace_back(-1, -1); - // same for module_b. It will also have just one - // generator and one relation, but at different positions. + Point rel_a_3_position { -1, 1 }; + IndexVec rel_a_3_components { 1 }; + Relation rel_a_3 { rel_a_3_position, rel_a_3_components }; + rels_a.push_back(rel_a_3); - PointVec gens_b; - gens_b.emplace_back(1, 1); + Point rel_a_4_position { 1, -1 }; + IndexVec rel_a_4_components { 1 }; + Relation rel_a_4 { rel_a_4_position, rel_a_4_components }; + rels_a.push_back(rel_a_4); + // Third rectangle + gens_a.emplace_back(-1, -3); + + Point rel_a_5_position { -1, 1 }; + IndexVec rel_a_5_components { 2 }; + Relation rel_a_5 { rel_a_5_position, rel_a_5_components }; + rels_a.push_back(rel_a_5); + + Point rel_a_6_position { 3, -3 }; + IndexVec rel_a_6_components { 2 }; + Relation rel_a_6 { rel_a_6_position, rel_a_6_components }; + rels_a.push_back(rel_a_6); + + + ModulePresentation module_a { gens_a, rels_a }; + + + // Module B (one rectangle) + PointVec gens_b; RelationVec rels_b; - Point rel_b_1_position { 2, 2 }; + // Rectangle + gens_b.emplace_back(-2, -2); + + Point rel_b_1_position { -2, 2 }; IndexVec rel_b_1_components { 0 }; + Relation rel_b_1 { rel_b_1_position, rel_b_1_components }; + rels_b.push_back(rel_b_1); + + Point rel_b_2_position { 2, -2 }; + IndexVec rel_b_2_components { 0 }; + Relation rel_b_2 { rel_b_2_position, rel_b_2_components }; + rels_b.push_back(rel_b_2); - rels_b.emplace_back(rel_b_1_position, rel_b_1_components); ModulePresentation module_b { gens_b, rels_b }; - // create CalculationParams + + // Computations CalculationParams params; - // set relative error to 10 % : params.delta = 0.1; - // go at most 8 levels deep in quadtree: - params.max_depth = 8; + params.max_depth = 5; + params.initialization_depth = 0; double dist = matching_distance(module_a, module_b, params); std::cout << "dist = " << dist << std::endl; -- cgit v1.2.3