synkit 1.6.5__py3-none-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- synkit/CRN/Benchmark/__init__.py +53 -0
- synkit/CRN/Benchmark/crosschecks.py +13 -0
- synkit/CRN/Benchmark/kegg.py +12 -0
- synkit/CRN/Benchmark/networks.py +13 -0
- synkit/CRN/Benchmark/scaling.py +13 -0
- synkit/CRN/Benchmark/validate.py +13 -0
- synkit/CRN/Construct/__init__.py +16 -0
- synkit/CRN/Construct/abstract.py +668 -0
- synkit/CRN/Construct/arity.py +36 -0
- synkit/CRN/Construct/builder.py +619 -0
- synkit/CRN/Construct/derivation.py +63 -0
- synkit/CRN/Construct/flattener.py +100 -0
- synkit/CRN/Construct/keys.py +14 -0
- synkit/CRN/Construct/mixtures.py +117 -0
- synkit/CRN/Construct/rdkit_worker.py +69 -0
- synkit/CRN/Construct/smiles.py +99 -0
- synkit/CRN/Construct/state.py +31 -0
- synkit/CRN/Construct/strategy.py +75 -0
- synkit/CRN/Construct/worker.py +42 -0
- synkit/CRN/IO/__init__.py +36 -0
- synkit/CRN/IO/sbml.py +925 -0
- synkit/CRN/Pathway/__init__.py +72 -0
- synkit/CRN/Pathway/_adapter.py +333 -0
- synkit/CRN/Pathway/pathfinder.py +500 -0
- synkit/CRN/Pathway/reachability.py +796 -0
- synkit/CRN/Pathway/realizability.py +1322 -0
- synkit/CRN/Petrinet/__init__.py +93 -0
- synkit/CRN/Petrinet/analyzer.py +486 -0
- synkit/CRN/Petrinet/minimal_semiflows.py +436 -0
- synkit/CRN/Petrinet/net.py +1041 -0
- synkit/CRN/Petrinet/persistence.py +97 -0
- synkit/CRN/Petrinet/semiflows.py +483 -0
- synkit/CRN/Petrinet/siphon_search.py +402 -0
- synkit/CRN/Petrinet/structure.py +286 -0
- synkit/CRN/Props/__init__.py +130 -0
- synkit/CRN/Props/_rank.py +29 -0
- synkit/CRN/Props/deficiency.py +953 -0
- synkit/CRN/Props/dynamics.py +832 -0
- synkit/CRN/Props/helper.py +151 -0
- synkit/CRN/Props/stoich.py +751 -0
- synkit/CRN/Props/thermo.py +584 -0
- synkit/CRN/Query/__init__.py +66 -0
- synkit/CRN/Query/cache.py +41 -0
- synkit/CRN/Query/kegg_api.py +99 -0
- synkit/CRN/Query/kegg_extract.py +714 -0
- synkit/CRN/Query/kegg_impute.py +707 -0
- synkit/CRN/Query/kegg_parse.py +480 -0
- synkit/CRN/Query/to_syncrn.py +290 -0
- synkit/CRN/README.md +234 -0
- synkit/CRN/Structure/__init__.py +12 -0
- synkit/CRN/Structure/_graph_io.py +713 -0
- synkit/CRN/Structure/_matrices.py +88 -0
- synkit/CRN/Structure/_parse.py +544 -0
- synkit/CRN/Structure/reaction.py +237 -0
- synkit/CRN/Structure/rule.py +55 -0
- synkit/CRN/Structure/species.py +46 -0
- synkit/CRN/Structure/syncrn.py +929 -0
- synkit/CRN/Symmetry/__init__.py +20 -0
- synkit/CRN/Symmetry/_common.py +1059 -0
- synkit/CRN/Symmetry/_ir.py +940 -0
- synkit/CRN/Symmetry/automorphism.py +472 -0
- synkit/CRN/Symmetry/canon.py +441 -0
- synkit/CRN/Symmetry/isomorphism.py +412 -0
- synkit/CRN/Symmetry/symmetry.py +61 -0
- synkit/CRN/Symmetry/wl_canon.py +967 -0
- synkit/CRN/Visualize/__init__.py +11 -0
- synkit/CRN/Visualize/labels.py +113 -0
- synkit/CRN/Visualize/layout.py +708 -0
- synkit/CRN/Visualize/palette.py +292 -0
- synkit/CRN/Visualize/validation.py +122 -0
- synkit/CRN/Visualize/vis.py +1152 -0
- synkit/CRN/__init__.py +233 -0
- synkit/CRN/_build.py +50 -0
- synkit/CRN/_native_build.py +175 -0
- synkit/CRN/analysis.py +629 -0
- synkit/CRN/backend.py +74 -0
- synkit/CRN/cpp/CMakeLists.txt +58 -0
- synkit/CRN/cpp/algebra.cpp +46 -0
- synkit/CRN/cpp/closure.cpp +29 -0
- synkit/CRN/cpp/exact.h +55 -0
- synkit/CRN/cpp/pathway.cpp +46 -0
- synkit/CRN/cpp/semiflows.cpp +209 -0
- synkit/CRN/cpp/structural.cpp +240 -0
- synkit/CRN/cpp/symmetry.cpp +45 -0
- synkit/CRN/cpp/write_manifest.cmake +28 -0
- synkit/CRN/kinds.py +137 -0
- synkit/CRN/lib/synkit_crn.dll +0 -0
- synkit/CRN/lib/synkit_crn.json +33 -0
- synkit/CRN/native.py +388 -0
- synkit/CRN/native_analysis.py +459 -0
- synkit/Chem/Cluster/__init__.py +0 -0
- synkit/Chem/Cluster/butina.py +140 -0
- synkit/Chem/Fingerprint/__init__.py +0 -0
- synkit/Chem/Fingerprint/fp_calculator.py +155 -0
- synkit/Chem/Fingerprint/smiles_featurizer.py +258 -0
- synkit/Chem/Fingerprint/transformation_fp.py +139 -0
- synkit/Chem/Mapper/README.rst +43 -0
- synkit/Chem/Mapper/__init__.py +255 -0
- synkit/Chem/Mapper/_compat.py +130 -0
- synkit/Chem/Mapper/adapters/__init__.py +1 -0
- synkit/Chem/Mapper/adapters/prediction.py +126 -0
- synkit/Chem/Mapper/adapters/template.py +412 -0
- synkit/Chem/Mapper/chem/__init__.py +52 -0
- synkit/Chem/Mapper/chem/aam.py +673 -0
- synkit/Chem/Mapper/chem/blind.py +160 -0
- synkit/Chem/Mapper/chem/its.py +309 -0
- synkit/Chem/Mapper/chem/smiles.py +564 -0
- synkit/Chem/Mapper/graph/__init__.py +66 -0
- synkit/Chem/Mapper/graph/automorphism.py +395 -0
- synkit/Chem/Mapper/graph/blockcut.py +98 -0
- synkit/Chem/Mapper/graph/labeled_graph.py +104 -0
- synkit/Chem/Mapper/graph/refine.py +176 -0
- synkit/Chem/Mapper/graph/synkit_adapter.py +110 -0
- synkit/Chem/Mapper/io/__init__.py +13 -0
- synkit/Chem/Mapper/io/idxmapstr.py +82 -0
- synkit/Chem/Mapper/mapper.py +685 -0
- synkit/Chem/Mapper/reaction_search.py +554 -0
- synkit/Chem/Mapper/reporting/__init__.py +1 -0
- synkit/Chem/Mapper/reporting/alternatives.py +451 -0
- synkit/Chem/Mapper/reporting/analysis.py +681 -0
- synkit/Chem/Mapper/reporting/native_analysis.py +485 -0
- synkit/Chem/Mapper/reporting/spectrum.py +642 -0
- synkit/Chem/Mapper/solvers/__init__.py +1 -0
- synkit/Chem/Mapper/solvers/exact/__init__.py +141 -0
- synkit/Chem/Mapper/solvers/exact/assignment/__init__.py +1 -0
- synkit/Chem/Mapper/solvers/exact/assignment/assignment_certificate.py +113 -0
- synkit/Chem/Mapper/solvers/exact/assignment/assignment_domains.py +162 -0
- synkit/Chem/Mapper/solvers/exact/assignment/assignment_verification.py +58 -0
- synkit/Chem/Mapper/solvers/exact/assignment/incremental_assignment.py +247 -0
- synkit/Chem/Mapper/solvers/exact/certificate.py +128 -0
- synkit/Chem/Mapper/solvers/exact/core.py +183 -0
- synkit/Chem/Mapper/solvers/exact/distance_search/__init__.py +1 -0
- synkit/Chem/Mapper/solvers/exact/distance_search/bounds.py +319 -0
- synkit/Chem/Mapper/solvers/exact/distance_search/exhaustive.py +179 -0
- synkit/Chem/Mapper/solvers/exact/distance_search/inputs.py +283 -0
- synkit/Chem/Mapper/solvers/exact/distance_search/records.py +242 -0
- synkit/Chem/Mapper/solvers/exact/distance_search/search.py +1025 -0
- synkit/Chem/Mapper/solvers/exact/distance_search/verify.py +378 -0
- synkit/Chem/Mapper/solvers/exact/edit_support.py +375 -0
- synkit/Chem/Mapper/solvers/exact/hybrid.py +224 -0
- synkit/Chem/Mapper/solvers/exact/hydrogen.py +264 -0
- synkit/Chem/Mapper/solvers/exact/kernel_solvers/__init__.py +1 -0
- synkit/Chem/Mapper/solvers/exact/kernel_solvers/branching.py +499 -0
- synkit/Chem/Mapper/solvers/exact/kernel_solvers/enumerate.py +1050 -0
- synkit/Chem/Mapper/solvers/exact/kernel_solvers/enumeration_result.py +30 -0
- synkit/Chem/Mapper/solvers/exact/kernel_solvers/kernel.py +256 -0
- synkit/Chem/Mapper/solvers/exact/kernel_solvers/milp.py +194 -0
- synkit/Chem/Mapper/solvers/exact/native/__init__.py +1 -0
- synkit/Chem/Mapper/solvers/exact/native/build.py +154 -0
- synkit/Chem/Mapper/solvers/exact/native/candidates.py +593 -0
- synkit/Chem/Mapper/solvers/exact/native/canonical.py +396 -0
- synkit/Chem/Mapper/solvers/exact/native/disk_frontier.py +415 -0
- synkit/Chem/Mapper/solvers/exact/native/frontier.py +390 -0
- synkit/Chem/Mapper/solvers/exact/native/hydrogen_quotient.py +213 -0
- synkit/Chem/Mapper/solvers/exact/native/its.py +528 -0
- synkit/Chem/Mapper/solvers/exact/native/native_distance.cpp +2803 -0
- synkit/Chem/Mapper/solvers/exact/native/orbit_aggregation.py +328 -0
- synkit/Chem/Mapper/solvers/exact/native/parallel.py +205 -0
- synkit/Chem/Mapper/solvers/exact/native/pmcd.py +203 -0
- synkit/Chem/Mapper/solvers/exact/native/runtime.py +40 -0
- synkit/Chem/Mapper/solvers/exact/native/search.py +294 -0
- synkit/Chem/Mapper/solvers/exact/native/separator.py +224 -0
- synkit/Chem/Mapper/solvers/exact/native_build.py +12 -0
- synkit/Chem/Mapper/solvers/exact/pabs/__init__.py +1 -0
- synkit/Chem/Mapper/solvers/exact/pabs/cost_lattice.py +43 -0
- synkit/Chem/Mapper/solvers/exact/pabs/factor_spectrum.py +110 -0
- synkit/Chem/Mapper/solvers/exact/pabs/multi_shell.py +368 -0
- synkit/Chem/Mapper/solvers/exact/pabs/propagation.py +679 -0
- synkit/Chem/Mapper/solvers/exact/pabs/propagation_bounds.py +436 -0
- synkit/Chem/Mapper/solvers/exact/pabs/propagation_limits.py +13 -0
- synkit/Chem/Mapper/solvers/exact/pabs/propagation_search.py +856 -0
- synkit/Chem/Mapper/solvers/exact/pabs/propagation_symmetry.py +66 -0
- synkit/Chem/Mapper/solvers/exact/pabs/residual_typed_bonds.py +136 -0
- synkit/Chem/Mapper/solvers/exact/pabs/reward_frontier.py +201 -0
- synkit/Chem/Mapper/solvers/exact/pabs/separator_bound.py +258 -0
- synkit/Chem/Mapper/solvers/exact/pabs/separator_spectrum.py +308 -0
- synkit/Chem/Mapper/solvers/exact/pabs/sparse_reward_bound.py +207 -0
- synkit/Chem/Mapper/solvers/exact/pabs/suffix_spectrum.py +299 -0
- synkit/Chem/Mapper/solvers/exact/search.py +55 -0
- synkit/Chem/Mapper/solvers/exact/seeds/__init__.py +1 -0
- synkit/Chem/Mapper/solvers/exact/seeds/seed.py +104 -0
- synkit/Chem/Mapper/solvers/exact/seeds/seed_fragments.py +148 -0
- synkit/Chem/Mapper/solvers/exact/seeds/seed_relaxation.py +181 -0
- synkit/Chem/Mapper/solvers/exact/symmetry.py +223 -0
- synkit/Chem/Mapper/solvers/native/__init__.py +4 -0
- synkit/Chem/Mapper/solvers/native/assignment.py +99 -0
- synkit/Chem/Mapper/solvers/native/astar.py +22 -0
- synkit/Chem/Mapper/solvers/native/build.py +385 -0
- synkit/Chem/Mapper/solvers/native/classification.py +641 -0
- synkit/Chem/Mapper/solvers/native/core.py +378 -0
- synkit/Chem/Mapper/solvers/native/cpp/CMakeLists.txt +120 -0
- synkit/Chem/Mapper/solvers/native/cpp/examples/map_reaction.cpp +29 -0
- synkit/Chem/Mapper/solvers/native/cpp/examples/slap_graph.cpp +63 -0
- synkit/Chem/Mapper/solvers/native/cpp/include/synkit_mapper/assignment/assignment.h +18 -0
- synkit/Chem/Mapper/solvers/native/cpp/include/synkit_mapper/astar/astar.h +18 -0
- synkit/Chem/Mapper/solvers/native/cpp/include/synkit_mapper/astar/bound.h +33 -0
- synkit/Chem/Mapper/solvers/native/cpp/include/synkit_mapper/core/pmcd_witness.h +16 -0
- synkit/Chem/Mapper/solvers/native/cpp/include/synkit_mapper/core/runtime.h +130 -0
- synkit/Chem/Mapper/solvers/native/cpp/include/synkit_mapper/hydrogen/hydrogen.h +73 -0
- synkit/Chem/Mapper/solvers/native/cpp/include/synkit_mapper/mapper.h +175 -0
- synkit/Chem/Mapper/solvers/native/cpp/include/synkit_mapper/mces/mces.h +9 -0
- synkit/Chem/Mapper/solvers/native/cpp/include/synkit_mapper/pabs/seed.h +34 -0
- synkit/Chem/Mapper/solvers/native/cpp/include/synkit_mapper/reaction/reaction.h +30 -0
- synkit/Chem/Mapper/solvers/native/cpp/include/synkit_mapper/sepdp/sepdp.h +21 -0
- synkit/Chem/Mapper/solvers/native/cpp/include/synkit_mapper/slap.h +72 -0
- synkit/Chem/Mapper/solvers/native/cpp/include/synkit_mapper/solvers/solvers.h +16 -0
- synkit/Chem/Mapper/solvers/native/cpp/include/synkit_mapper/symmetry/classification.h +140 -0
- synkit/Chem/Mapper/solvers/native/cpp/include/synkit_mapper/symmetry/cpabs.h +33 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/assignment/abb.cpp +302 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/astar/CMakeLists.txt +12 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/astar/README.md +47 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/astar/astar.cpp +228 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/astar/astar_graph.cpp +37 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/astar/bound.cpp +212 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/core/dispatch.cpp +272 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/core/pmcd_witness.cpp +36 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/hydrogen/hydrogen.cpp +380 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/mces/README.md +57 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/mces/mces.cpp +287 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/pabs/bridge.cpp +334 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/pabs/chemical_floor.inc +181 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/pabs/endpoint_symmetry.inc +104 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/pabs/exact_helpers.h +20 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/pabs/lp_assignment_certificate.h +165 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/pabs/lp_certificate.h +125 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/pabs/lp_model.h +365 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/pabs/lp_provider.inc +319 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/pabs/lp_rounding.inc +170 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/pabs/lp_test_hooks.h +342 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/pabs/objective_reduction.inc +137 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/pabs/overlap_dual.inc +351 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/pabs/profile_seed.inc +214 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/pabs/seed_heuristics.inc +640 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/pabs/sparse_embedding.cpp +430 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/pabs/sparse_root_lp.h +176 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/pabs/test_hooks.inc +262 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/reaction/reaction.cpp +611 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/sepdp/README.md +61 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/sepdp/sepdp.cpp +253 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/slap.cpp +810 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/solvers/formulation.h +138 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/solvers/maxsat.cpp +526 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/solvers/ortools.cpp +475 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/solvers/seed.h +80 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/solvers/weighted_cnf.h +256 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/supporting/README.md +43 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/supporting/dfs.cpp +123 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/supporting/edit_support.cpp +224 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/symmetry/classification.cpp +553 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/symmetry/classification_pipeline.cpp +124 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/symmetry/classification_stream.h +13 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/symmetry/cpabs.cpp +455 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/symmetry/edge_deck.cpp +743 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/symmetry/vendor/nauty/COPYRIGHT +44 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/symmetry/vendor/nauty/LICENSE-2.0.txt +202 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/symmetry/vendor/nauty/naugraph.c +732 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/symmetry/vendor/nauty/naurng.c +94 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/symmetry/vendor/nauty/naurng.h +49 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/symmetry/vendor/nauty/nausparse.c +1771 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/symmetry/vendor/nauty/nausparse.h +133 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/symmetry/vendor/nauty/nautil.c +750 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/symmetry/vendor/nauty/naututil.h +355 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/symmetry/vendor/nauty/nauty.c +1256 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/symmetry/vendor/nauty/nauty.h +1544 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/symmetry/vendor/nauty/schreier.c +1131 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/symmetry/vendor/nauty/schreier.h +70 -0
- synkit/Chem/Mapper/solvers/native/cpp/src/symmetry/vendor/nauty/sorttemplates.c +580 -0
- synkit/Chem/Mapper/solvers/native/hydrogen.py +711 -0
- synkit/Chem/Mapper/solvers/native/implicit.py +506 -0
- synkit/Chem/Mapper/solvers/native/implicit_certificate.py +187 -0
- synkit/Chem/Mapper/solvers/native/implicit_preparation.py +309 -0
- synkit/Chem/Mapper/solvers/native/lib/synkit_mapper.dll +0 -0
- synkit/Chem/Mapper/solvers/native/mces.py +16 -0
- synkit/Chem/Mapper/solvers/native/reaction.py +179 -0
- synkit/Chem/Mapper/solvers/native/reaction_build.py +277 -0
- synkit/Chem/Mapper/solvers/native/reaction_text.py +26 -0
- synkit/Chem/Mapper/solvers/native/runtime.py +242 -0
- synkit/Chem/Mapper/solvers/native/sepdp.py +47 -0
- synkit/Chem/Mapper/solvers/native/slap.py +266 -0
- synkit/Chem/Mapper/solvers/native/solvers.py +67 -0
- synkit/Chem/Mapper/solvers/native/stereo.py +86 -0
- synkit/Chem/Mapper/solvers/native/supporting.py +34 -0
- synkit/Chem/Mapper/solvers/native/symmetry.py +91 -0
- synkit/Chem/Mapper/solvers/slap/__init__.py +29 -0
- synkit/Chem/Mapper/solvers/slap/lap.py +174 -0
- synkit/Chem/Mapper/solvers/slap/sequential.py +696 -0
- synkit/Chem/Mapper/validation/__init__.py +1 -0
- synkit/Chem/Mapper/validation/aam_validator.py +442 -0
- synkit/Chem/Mapper/validation/annotations.py +274 -0
- synkit/Chem/Mapper/validation/bonds.py +124 -0
- synkit/Chem/Mapper/validation/cohorts.py +72 -0
- synkit/Chem/Mapper/validation/identifiability.py +150 -0
- synkit/Chem/Mapper/validation/numerical_scope.py +36 -0
- synkit/Chem/Mapper/validation/orbits.py +137 -0
- synkit/Chem/Molecule/__init__.py +0 -0
- synkit/Chem/Molecule/_chirality_loci.py +165 -0
- synkit/Chem/Molecule/_chirality_types.py +231 -0
- synkit/Chem/Molecule/_helical_loci.py +167 -0
- synkit/Chem/Molecule/_stereo_axis_evidence.py +202 -0
- synkit/Chem/Molecule/_stereo_element_detection.py +193 -0
- synkit/Chem/Molecule/_stereo_orientation_constraints.py +511 -0
- synkit/Chem/Molecule/_tetrahedral_carriers.py +63 -0
- synkit/Chem/Molecule/atom_features.py +379 -0
- synkit/Chem/Molecule/chirality.py +1041 -0
- synkit/Chem/Molecule/cip_assignment.py +569 -0
- synkit/Chem/Molecule/cip_ranking.py +843 -0
- synkit/Chem/Molecule/coordinate_stereo.py +503 -0
- synkit/Chem/Molecule/derived_stereo_naming.py +165 -0
- synkit/Chem/Molecule/descriptors.py +452 -0
- synkit/Chem/Molecule/formula.py +249 -0
- synkit/Chem/Molecule/global_stereo.py +175 -0
- synkit/Chem/Molecule/graph_annotator.py +300 -0
- synkit/Chem/Molecule/standardize.py +817 -0
- synkit/Chem/Molecule/stereo_evidence.py +179 -0
- synkit/Chem/Molecule/stereo_perception.py +1032 -0
- synkit/Chem/Molecule/valence.py +123 -0
- synkit/Chem/Reaction/Mapper/__init__.py +44 -0
- synkit/Chem/Reaction/__init__.py +20 -0
- synkit/Chem/Reaction/aam_validator.py +5 -0
- synkit/Chem/Reaction/balance_check.py +138 -0
- synkit/Chem/Reaction/canon_rsmi.py +249 -0
- synkit/Chem/Reaction/cleaning.py +58 -0
- synkit/Chem/Reaction/deionize.py +199 -0
- synkit/Chem/Reaction/explicit_h_audit.py +232 -0
- synkit/Chem/Reaction/fix_aam.py +64 -0
- synkit/Chem/Reaction/neutralize.py +207 -0
- synkit/Chem/Reaction/radical_wildcard.py +224 -0
- synkit/Chem/Reaction/standardize.py +203 -0
- synkit/Chem/Reaction/tautomerize.py +205 -0
- synkit/Chem/__init__.py +1 -0
- synkit/Chem/utils.py +315 -0
- synkit/Data/__init__.py +0 -0
- synkit/Data/aldol.json.gz +1 -0
- synkit/Data/gen_partial_aam.py +147 -0
- synkit/Data/paracetamol.json.gz +1 -0
- synkit/Graph/Canon/__init__.py +16 -0
- synkit/Graph/Canon/_native/__init__.py +13 -0
- synkit/Graph/Canon/_native/build.py +93 -0
- synkit/Graph/Canon/_native/lib/synkit_canon.dll +0 -0
- synkit/Graph/Canon/_native/prepare.py +49 -0
- synkit/Graph/Canon/_native/runtime.py +140 -0
- synkit/Graph/Canon/_native/search.py +137 -0
- synkit/Graph/Canon/canon_algs.py +228 -0
- synkit/Graph/Canon/canon_graph.py +531 -0
- synkit/Graph/Canon/cpp/CMakeLists.txt +42 -0
- synkit/Graph/Canon/cpp/README.md +123 -0
- synkit/Graph/Canon/cpp/examples/canonical_graph.cpp +16 -0
- synkit/Graph/Canon/cpp/include/synkit_canon/canon.h +85 -0
- synkit/Graph/Canon/cpp/src/canonical.cpp +391 -0
- synkit/Graph/Canon/cpp/src/symmetry.h +83 -0
- synkit/Graph/Canon/cpp/tests/symmetry.cpp +93 -0
- synkit/Graph/Canon/exact.py +1020 -0
- synkit/Graph/Canon/exact_refinement.py +368 -0
- synkit/Graph/Canon/nauty.py +143 -0
- synkit/Graph/Context/__init__.py +0 -0
- synkit/Graph/Context/hier_context.py +244 -0
- synkit/Graph/Context/radius_expand.py +252 -0
- synkit/Graph/FG/__init__.py +19 -0
- synkit/Graph/FG/api.py +39 -0
- synkit/Graph/FG/audit.py +155 -0
- synkit/Graph/FG/catalog.py +919 -0
- synkit/Graph/FG/detector.py +288 -0
- synkit/Graph/FG/model.py +97 -0
- synkit/Graph/FG/recognizers.py +274 -0
- synkit/Graph/FG/ring_system.py +154 -0
- synkit/Graph/Feature/Descriptors/topology.py +857 -0
- synkit/Graph/Feature/Fingerprint/__init__.py +0 -0
- synkit/Graph/Feature/Fingerprint/wl_rxn_fps.py +222 -0
- synkit/Graph/Feature/__init__.py +5 -0
- synkit/Graph/Feature/graph_descriptors.py +323 -0
- synkit/Graph/Feature/graph_fps.py +96 -0
- synkit/Graph/Feature/graph_signature.py +239 -0
- synkit/Graph/Feature/hash_fps.py +133 -0
- synkit/Graph/Feature/morgan_fps.py +88 -0
- synkit/Graph/Feature/path_fps.py +81 -0
- synkit/Graph/Feature/wl_hash.py +134 -0
- synkit/Graph/Fusion/__init__.py +85 -0
- synkit/Graph/Fusion/candidate.py +559 -0
- synkit/Graph/Fusion/constructor.py +877 -0
- synkit/Graph/Fusion/identity.py +184 -0
- synkit/Graph/Fusion/interface.py +700 -0
- synkit/Graph/Fusion/search.py +241 -0
- synkit/Graph/Hyrogen/__init__.py +6 -0
- synkit/Graph/Hyrogen/_misc.py +591 -0
- synkit/Graph/Hyrogen/hcomplete.py +995 -0
- synkit/Graph/Hyrogen/hcomplete_legacy.py +368 -0
- synkit/Graph/Hyrogen/hcompletion_algorithms.py +713 -0
- synkit/Graph/Hyrogen/hextend.py +570 -0
- synkit/Graph/Hyrogen/hextend_legacy.py +215 -0
- synkit/Graph/ITS/__init__.py +4 -0
- synkit/Graph/ITS/its_builder.py +120 -0
- synkit/Graph/ITS/its_construction.py +719 -0
- synkit/Graph/ITS/its_decompose.py +572 -0
- synkit/Graph/ITS/its_destruction.py +331 -0
- synkit/Graph/ITS/its_expand.py +1251 -0
- synkit/Graph/ITS/its_relabel.py +187 -0
- synkit/Graph/ITS/its_reverter.py +356 -0
- synkit/Graph/ITS/normalize_aam.py +145 -0
- synkit/Graph/ITS/partial_its.py +238 -0
- synkit/Graph/ITS/rc_extractor.py +656 -0
- synkit/Graph/ITS/stereo.py +74 -0
- synkit/Graph/MTG/__init__.py +107 -0
- synkit/Graph/MTG/gluing.py +451 -0
- synkit/Graph/MTG/history.py +928 -0
- synkit/Graph/MTG/inventory.py +118 -0
- synkit/Graph/MTG/local.py +447 -0
- synkit/Graph/MTG/mcs_matcher.py +246 -0
- synkit/Graph/MTG/mtg.py +611 -0
- synkit/Graph/MTG/mtg_explore.py +74 -0
- synkit/Graph/MTG/observation.py +209 -0
- synkit/Graph/MTG/process.py +577 -0
- synkit/Graph/MTG/queries.py +66 -0
- synkit/Graph/MTG/realization.py +95 -0
- synkit/Graph/MTG/series_parallel.py +107 -0
- synkit/Graph/MTG/utils.py +424 -0
- synkit/Graph/Matcher/__init__.py +10 -0
- synkit/Graph/Matcher/approx_mcs.py +1264 -0
- synkit/Graph/Matcher/auto_est.py +736 -0
- synkit/Graph/Matcher/automorphism.py +314 -0
- synkit/Graph/Matcher/batch_cluster.py +224 -0
- synkit/Graph/Matcher/dedup_matches.py +247 -0
- synkit/Graph/Matcher/graph_cluster.py +191 -0
- synkit/Graph/Matcher/graph_matcher.py +312 -0
- synkit/Graph/Matcher/graph_morphism.py +421 -0
- synkit/Graph/Matcher/mcs_matcher.py +804 -0
- synkit/Graph/Matcher/multi_turbo_iso.py +186 -0
- synkit/Graph/Matcher/orbit.py +284 -0
- synkit/Graph/Matcher/partial_matcher.py +694 -0
- synkit/Graph/Matcher/sing.py +544 -0
- synkit/Graph/Matcher/subgraph_matcher.py +812 -0
- synkit/Graph/Matcher/turbo_iso.py +272 -0
- synkit/Graph/Matcher/wl_sel.py +537 -0
- synkit/Graph/Mech/__init__.py +26 -0
- synkit/Graph/Mech/conversion.py +1466 -0
- synkit/Graph/Mech/conversion_debug.py +237 -0
- synkit/Graph/Mech/electron_accounting.py +200 -0
- synkit/Graph/Mech/lwg_editor.py +406 -0
- synkit/Graph/Mech/lwg_ops.py +313 -0
- synkit/Graph/Morphism/__init__.py +99 -0
- synkit/Graph/Morphism/constraints.py +460 -0
- synkit/Graph/Morphism/llg.py +999 -0
- synkit/Graph/Morphism/morphism.py +349 -0
- synkit/Graph/Morphism/stereo.py +258 -0
- synkit/Graph/Morphism/stereo_morphism.py +383 -0
- synkit/Graph/Morphism/stereo_morphism_helpers.py +957 -0
- synkit/Graph/Morphism/stereo_morphism_types.py +117 -0
- synkit/Graph/Stereo/__init__.py +376 -0
- synkit/Graph/Stereo/_descriptor_core.py +207 -0
- synkit/Graph/Stereo/_descriptor_serialization.py +138 -0
- synkit/Graph/Stereo/canonical.py +648 -0
- synkit/Graph/Stereo/changes.py +964 -0
- synkit/Graph/Stereo/composition.py +391 -0
- synkit/Graph/Stereo/configured.py +946 -0
- synkit/Graph/Stereo/couplings.py +245 -0
- synkit/Graph/Stereo/descriptors.py +1030 -0
- synkit/Graph/Stereo/enumeration.py +597 -0
- synkit/Graph/Stereo/extended_descriptors.py +406 -0
- synkit/Graph/Stereo/global_configured.py +152 -0
- synkit/Graph/Stereo/global_stereo.py +304 -0
- synkit/Graph/Stereo/identity.py +648 -0
- synkit/Graph/Stereo/interchange.py +496 -0
- synkit/Graph/Stereo/legacy.py +460 -0
- synkit/Graph/Stereo/matching.py +899 -0
- synkit/Graph/Stereo/native.py +154 -0
- synkit/Graph/Stereo/orbits.py +668 -0
- synkit/Graph/Stereo/outcomes.py +99 -0
- synkit/Graph/Stereo/pairwise.py +350 -0
- synkit/Graph/Stereo/rdkit_adapter.py +662 -0
- synkit/Graph/Stereo/rdkit_identity.py +118 -0
- synkit/Graph/Stereo/rdkit_resonance.py +140 -0
- synkit/Graph/Stereo/reaction_interchange.py +266 -0
- synkit/Graph/Stereo/semantics.py +296 -0
- synkit/Graph/Stereo/supports.py +257 -0
- synkit/Graph/Stereo/wire.py +339 -0
- synkit/Graph/Wildcard/__init__.py +0 -0
- synkit/Graph/Wildcard/fuse_graph.py +156 -0
- synkit/Graph/Wildcard/graph_wc.py +303 -0
- synkit/Graph/Wildcard/its_merge.py +857 -0
- synkit/Graph/Wildcard/radwc.py +114 -0
- synkit/Graph/Wildcard/wc_matcher.py +576 -0
- synkit/Graph/Wildcard/wildcard.py +225 -0
- synkit/Graph/__init__.py +17 -0
- synkit/Graph/canon_graph.py +14 -0
- synkit/Graph/syn_graph.py +199 -0
- synkit/Graph/utils.py +324 -0
- synkit/IO/__init__.py +4 -0
- synkit/IO/chem_converter.py +1059 -0
- synkit/IO/combinatorial/__init__.py +8 -0
- synkit/IO/combinatorial/gml_to_graph.py +223 -0
- synkit/IO/combinatorial/graph_to_gml.py +280 -0
- synkit/IO/combinatorial/graph_to_smarts.py +186 -0
- synkit/IO/combinatorial/smarts_expander.py +147 -0
- synkit/IO/combinatorial/smarts_generalizer.py +133 -0
- synkit/IO/combinatorial/smarts_to_graph.py +179 -0
- synkit/IO/conversion.py +42 -0
- synkit/IO/data_io.py +269 -0
- synkit/IO/data_process.py +143 -0
- synkit/IO/debug.py +73 -0
- synkit/IO/gml_to_nx.py +150 -0
- synkit/IO/graph_to_mol.py +199 -0
- synkit/IO/mol_to_graph.py +1105 -0
- synkit/IO/mol_to_graph_chemistry.py +545 -0
- synkit/IO/nx_to_gml.py +209 -0
- synkit/IO/smiles_to_id.py +123 -0
- synkit/Mechanism/__init__.py +151 -0
- synkit/Mechanism/adapters.py +136 -0
- synkit/Mechanism/audit.py +323 -0
- synkit/Mechanism/benchmark.py +638 -0
- synkit/Mechanism/compatibility.py +13 -0
- synkit/Mechanism/drawing.py +85 -0
- synkit/Mechanism/electron_models.py +725 -0
- synkit/Mechanism/equivalence.py +521 -0
- synkit/Mechanism/evidence.py +262 -0
- synkit/Mechanism/interchange.py +141 -0
- synkit/Mechanism/model.py +918 -0
- synkit/Mechanism/neighbor_stereo.py +312 -0
- synkit/Mechanism/radical_data.py +740 -0
- synkit/Mechanism/replay.py +986 -0
- synkit/Mechanism/schema.py +264 -0
- synkit/Mechanism/stereo_state.py +416 -0
- synkit/Mechanism/symbols.py +91 -0
- synkit/Rule/Apply/__init__.py +35 -0
- synkit/Rule/Apply/conditions.py +45 -0
- synkit/Rule/Apply/dpo.py +998 -0
- synkit/Rule/Apply/rule_matcher.py +218 -0
- synkit/Rule/Apply/validation.py +354 -0
- synkit/Rule/Compose/__init__.py +106 -0
- synkit/Rule/Compose/_identity.py +43 -0
- synkit/Rule/Compose/composition.py +976 -0
- synkit/Rule/Compose/laws.py +439 -0
- synkit/Rule/Compose/search.py +771 -0
- synkit/Rule/Compose/synrule.py +170 -0
- synkit/Rule/Modify/__init__.py +0 -0
- synkit/Rule/Modify/implict_rule.py +56 -0
- synkit/Rule/Modify/longest_path.py +92 -0
- synkit/Rule/Modify/molecule_rule.py +115 -0
- synkit/Rule/Modify/prune_templates.py +78 -0
- synkit/Rule/Modify/rule_utils.py +194 -0
- synkit/Rule/Modify/strip_rule.py +97 -0
- synkit/Rule/__init__.py +28 -0
- synkit/Rule/generic_stereo.py +884 -0
- synkit/Rule/stereo_identity.py +271 -0
- synkit/Rule/syn_rule.py +1090 -0
- synkit/Synthesis/MSR/__init__.py +0 -0
- synkit/Synthesis/MSR/path_finder.py +239 -0
- synkit/Synthesis/Metrics/__init__.py +0 -0
- synkit/Synthesis/Metrics/_base.py +52 -0
- synkit/Synthesis/Metrics/_plot.py +129 -0
- synkit/Synthesis/Metrics/_ranking.py +179 -0
- synkit/Synthesis/RBL/__init__.py +80 -0
- synkit/Synthesis/RBL/engine.py +1249 -0
- synkit/Synthesis/RBL/matching.py +652 -0
- synkit/Synthesis/RBL/overlap.py +336 -0
- synkit/Synthesis/RBL/pipeline.py +376 -0
- synkit/Synthesis/RBL/policy.py +139 -0
- synkit/Synthesis/RBL/proof.py +370 -0
- synkit/Synthesis/RBL/reaction.py +506 -0
- synkit/Synthesis/RBL/state.py +169 -0
- synkit/Synthesis/RBL/validation.py +1060 -0
- synkit/Synthesis/Reactor/__init__.py +60 -0
- synkit/Synthesis/Reactor/core/__init__.py +1 -0
- synkit/Synthesis/Reactor/core/engine.py +967 -0
- synkit/Synthesis/Reactor/core/product.py +621 -0
- synkit/Synthesis/Reactor/core/rewrite.py +561 -0
- synkit/Synthesis/Reactor/core/strategy.py +44 -0
- synkit/Synthesis/Reactor/matching/__init__.py +1 -0
- synkit/Synthesis/Reactor/matching/mixin.py +920 -0
- synkit/Synthesis/Reactor/matching/policy.py +345 -0
- synkit/Synthesis/Reactor/matching/symmetry.py +309 -0
- synkit/Synthesis/Reactor/output/__init__.py +1 -0
- synkit/Synthesis/Reactor/output/deduplication.py +703 -0
- synkit/Synthesis/Reactor/output/policy.py +16 -0
- synkit/Synthesis/Reactor/output/serialization.py +485 -0
- synkit/Synthesis/Reactor/output/structural.py +893 -0
- synkit/Synthesis/Reactor/stereo/__init__.py +1 -0
- synkit/Synthesis/Reactor/stereo/assignment.py +35 -0
- synkit/Synthesis/Reactor/stereo/mixin.py +780 -0
- synkit/Synthesis/Reactor/variants/__init__.py +1 -0
- synkit/Synthesis/Reactor/variants/imbalanced.py +180 -0
- synkit/Synthesis/Reactor/variants/partial.py +84 -0
- synkit/Synthesis/Reactor/workflow/__init__.py +1 -0
- synkit/Synthesis/Reactor/workflow/batch.py +550 -0
- synkit/Synthesis/Reactor/workflow/benchmark.py +143 -0
- synkit/Synthesis/Reactor/workflow/postprocess.py +267 -0
- synkit/Synthesis/Reactor/workflow/rule_filter.py +210 -0
- synkit/Synthesis/__init__.py +0 -0
- synkit/Synthesis/reactor_utils.py +316 -0
- synkit/Utils/__init__.py +0 -0
- synkit/Utils/utils.py +172 -0
- synkit/Vis/__init__.py +91 -0
- synkit/Vis/crn/__init__.py +40 -0
- synkit/Vis/epd/__init__.py +20 -0
- synkit/Vis/epd/arrows.py +425 -0
- synkit/Vis/epd/chem.py +197 -0
- synkit/Vis/epd/constants.py +83 -0
- synkit/Vis/epd/layout.py +283 -0
- synkit/Vis/epd/mapping.py +51 -0
- synkit/Vis/epd/models.py +136 -0
- synkit/Vis/epd/render.py +543 -0
- synkit/Vis/epd/utils.py +108 -0
- synkit/Vis/epd/visualizer.py +811 -0
- synkit/Vis/graph_visualizer.py +375 -0
- synkit/Vis/its/__init__.py +19 -0
- synkit/Vis/its/drawer.py +615 -0
- synkit/Vis/its_drawer.py +35 -0
- synkit/Vis/molecule/__init__.py +31 -0
- synkit/Vis/molecule/drawer.py +563 -0
- synkit/Vis/molecule/reaction.py +285 -0
- synkit/Vis/molecule_drawer.py +33 -0
- synkit/Vis/mtg/__init__.py +17 -0
- synkit/Vis/mtg/drawer.py +769 -0
- synkit/Vis/mtg_drawer.py +34 -0
- synkit/Vis/pdf_writer.py +146 -0
- synkit/Vis/reaction/__init__.py +19 -0
- synkit/Vis/reaction/rule.py +141 -0
- synkit/Vis/reaction/rxn.py +532 -0
- synkit/Vis/reaction_drawer.py +41 -0
- synkit/Vis/space/__init__.py +17 -0
- synkit/Vis/space/chemical.py +80 -0
- synkit/Vis/space/embedding.py +87 -0
- synkit/Vis/vis_synedu/Vis/__init__.py +7 -0
- synkit/Vis/vis_synedu/Vis/dpo.py +862 -0
- synkit/Vis/vis_synedu/rxn_vis.py +377 -0
- synkit/Vis/vis_synedu/vis.py +501 -0
- synkit/Vis/visual_drawer.py +215 -0
- synkit/Vis/visual_model.py +520 -0
- synkit/__init__.py +3 -0
- synkit/_native.py +91 -0
- synkit/examples.py +50 -0
- synkit/version.py +23 -0
- synkit-1.6.5.dist-info/METADATA +156 -0
- synkit-1.6.5.dist-info/RECORD +636 -0
- synkit-1.6.5.dist-info/WHEEL +4 -0
- synkit-1.6.5.dist-info/licenses/LICENSE +21 -0
- synkit-1.6.5.dist-info/licenses/synkit/Chem/Mapper/solvers/native/cpp/src/symmetry/vendor/nauty/COPYRIGHT +44 -0
- synkit-1.6.5.dist-info/licenses/synkit/Chem/Mapper/solvers/native/cpp/src/symmetry/vendor/nauty/LICENSE-2.0.txt +202 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
|
|
2
|
+
#ifndef SYNKIT_PRIVATE_CLASS_STREAM_H
|
|
3
|
+
#define SYNKIT_PRIVATE_CLASS_STREAM_H
|
|
4
|
+
#include "synkit_mapper/symmetry/classification.h"
|
|
5
|
+
namespace synkit_mapper::detail {
|
|
6
|
+
struct ClassStream;
|
|
7
|
+
ClassStream *class_stream_create(const SynkitClassProblem &,double,int64_t,
|
|
8
|
+
int64_t,void *,SynkitClassCallback,void *,bool);
|
|
9
|
+
int class_stream_push(ClassStream *,const int32_t *,int64_t);
|
|
10
|
+
void class_stream_finish(ClassStream *,SynkitClassStatistics &);
|
|
11
|
+
void class_stream_delete(ClassStream *);
|
|
12
|
+
}
|
|
13
|
+
#endif
|
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
#include "synkit_mapper/symmetry/cpabs.h"
|
|
2
|
+
#include "synkit_mapper/core/runtime.h"
|
|
3
|
+
#include "synkit_mapper/pabs/seed.h"
|
|
4
|
+
#include "synkit_mapper/astar/bound.h"
|
|
5
|
+
|
|
6
|
+
#include <functional>
|
|
7
|
+
#include <limits>
|
|
8
|
+
#include <numeric>
|
|
9
|
+
#include <set>
|
|
10
|
+
#include <utility>
|
|
11
|
+
|
|
12
|
+
namespace synkit_mapper {
|
|
13
|
+
namespace {
|
|
14
|
+
using Perm=std::vector<int32_t>;
|
|
15
|
+
using Matching=std::vector<int32_t>; // sorted r*n+p pairs; arbitrary source set
|
|
16
|
+
using Group=std::vector<Perm>;
|
|
17
|
+
thread_local SynkitCPABSProfile profile;
|
|
18
|
+
thread_local SynkitCPABSProfileV2 detailed;
|
|
19
|
+
|
|
20
|
+
// Close only admitted generators. If adding one would exceed the explicit
|
|
21
|
+
// quotient budget, retain the previous closed subgroup, never an open prefix.
|
|
22
|
+
Group bounded_subgroup(const Group &witnesses,int n,size_t cap,Budget &budget) {
|
|
23
|
+
Perm identity(n);std::iota(identity.begin(),identity.end(),0);
|
|
24
|
+
Group group{identity},generators;
|
|
25
|
+
std::set<Perm> known{identity};
|
|
26
|
+
for(const auto &witness:witnesses) {
|
|
27
|
+
budget.check();if(known.count(witness)) continue;
|
|
28
|
+
Group candidate{identity},basis=generators;basis.push_back(witness);
|
|
29
|
+
std::set<Perm> seen{identity};bool over=false;
|
|
30
|
+
for(size_t k=0;k<candidate.size()&&!over;++k) for(const auto &g:basis) {
|
|
31
|
+
budget.check();Perm image(n);for(int i=0;i<n;++i) image[i]=g[candidate[k][i]];
|
|
32
|
+
if(seen.insert(image).second) {candidate.push_back(std::move(image));if(candidate.size()>cap) {over=true;break;}}
|
|
33
|
+
}
|
|
34
|
+
if(!over) {group=std::move(candidate);known=std::move(seen);generators=std::move(basis);}
|
|
35
|
+
}
|
|
36
|
+
return group;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Exact twin symmetric factors are represented implicitly. The quotient group
|
|
40
|
+
// is enumerated only on the blocks; exceeding a discovery cap retains all
|
|
41
|
+
// twin factors and retains a closed bounded quotient subgroup.
|
|
42
|
+
struct EndpointSymmetry {
|
|
43
|
+
std::vector<Perm> blocks;
|
|
44
|
+
Perm block_of;
|
|
45
|
+
Group quotient;
|
|
46
|
+
bool fallback=false;
|
|
47
|
+
int64_t order=1;
|
|
48
|
+
};
|
|
49
|
+
int64_t multiply_order(int64_t a,int64_t b) {
|
|
50
|
+
if(a<0||b<0||a>std::numeric_limits<int64_t>::max()/b) return -1;
|
|
51
|
+
return a*b;
|
|
52
|
+
}
|
|
53
|
+
EndpointSymmetry endpoint_group(const Problem &p,bool product,Budget &budget) {
|
|
54
|
+
auto weights=product?p.b2:p.a2;
|
|
55
|
+
auto types=product?p.types_p:p.types_r;
|
|
56
|
+
auto colors=product?p.node_colors_p:p.node_colors_r;
|
|
57
|
+
auto edges=product?p.edge_colors_p:p.edge_colors_r;
|
|
58
|
+
EndpointSymmetry result;result.block_of.assign(p.n,-1);
|
|
59
|
+
auto twins=[&](int i,int j) {
|
|
60
|
+
if(types[i]!=types[j]||(colors&&colors[i]!=colors[j])||(edges&&edges[i*p.n+i]!=edges[j*p.n+j])) return false;
|
|
61
|
+
for(int k=0;k<p.n;++k) if(k!=i&&k!=j &&
|
|
62
|
+
(weights[i*p.n+k]!=weights[j*p.n+k] ||
|
|
63
|
+
(edges&&edges[i*p.n+k]!=edges[j*p.n+k]))) return false;
|
|
64
|
+
return true;
|
|
65
|
+
};
|
|
66
|
+
for(int i=0;i<p.n;++i) if(result.block_of[i]<0) {
|
|
67
|
+
budget.check();
|
|
68
|
+
int id=static_cast<int>(result.blocks.size());Perm block{i};result.block_of[i]=id;
|
|
69
|
+
for(int j=i+1;j<p.n;++j) if(result.block_of[j]<0&&twins(i,j)) {block.push_back(j);result.block_of[j]=id;}
|
|
70
|
+
for(size_t k=2;k<=block.size();++k) result.order=multiply_order(result.order,k);
|
|
71
|
+
result.blocks.push_back(std::move(block));
|
|
72
|
+
}
|
|
73
|
+
int m=static_cast<int>(result.blocks.size());
|
|
74
|
+
std::vector<Perm> choices(m);
|
|
75
|
+
std::vector<std::vector<int64_t>> initial(m);
|
|
76
|
+
for(int i=0;i<m;++i) {
|
|
77
|
+
int atom=result.blocks[i][0],second=result.blocks[i].size()>1?result.blocks[i][1]:atom;
|
|
78
|
+
initial[i]={static_cast<int64_t>(result.blocks[i].size()),types[atom],colors?colors[atom]:0,
|
|
79
|
+
weights[atom*p.n+second],edges?edges[atom*p.n+second]:0};
|
|
80
|
+
}
|
|
81
|
+
Perm refined(m);
|
|
82
|
+
auto intern=[&](const std::vector<std::vector<int64_t>> &signatures) {
|
|
83
|
+
std::map<std::vector<int64_t>,int> ids;
|
|
84
|
+
for(const auto &signature:signatures) ids.emplace(signature,0);
|
|
85
|
+
int next=0;for(auto &entry:ids) entry.second=next++;
|
|
86
|
+
Perm labels;for(const auto &signature:signatures) labels.push_back(ids.at(signature));return labels;
|
|
87
|
+
};
|
|
88
|
+
refined=intern(initial);
|
|
89
|
+
for(int round=0;round<m;++round) {
|
|
90
|
+
budget.check();auto signatures=initial;
|
|
91
|
+
for(int i=0;i<m;++i) {
|
|
92
|
+
std::vector<std::vector<int64_t>> neighbors;
|
|
93
|
+
for(int j=0;j<m;++j) if(i!=j) {
|
|
94
|
+
int x=result.blocks[i][0],y=result.blocks[j][0];
|
|
95
|
+
neighbors.push_back({refined[j],weights[x*p.n+y],edges?edges[x*p.n+y]:0});
|
|
96
|
+
}
|
|
97
|
+
std::sort(neighbors.begin(),neighbors.end());
|
|
98
|
+
signatures[i].push_back(refined[i]);
|
|
99
|
+
for(const auto &neighbor:neighbors) signatures[i].insert(signatures[i].end(),neighbor.begin(),neighbor.end());
|
|
100
|
+
}
|
|
101
|
+
Perm next=intern(signatures);if(next==refined) break;refined=std::move(next);
|
|
102
|
+
}
|
|
103
|
+
for(int i=0;i<m;++i) for(int j=0;j<m;++j) if(refined[i]==refined[j]) choices[i].push_back(j);
|
|
104
|
+
Perm mapping(m,-1),used(m,0);
|
|
105
|
+
int64_t nodes=0;bool over=false;
|
|
106
|
+
std::function<void(int)> visit=[&](int depth) {
|
|
107
|
+
budget.check();if(++nodes>200000||result.quotient.size()>256) {over=true;return;}
|
|
108
|
+
if(depth==m) {result.quotient.push_back(mapping);return;}
|
|
109
|
+
int chosen=-1;Perm valid_choices;
|
|
110
|
+
for(int i=0;i<m;++i) if(mapping[i]<0) {
|
|
111
|
+
Perm valid;
|
|
112
|
+
for(int j:choices[i]) if(!used[j]) {
|
|
113
|
+
bool compatible=true;
|
|
114
|
+
for(int k=0;k<m;++k) if(mapping[k]>=0) {
|
|
115
|
+
int x=result.blocks[i][0],y=result.blocks[k][0],u=result.blocks[j][0],v=result.blocks[mapping[k]][0];
|
|
116
|
+
if(weights[x*p.n+y]!=weights[u*p.n+v]||(edges&&edges[x*p.n+y]!=edges[u*p.n+v])) {compatible=false;break;}
|
|
117
|
+
}
|
|
118
|
+
if(compatible) valid.push_back(j);
|
|
119
|
+
}
|
|
120
|
+
if(valid.empty()) return;
|
|
121
|
+
if(chosen<0||valid.size()<valid_choices.size()) {chosen=i;valid_choices=std::move(valid);}
|
|
122
|
+
}
|
|
123
|
+
for(int j:valid_choices) {
|
|
124
|
+
mapping[chosen]=j;used[j]=1;visit(depth+1);mapping[chosen]=-1;used[j]=0;if(over) return;
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
visit(0);profile.discovery_nodes+=nodes;
|
|
128
|
+
if(over||result.quotient.size()>256) {
|
|
129
|
+
result.fallback=true;result.quotient=bounded_subgroup(result.quotient,m,256,budget);
|
|
130
|
+
}
|
|
131
|
+
if(result.quotient.empty()) throw std::logic_error("Endpoint quotient identity missing");
|
|
132
|
+
result.order=multiply_order(result.order,result.quotient.size());
|
|
133
|
+
return result;
|
|
134
|
+
}
|
|
135
|
+
EndpointSymmetry identity_group(int n) {
|
|
136
|
+
EndpointSymmetry result;result.block_of.resize(n);Perm id(n);
|
|
137
|
+
for(int i=0;i<n;++i) {result.blocks.push_back(Perm{i});result.block_of[i]=id[i]=i;}
|
|
138
|
+
result.quotient={id};return result;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// An orbit of the two independent twin factors is exactly its block-flow
|
|
142
|
+
// matrix. Greedy earliest source/target vertices give its lexicographic minimum.
|
|
143
|
+
Matching twin_canonical(const Matching &matching,const EndpointSymmetry &r,
|
|
144
|
+
const EndpointSymmetry &p,const Perm &rg,const Perm &pg,int n) {
|
|
145
|
+
std::map<std::pair<int,int>,int> cells;
|
|
146
|
+
std::vector<int> row_counts(r.blocks.size(),0),row_used(r.blocks.size(),0),column_used(p.blocks.size(),0);
|
|
147
|
+
for(int pair:matching) {
|
|
148
|
+
int a=rg[r.block_of[pair/n]],b=pg[p.block_of[pair%n]];
|
|
149
|
+
++cells[{a,b}];++row_counts[a];
|
|
150
|
+
}
|
|
151
|
+
Perm selected;
|
|
152
|
+
for(size_t a=0;a<r.blocks.size();++a) for(int k=0;k<row_counts[a];++k) selected.push_back(r.blocks[a][k]);
|
|
153
|
+
std::sort(selected.begin(),selected.end());Matching result;
|
|
154
|
+
for(int source:selected) {
|
|
155
|
+
int a=r.block_of[source],chosen=-1,target=n;
|
|
156
|
+
for(const auto &entry:cells) if(entry.first.first==a&&entry.second) {
|
|
157
|
+
int b=entry.first.second,next=p.blocks[b][column_used[b]];
|
|
158
|
+
if(next<target) {target=next;chosen=b;}
|
|
159
|
+
}
|
|
160
|
+
if(chosen<0) throw std::logic_error("Invalid twin flow");
|
|
161
|
+
result.push_back(source*n+target);--cells[{a,chosen}];++column_used[chosen];++row_used[a];
|
|
162
|
+
}
|
|
163
|
+
return result;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
struct Traversal {
|
|
167
|
+
const Problem &p;
|
|
168
|
+
const Request &request;
|
|
169
|
+
Callback callback;
|
|
170
|
+
void *userdata;
|
|
171
|
+
Statistics &stats;
|
|
172
|
+
Budget budget;
|
|
173
|
+
EndpointSymmetry rows,columns;
|
|
174
|
+
int64_t best=std::numeric_limits<int64_t>::max();
|
|
175
|
+
int64_t threshold=std::numeric_limits<int64_t>::max();
|
|
176
|
+
bool optimization=false;
|
|
177
|
+
int64_t pending=0;
|
|
178
|
+
Matching base;
|
|
179
|
+
Perm variable_sources,base_source;
|
|
180
|
+
std::vector<Perm> prefix_counts,next_block_possible;
|
|
181
|
+
Traversal(const Problem &problem,const Request &r,Callback cb,void *data,Statistics &s)
|
|
182
|
+
:p(problem),request(r),callback(cb),userdata(data),stats(s),budget(r) {}
|
|
183
|
+
// Singleton hard types force these pairs in every full compatible map.
|
|
184
|
+
// Both endpoint groups fix them pointwise, including bounded subgroups.
|
|
185
|
+
void prepare_root() {
|
|
186
|
+
std::map<int32_t,Perm> source_types,target_types;
|
|
187
|
+
for(int i=0;i<p.n;++i) {
|
|
188
|
+
budget.check();source_types[p.types_r[i]].push_back(i);
|
|
189
|
+
target_types[p.types_p[i]].push_back(i);
|
|
190
|
+
}
|
|
191
|
+
base_source.assign(p.n,0);
|
|
192
|
+
for(int i=0;i<p.n;++i) {
|
|
193
|
+
if(source_types[p.types_r[i]].size()==1) {
|
|
194
|
+
const auto &targets=target_types.at(p.types_r[i]);
|
|
195
|
+
if(targets.size()!=1) throw std::logic_error("Incompatible forced type");
|
|
196
|
+
base.push_back(i*p.n+targets.front());base_source[i]=1;
|
|
197
|
+
} else variable_sources.push_back(i);
|
|
198
|
+
}
|
|
199
|
+
prefix_counts.push_back(Perm(rows.blocks.size(),0));
|
|
200
|
+
for(int pair:base) ++prefix_counts.back()[rows.block_of[pair/p.n]];
|
|
201
|
+
for(int i:variable_sources) {
|
|
202
|
+
budget.check();prefix_counts.push_back(prefix_counts.back());
|
|
203
|
+
++prefix_counts.back()[rows.block_of[i]];
|
|
204
|
+
}
|
|
205
|
+
next_block_possible.assign(variable_sources.size(),Perm(rows.blocks.size(),-1));
|
|
206
|
+
}
|
|
207
|
+
bool prefix_domain(const Matching &matching) const {
|
|
208
|
+
size_t next=0;
|
|
209
|
+
for(int pair:matching) if(!base_source[pair/p.n]) {
|
|
210
|
+
if(next>=variable_sources.size()||pair/p.n!=variable_sources[next++]) return false;
|
|
211
|
+
}
|
|
212
|
+
return matching.size()==base.size()+next;
|
|
213
|
+
}
|
|
214
|
+
// Necessary domain-orbit test only. Twins realize every subset of a block
|
|
215
|
+
// with the specified cardinality; quotient permutations move whole blocks.
|
|
216
|
+
// Full canonicalization and its actual prefix test remain mandatory.
|
|
217
|
+
bool possible_prefix_extension(size_t matched,int block) {
|
|
218
|
+
const size_t depth=matched-base.size();
|
|
219
|
+
auto &answer=next_block_possible.at(depth).at(block);
|
|
220
|
+
if(answer>=0) return answer;
|
|
221
|
+
Perm counts=prefix_counts.at(depth);++counts[block];
|
|
222
|
+
const auto &wanted=prefix_counts.at(depth+1);
|
|
223
|
+
for(const auto &g:rows.quotient) {
|
|
224
|
+
budget.check();bool equal=true;
|
|
225
|
+
for(size_t a=0;a<counts.size();++a) if(counts[a]!=wanted[g[a]]) {equal=false;break;}
|
|
226
|
+
if(equal) {answer=1;return true;}
|
|
227
|
+
}
|
|
228
|
+
answer=0;return false;
|
|
229
|
+
}
|
|
230
|
+
Matching canonical(const Matching &matching) {
|
|
231
|
+
budget.check();
|
|
232
|
+
auto start=Clock::now();++profile.canonical_calls;
|
|
233
|
+
Matching best_matching=matching,image;image.reserve(matching.size());
|
|
234
|
+
for(const auto &row:rows.quotient) for(const auto &column:columns.quotient) {
|
|
235
|
+
budget.check();image=twin_canonical(matching,rows,columns,row,column,p.n);
|
|
236
|
+
if(image<best_matching) best_matching=image;
|
|
237
|
+
}
|
|
238
|
+
profile.canonical_seconds+=elapsed(start);
|
|
239
|
+
return best_matching;
|
|
240
|
+
}
|
|
241
|
+
int64_t partial_cost(const Matching &matching) {
|
|
242
|
+
int64_t value=0;
|
|
243
|
+
for(size_t i=0;i<matching.size();++i) for(size_t j=i+1;j<matching.size();++j)
|
|
244
|
+
value+=std::abs(p.a2[(matching[i]/p.n)*p.n+matching[j]/p.n]-
|
|
245
|
+
p.b2[(matching[i]%p.n)*p.n+matching[j]%p.n]);
|
|
246
|
+
return value;
|
|
247
|
+
}
|
|
248
|
+
int64_t lower_bound(const Matching &matching) {
|
|
249
|
+
auto start=Clock::now();++detailed.bound_calls;
|
|
250
|
+
Perm mapping(p.n,-1);for(int pair:matching) mapping[pair/p.n]=pair%p.n;
|
|
251
|
+
int64_t value=astar::partial_lower_bound2(p.n,p.a2,p.b2,p.types_r,p.types_p,mapping,[&](){budget.check();});
|
|
252
|
+
detailed.bound_seconds+=elapsed(start);return value;
|
|
253
|
+
}
|
|
254
|
+
void seed() {
|
|
255
|
+
auto started=Clock::now();
|
|
256
|
+
// The controlled variant shares PABS's complete input-only seed policy.
|
|
257
|
+
// This changes only a feasible optimization upper bound, never the
|
|
258
|
+
// canonical-parent extension tree or numeric exact/at-most enumeration.
|
|
259
|
+
std::vector<int32_t> shared_mapping;
|
|
260
|
+
int64_t shared_incumbent=-1,shared_lower=-1;
|
|
261
|
+
auto retain_shared=[&]() {
|
|
262
|
+
if(static_cast<int>(shared_mapping.size())!=p.n||shared_incumbent<0) return;
|
|
263
|
+
std::vector<bool> seen(p.n,false);
|
|
264
|
+
for(int i=0;i<p.n;++i) {
|
|
265
|
+
const int j=shared_mapping[i];
|
|
266
|
+
if(j<0||j>=p.n||seen[j]||p.types_r[i]!=p.types_p[j])
|
|
267
|
+
throw std::logic_error("cPABS shared seed is not a typed bijection");
|
|
268
|
+
seen[j]=true;
|
|
269
|
+
}
|
|
270
|
+
if(mapping_cost2(p,shared_mapping)!=shared_incumbent)
|
|
271
|
+
throw std::logic_error("cPABS shared seed rescore mismatch");
|
|
272
|
+
if(shared_lower>shared_incumbent)
|
|
273
|
+
throw std::logic_error("cPABS shared lower bound exceeds feasible seed");
|
|
274
|
+
best=std::min(best,shared_incumbent);stats.incumbent2=best;
|
|
275
|
+
stats.lower_bound2=std::max(stats.lower_bound2,shared_lower);
|
|
276
|
+
detailed.seed_cost2=best;detailed.seed_seconds=elapsed(started);
|
|
277
|
+
};
|
|
278
|
+
try {
|
|
279
|
+
if(pabs::prepare_seed(p,budget,true,shared_mapping,shared_incumbent,shared_lower)) {
|
|
280
|
+
if(static_cast<int>(shared_mapping.size())!=p.n||shared_incumbent<0)
|
|
281
|
+
throw std::logic_error("cPABS shared seed helper returned no feasible map");
|
|
282
|
+
retain_shared();return;
|
|
283
|
+
}
|
|
284
|
+
} catch(const Stop &) {
|
|
285
|
+
// The helper publishes a valid incumbent before checking its deadline.
|
|
286
|
+
retain_shared();detailed.seed_seconds=elapsed(started);throw;
|
|
287
|
+
}
|
|
288
|
+
// Keep cPABS's former seed policy outside the shared PABS helper domain.
|
|
289
|
+
Perm source(p.n),target(p.n);std::iota(source.begin(),source.end(),0);target=source;
|
|
290
|
+
std::vector<int64_t> left(p.n),right(p.n);
|
|
291
|
+
for(int i=0;i<p.n;++i) for(int j=0;j<p.n;++j) {left[i]+=p.a2[i*p.n+j];right[i]+=p.b2[i*p.n+j];}
|
|
292
|
+
std::stable_sort(source.begin(),source.end(),[&](int i,int j){return std::make_pair(p.types_r[i],left[i])<std::make_pair(p.types_r[j],left[j]);});
|
|
293
|
+
std::stable_sort(target.begin(),target.end(),[&](int i,int j){return std::make_pair(p.types_p[i],right[i])<std::make_pair(p.types_p[j],right[j]);});
|
|
294
|
+
Perm mapping(p.n);for(int k=0;k<p.n;++k) mapping[source[k]]=target[k];
|
|
295
|
+
auto improve=[&](Perm candidate) {
|
|
296
|
+
int64_t candidate_cost=mapping_cost2(p,candidate);
|
|
297
|
+
best=std::min(best,candidate_cost);stats.incumbent2=best;
|
|
298
|
+
for(int pass=0;pass<8;++pass) {
|
|
299
|
+
budget.check();bool improved=false;
|
|
300
|
+
for(int i=0;i<p.n;++i) for(int j=i+1;j<p.n;++j) if(p.types_r[i]==p.types_r[j]) {
|
|
301
|
+
budget.check();int64_t delta=0;
|
|
302
|
+
for(int k=0;k<p.n;++k) if(k!=i&&k!=j) {
|
|
303
|
+
delta+=std::abs(p.a2[i*p.n+k]-p.b2[candidate[j]*p.n+candidate[k]])+std::abs(p.a2[j*p.n+k]-p.b2[candidate[i]*p.n+candidate[k]])-
|
|
304
|
+
std::abs(p.a2[i*p.n+k]-p.b2[candidate[i]*p.n+candidate[k]])-std::abs(p.a2[j*p.n+k]-p.b2[candidate[j]*p.n+candidate[k]]);
|
|
305
|
+
}
|
|
306
|
+
if(delta<0) {
|
|
307
|
+
std::swap(candidate[i],candidate[j]);candidate_cost+=delta;improved=true;
|
|
308
|
+
best=std::min(best,candidate_cost);stats.incumbent2=best;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
if(!improved) break;
|
|
312
|
+
}
|
|
313
|
+
if(mapping_cost2(p,candidate)!=candidate_cost) throw std::logic_error("cPABS seed rescore mismatch");
|
|
314
|
+
};
|
|
315
|
+
improve(mapping);
|
|
316
|
+
// Same typed profile-LAP relaxation as the PABS starting assignment.
|
|
317
|
+
// Keep the old degree seed as a second candidate, so the feasible upper
|
|
318
|
+
// bound cannot regress. Neither seed uses an annotation or narrows search.
|
|
319
|
+
improve(astar::profile_assignment_seed(p.n,p.a2,p.b2,p.types_r,p.types_p,
|
|
320
|
+
[&](){budget.check();}));
|
|
321
|
+
stats.incumbent2=best;
|
|
322
|
+
detailed.seed_cost2=best;detailed.seed_seconds=elapsed(started);
|
|
323
|
+
}
|
|
324
|
+
void leaf(const Matching &matching,int64_t cost) {
|
|
325
|
+
++stats.leaves;
|
|
326
|
+
if(optimization) {
|
|
327
|
+
best=std::min(best,cost);stats.incumbent2=best;return;
|
|
328
|
+
}
|
|
329
|
+
if((request.query==SYNKIT_EXACT_DISTANCE||request.query==SYNKIT_MINIMUM_CLASSES)&&cost!=threshold) return;
|
|
330
|
+
if(cost>threshold) return;
|
|
331
|
+
if(request.max_candidates>=0&&stats.candidate_count>=request.max_candidates) throw Stop{SYNKIT_STOP_CANDIDATES};
|
|
332
|
+
Perm mapping(p.n,-1);
|
|
333
|
+
for(int pair:matching) mapping[pair/p.n]=pair%p.n;
|
|
334
|
+
if(mapping_cost2(p,mapping)!=cost) throw std::logic_error("cPABS independent rescore mismatch");
|
|
335
|
+
stats.incumbent2=stats.incumbent2<0?cost:std::min(stats.incumbent2,cost);
|
|
336
|
+
++stats.candidate_count;
|
|
337
|
+
auto started=Clock::now();
|
|
338
|
+
int stop=callback(mapping.data(),cost,userdata);
|
|
339
|
+
stats.callback_seconds+=elapsed(started);
|
|
340
|
+
if(stop) throw Stop{SYNKIT_STOP_CALLBACK};
|
|
341
|
+
budget.check();
|
|
342
|
+
}
|
|
343
|
+
void visit(const Matching &matching,int64_t known_bound=-1,int64_t known_cost=-1) {
|
|
344
|
+
budget.check();
|
|
345
|
+
if(request.max_states>=0&&stats.nodes>=request.max_states) throw Stop{SYNKIT_STOP_STATES};
|
|
346
|
+
++stats.nodes;
|
|
347
|
+
const int64_t cost=known_cost<0?partial_cost(matching):known_cost;
|
|
348
|
+
const int64_t limit=optimization?best:threshold;
|
|
349
|
+
const int64_t bound=known_bound<0?lower_bound(matching):known_bound;
|
|
350
|
+
if(matching.size()==base.size()) stats.lower_bound2=std::max(stats.lower_bound2,bound);
|
|
351
|
+
if(bound>limit||(optimization&&bound>=best)) {++profile.bound_rejections;return;}
|
|
352
|
+
if(static_cast<int>(matching.size())==p.n) {leaf(matching,cost);return;}
|
|
353
|
+
Perm assigned(p.n,0),used(p.n,0);
|
|
354
|
+
for(int pair:matching) {assigned[pair/p.n]=1;used[pair%p.n]=1;}
|
|
355
|
+
// Unused vertices in one exact twin block can be swapped while fixing
|
|
356
|
+
// the current matching pointwise. One representative per block is enough;
|
|
357
|
+
// retain every eligible source/target block pair, including coupled orbits.
|
|
358
|
+
Perm targets;
|
|
359
|
+
std::vector<bool> target_seen(columns.blocks.size(),false),source_seen(rows.blocks.size(),false);
|
|
360
|
+
for(int j=0;j<p.n;++j) if(!used[j]&&!target_seen[columns.block_of[j]]) {
|
|
361
|
+
targets.push_back(j);target_seen[columns.block_of[j]]=true;
|
|
362
|
+
}
|
|
363
|
+
// A negative bound marks an exactly considered but rejected canonical key.
|
|
364
|
+
// This deduplicates before expensive LAPs, including keys failing a bound.
|
|
365
|
+
std::map<Matching,std::pair<int64_t,int64_t>> children;
|
|
366
|
+
int64_t accepted=0;
|
|
367
|
+
for(int i=0;i<p.n;++i) if(!assigned[i]&&!source_seen[rows.block_of[i]]) {
|
|
368
|
+
source_seen[rows.block_of[i]]=true;
|
|
369
|
+
if(!possible_prefix_extension(matching.size(),rows.block_of[i])) continue;
|
|
370
|
+
for(int j:targets) if(p.types_r[i]==p.types_p[j]) {
|
|
371
|
+
budget.check();++profile.augmentations;
|
|
372
|
+
int64_t child_cost=cost;
|
|
373
|
+
for(int pair:matching) child_cost+=std::abs(p.a2[i*p.n+pair/p.n]-p.b2[j*p.n+pair%p.n]);
|
|
374
|
+
if(child_cost>limit||(optimization&&child_cost>=best)) {++profile.bound_rejections;continue;}
|
|
375
|
+
Matching child=matching;child.push_back(i*p.n+j);std::sort(child.begin(),child.end());
|
|
376
|
+
child=canonical(child);
|
|
377
|
+
if(!prefix_domain(child)) {++profile.canonical_rejections;continue;}
|
|
378
|
+
auto inserted=children.emplace(std::move(child),std::make_pair(-1,child_cost));
|
|
379
|
+
if(!inserted.second) continue;
|
|
380
|
+
const auto &key=inserted.first->first;
|
|
381
|
+
Matching parent=key;
|
|
382
|
+
int remove=static_cast<int>(parent.size())-1;
|
|
383
|
+
while(remove>=0&&base_source[parent[remove]/p.n]) --remove;
|
|
384
|
+
if(remove<0) throw std::logic_error("Non-base extension missing");
|
|
385
|
+
parent.erase(parent.begin()+remove);parent=canonical(parent);
|
|
386
|
+
if(parent!=matching) {++profile.canonical_rejections;continue;}
|
|
387
|
+
const int64_t child_bound=lower_bound(key);
|
|
388
|
+
if(child_bound>limit||(optimization&&child_bound>=best)) {++profile.bound_rejections;continue;}
|
|
389
|
+
inserted.first->second.first=child_bound;++accepted;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
pending+=accepted;
|
|
393
|
+
stats.peak_frontier=std::max(stats.peak_frontier,pending);
|
|
394
|
+
if(request.max_frontier>=0&&pending>request.max_frontier) throw Stop{SYNKIT_STOP_FRONTIER};
|
|
395
|
+
while(!children.empty()) {
|
|
396
|
+
auto node=children.extract(children.begin());
|
|
397
|
+
if(node.mapped().first<0) continue;
|
|
398
|
+
--pending;visit(node.key(),node.mapped().first,node.mapped().second);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
int run() {
|
|
402
|
+
if(request.classify||request.max_classes!=-1||request.memory_limit_bytes!=-1) return unsupported(stats);
|
|
403
|
+
if(p.n>256) return unsupported(stats);
|
|
404
|
+
profile={};detailed={};detailed.seed_cost2=-1;stats.peak_frontier_bytes=-1;
|
|
405
|
+
auto start=Clock::now();
|
|
406
|
+
if(request.symmetry) {
|
|
407
|
+
rows=endpoint_group(p,false,budget);columns=endpoint_group(p,true,budget);
|
|
408
|
+
if(rows.quotient.size()*columns.quotient.size()>16384) {
|
|
409
|
+
if(columns.order>=0) columns.order/=static_cast<int64_t>(columns.quotient.size());
|
|
410
|
+
columns.quotient=bounded_subgroup(columns.quotient,columns.blocks.size(),16384/rows.quotient.size(),budget);
|
|
411
|
+
columns.order=multiply_order(columns.order,columns.quotient.size());columns.fallback=true;
|
|
412
|
+
}
|
|
413
|
+
profile.identity_fallback_r=rows.fallback;profile.identity_fallback_p=columns.fallback;
|
|
414
|
+
} else {rows=identity_group(p.n);columns=identity_group(p.n);}
|
|
415
|
+
profile.subgroup_order=multiply_order(rows.order,columns.order);
|
|
416
|
+
detailed.twin_blocks_r=rows.blocks.size();detailed.twin_blocks_p=columns.blocks.size();
|
|
417
|
+
detailed.quotient_order_r=rows.quotient.size();detailed.quotient_order_p=columns.quotient.size();
|
|
418
|
+
profile.discovery_seconds=elapsed(start);stats.model_seconds=profile.discovery_seconds;
|
|
419
|
+
start=Clock::now();prepare_root();stats.model_seconds+=elapsed(start);
|
|
420
|
+
try {
|
|
421
|
+
if(request.query==SYNKIT_MINIMUM_CLASSES||request.query==SYNKIT_MINIMUM_PROOF) {
|
|
422
|
+
optimization=true;start=Clock::now();seed();visit(base);stats.optimization_seconds=elapsed(start);
|
|
423
|
+
stats.minimum_proven=1;stats.minimum2=stats.incumbent2=stats.lower_bound2=best;
|
|
424
|
+
if(request.query==SYNKIT_MINIMUM_PROOF) {stats.search_complete=1;stats.elapsed_seconds=budget.seconds();return 0;}
|
|
425
|
+
threshold=best;optimization=false;
|
|
426
|
+
} else threshold=request.target2;
|
|
427
|
+
start=Clock::now();visit(base);stats.enumeration_seconds=elapsed(start);stats.search_complete=1;
|
|
428
|
+
} catch(const Stop &stop) {
|
|
429
|
+
if(optimization) stats.optimization_seconds=budget.seconds()-stats.model_seconds;
|
|
430
|
+
else stats.enumeration_seconds=budget.seconds()-stats.model_seconds-stats.optimization_seconds;
|
|
431
|
+
stopped(stats,stop.reason);
|
|
432
|
+
}
|
|
433
|
+
if(stats.minimum_proven==0&&stats.lower_bound2<0) stats.lower_bound2=0;
|
|
434
|
+
// Raw output counts subgroup orbits, not reaction classes or labeled maps.
|
|
435
|
+
stats.labeled_count=-1;stats.class_count=-1;
|
|
436
|
+
stats.elapsed_seconds=budget.seconds();return 0;
|
|
437
|
+
}
|
|
438
|
+
};
|
|
439
|
+
} // namespace
|
|
440
|
+
|
|
441
|
+
int solve_cpabs(const Problem &p,const Request &r,Callback callback,void *userdata,Statistics &statistics) {
|
|
442
|
+
initialize(statistics,r);
|
|
443
|
+
if(!callback&&r.query!=SYNKIT_MINIMUM_PROOF) throw std::invalid_argument("cPABS enumeration requires a callback");
|
|
444
|
+
Traversal search(p,r,callback,userdata,statistics);
|
|
445
|
+
try {return search.run();}
|
|
446
|
+
catch(const Stop &stop) {stopped(statistics,stop.reason);statistics.elapsed_seconds=search.budget.seconds();return 0;}
|
|
447
|
+
}
|
|
448
|
+
} // namespace synkit_mapper
|
|
449
|
+
|
|
450
|
+
extern "C" void synkit_mapper_cpabs_profile(SynkitCPABSProfile *out) {
|
|
451
|
+
if(out) *out=synkit_mapper::profile;
|
|
452
|
+
}
|
|
453
|
+
extern "C" void synkit_mapper_cpabs_profile_v2(SynkitCPABSProfileV2 *out) {
|
|
454
|
+
if(out) {*out=synkit_mapper::detailed;out->base=synkit_mapper::profile;}
|
|
455
|
+
}
|