cpp-pd-code-simplify-interface 0.1.15__tar.gz → 0.1.17__tar.gz

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.
Files changed (12) hide show
  1. {cpp_pd_code_simplify_interface-0.1.15 → cpp_pd_code_simplify_interface-0.1.17}/PKG-INFO +1 -1
  2. {cpp_pd_code_simplify_interface-0.1.15 → cpp_pd_code_simplify_interface-0.1.17}/cpp_pd_code_simplify_interface/data/src/pdcode_simplify.cpp +53 -2
  3. {cpp_pd_code_simplify_interface-0.1.15 → cpp_pd_code_simplify_interface-0.1.17}/pyproject.toml +1 -1
  4. {cpp_pd_code_simplify_interface-0.1.15 → cpp_pd_code_simplify_interface-0.1.17}/README.md +0 -0
  5. {cpp_pd_code_simplify_interface-0.1.15 → cpp_pd_code_simplify_interface-0.1.17}/build_backend/cpp_pd_code_simplify_interface_build_backend.py +0 -0
  6. {cpp_pd_code_simplify_interface-0.1.15 → cpp_pd_code_simplify_interface-0.1.17}/cpp_pd_code_simplify_interface/__init__.py +0 -0
  7. {cpp_pd_code_simplify_interface-0.1.15 → cpp_pd_code_simplify_interface-0.1.17}/cpp_pd_code_simplify_interface/__main__.py +0 -0
  8. {cpp_pd_code_simplify_interface-0.1.15 → cpp_pd_code_simplify_interface-0.1.17}/cpp_pd_code_simplify_interface/_worker.py +0 -0
  9. {cpp_pd_code_simplify_interface-0.1.15 → cpp_pd_code_simplify_interface-0.1.17}/cpp_pd_code_simplify_interface/data/include/pdcode_simplify/pdcode_simplify.hpp +0 -0
  10. {cpp_pd_code_simplify_interface-0.1.15 → cpp_pd_code_simplify_interface-0.1.17}/cpp_pd_code_simplify_interface/data/src/native_interface.cpp +0 -0
  11. {cpp_pd_code_simplify_interface-0.1.15 → cpp_pd_code_simplify_interface-0.1.17}/cpp_pd_code_simplify_interface/main.py +0 -0
  12. {cpp_pd_code_simplify_interface-0.1.15 → cpp_pd_code_simplify_interface-0.1.17}/cpp_pd_code_simplify_interface/py.typed +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cpp-pd-code-simplify-interface
3
- Version: 0.1.15
3
+ Version: 0.1.17
4
4
  Summary: Python interface for cpp-pd-code-simplify with runtime C++ compilation.
5
5
  License-Expression: MIT
6
6
  Author: GGN_2015
@@ -1842,6 +1842,18 @@ void emit_step_pd(const SimplifierOptions& options, int round, const PDCode& cod
1842
1842
  }
1843
1843
  }
1844
1844
 
1845
+ std::string no_path_restart_signature(
1846
+ const PDCode& code,
1847
+ std::size_t crossingless_components) {
1848
+ std::ostringstream out;
1849
+ out << crossingless_components << ':' << format_final_pd_code(code);
1850
+ return out.str();
1851
+ }
1852
+
1853
+ PDCode canonical_output_code(const PDCode& code) {
1854
+ return parse_pd_code(format_final_pd_code(code));
1855
+ }
1856
+
1845
1857
  std::string search_mode_for_options(const SimplifierOptions& options) {
1846
1858
  if (options.max_paths == -1 && !options.ban_heuristic) {
1847
1859
  return "heuristic";
@@ -2538,6 +2550,7 @@ ReductionResult reduce_pd_code(
2538
2550
  ReductionResult output;
2539
2551
  output.code = code;
2540
2552
  output.crossingless_components = known_crossingless_components;
2553
+ std::set<std::string> exhausted_no_path_signatures;
2541
2554
 
2542
2555
  try {
2543
2556
  check_timeout(run_options);
@@ -2598,8 +2611,7 @@ ReductionResult reduce_pd_code(
2598
2611
  emit_progress(run_options, message.str());
2599
2612
  }
2600
2613
 
2601
- if (!search.found && reduction_round < 0 &&
2602
- run_options.max_paths == -1 && !run_options.ban_heuristic) {
2614
+ if (!search.found && run_options.max_paths == -1 && !run_options.ban_heuristic) {
2603
2615
  SimplifierOptions brute_options = run_options;
2604
2616
  brute_options.max_paths = -1;
2605
2617
  brute_options.ban_heuristic = true;
@@ -2631,6 +2643,45 @@ ReductionResult reduce_pd_code(
2631
2643
  }
2632
2644
 
2633
2645
  if (!search.found) {
2646
+ if (run_options.max_paths == -1) {
2647
+ check_timeout(run_options);
2648
+ const std::string signature = no_path_restart_signature(
2649
+ output.code, output.crossingless_components);
2650
+ if (exhausted_no_path_signatures.insert(signature).second) {
2651
+ const std::size_t before_restart_crossings = output.code.size();
2652
+ const std::size_t before_restart_crossingless =
2653
+ output.crossingless_components;
2654
+ const PDSimplificationResult restarted =
2655
+ simplify_pd_code(
2656
+ canonical_output_code(output.code),
2657
+ output.crossingless_components);
2658
+ const bool changed =
2659
+ restarted.code != output.code ||
2660
+ restarted.crossingless_components != output.crossingless_components;
2661
+ output.code = restarted.code;
2662
+ output.crossingless_components = restarted.crossingless_components;
2663
+ output.reidemeister_i_moves += restarted.reidemeister_i_moves;
2664
+ output.nugatory_crossing_moves += restarted.nugatory_crossing_moves;
2665
+ {
2666
+ std::ostringstream message;
2667
+ message << "round " << round
2668
+ << " canonical_restart changed="
2669
+ << (changed ? "yes" : "no")
2670
+ << " crossings=" << before_restart_crossings
2671
+ << " -> " << output.code.size()
2672
+ << " crossingless_components="
2673
+ << before_restart_crossingless
2674
+ << " -> " << output.crossingless_components
2675
+ << " r1_moves=" << restarted.reidemeister_i_moves
2676
+ << " nugatory_moves="
2677
+ << restarted.nugatory_crossing_moves;
2678
+ emit_progress(run_options, message.str());
2679
+ }
2680
+ if (changed) {
2681
+ continue;
2682
+ }
2683
+ }
2684
+ }
2634
2685
  {
2635
2686
  std::ostringstream message;
2636
2687
  message << "round " << round
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "cpp-pd-code-simplify-interface"
3
- version = "0.1.15"
3
+ version = "0.1.17"
4
4
  description = "Python interface for cpp-pd-code-simplify with runtime C++ compilation."
5
5
  authors = [
6
6
  {name = "GGN_2015", email = "neko@jlulug.org"}