simulation-alg 0.1.8__tar.gz → 0.1.9__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 (21) hide show
  1. {simulation_alg-0.1.8 → simulation_alg-0.1.9}/Cargo.lock +4 -4
  2. {simulation_alg-0.1.8 → simulation_alg-0.1.9}/Cargo.toml +1 -1
  3. {simulation_alg-0.1.8 → simulation_alg-0.1.9}/PKG-INFO +1 -1
  4. {simulation_alg-0.1.8 → simulation_alg-0.1.9}/pyproject.toml +1 -1
  5. {simulation_alg-0.1.8 → simulation_alg-0.1.9}/simulation.pyi +15 -0
  6. {simulation_alg-0.1.8 → simulation_alg-0.1.9}/src/graph/hypergraph.rs +47 -5
  7. {simulation_alg-0.1.8 → simulation_alg-0.1.9}/src/lib.rs +1 -0
  8. {simulation_alg-0.1.8 → simulation_alg-0.1.9}/.github/workflows/ci.yml +0 -0
  9. {simulation_alg-0.1.8 → simulation_alg-0.1.9}/.gitignore +0 -0
  10. {simulation_alg-0.1.8 → simulation_alg-0.1.9}/.gitmodules +0 -0
  11. {simulation_alg-0.1.8 → simulation_alg-0.1.9}/LICENSE +0 -0
  12. {simulation_alg-0.1.8 → simulation_alg-0.1.9}/README.md +0 -0
  13. {simulation_alg-0.1.8 → simulation_alg-0.1.9}/hyper-simulation.log +0 -0
  14. {simulation_alg-0.1.8 → simulation_alg-0.1.9}/python/__init__.py +0 -0
  15. {simulation_alg-0.1.8 → simulation_alg-0.1.9}/requirements.txt +0 -0
  16. {simulation_alg-0.1.8 → simulation_alg-0.1.9}/src/graph/mod.rs +0 -0
  17. {simulation_alg-0.1.8 → simulation_alg-0.1.9}/src/graph/networkx_graph.rs +0 -0
  18. {simulation_alg-0.1.8 → simulation_alg-0.1.9}/src/utils.rs +0 -0
  19. {simulation_alg-0.1.8 → simulation_alg-0.1.9}/test.py +0 -0
  20. {simulation_alg-0.1.8 → simulation_alg-0.1.9}/tests/test_hyper_simulation.py +0 -0
  21. {simulation_alg-0.1.8 → simulation_alg-0.1.9}/tests/test_simulation.py +0 -0
@@ -177,9 +177,9 @@ dependencies = [
177
177
 
178
178
  [[package]]
179
179
  name = "graph-base"
180
- version = "0.1.13"
180
+ version = "0.1.14"
181
181
  source = "registry+https://github.com/rust-lang/crates.io-index"
182
- checksum = "985b3629de3172005640f8f4ba46b738c605682db2776ecf4dd73a42ce55325f"
182
+ checksum = "1c337eeba84f9bf9bd65f89631119a34215bf46251e751abc1a6819195d71287"
183
183
  dependencies = [
184
184
  "lazy_static",
185
185
  "rand",
@@ -188,9 +188,9 @@ dependencies = [
188
188
 
189
189
  [[package]]
190
190
  name = "graph-simulation"
191
- version = "0.1.20"
191
+ version = "0.1.24"
192
192
  source = "registry+https://github.com/rust-lang/crates.io-index"
193
- checksum = "3c2137012fbaf6b3428ea73e32e93e1f7c90c13d6edbfd687f6cc1021b8ab83a"
193
+ checksum = "3744a0d1d724cad58fef5eee7383bcdc3cd318952f4611ca9f3916fe0bf01e46"
194
194
  dependencies = [
195
195
  "bincode",
196
196
  "env_logger",
@@ -14,7 +14,7 @@ crate-type = ["cdylib"]
14
14
 
15
15
  [dependencies]
16
16
  pyo3 = { version = "0.27.1", features = ["extension-module"] }
17
- graph-simulation = "0.1.20"
17
+ graph-simulation = "0.1.24"
18
18
  graph-base = "0.1.13"
19
19
  rayon = "1.10.0"
20
20
  # [tool.maturin]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: simulation-alg
3
- Version: 0.1.8
3
+ Version: 0.1.9
4
4
  Classifier: Programming Language :: Rust
5
5
  Classifier: Programming Language :: Python :: Implementation :: CPython
6
6
  Classifier: Programming Language :: Python :: Implementation :: PyPy
@@ -4,7 +4,7 @@ build-backend = "maturin"
4
4
 
5
5
  [project]
6
6
  name = "simulation-alg"
7
- version = "0.1.8"
7
+ version = "0.1.9"
8
8
  requires-python = ">=3.10"
9
9
  classifiers = [
10
10
  "Programming Language :: Rust",
@@ -49,6 +49,15 @@ class Hyperedge:
49
49
  def id_set(self) -> set[int]: ...
50
50
  def desc(self) -> str: ...
51
51
 
52
+ class Event:
53
+ """
54
+ Event class.
55
+ """
56
+ phrase: str
57
+ sc_id: int
58
+ binary_relation: set[tuple[int, int]]
59
+
60
+ def __init__(self, phrase: str, sc_id: int, binary_relation: set[tuple[int, int]]): ...
52
61
 
53
62
  # (cluster_u, cluster_v)
54
63
  class DMatch:
@@ -92,6 +101,11 @@ class Hypergraph:
92
101
 
93
102
  def get_node_desc_by_id(self, node_id: int) -> Optional[str]: ...
94
103
 
104
+ def get_hyper_simulation_trace(self) -> list[Event]:
105
+ """
106
+ Get trace events of last time hyper simulation.
107
+ """
108
+
95
109
  @staticmethod
96
110
  def hyper_simulation(query: 'Hypergraph', data: 'Hypergraph', l_match_fn: Callable[[Hyperedge, Hyperedge], dict[int, set[int]]]) -> dict[int, set[int]]:
97
111
  """
@@ -109,3 +123,4 @@ class Hypergraph:
109
123
  """
110
124
  Hyper Simulation
111
125
  """
126
+
@@ -1,8 +1,9 @@
1
1
  use std::{collections::{HashMap, HashSet}, fmt::Display, hash::Hash};
2
2
 
3
3
  use pyo3::{prelude::*, types::PyList};
4
- use graph_simulation::algorithm::hyper_simulation::{DMatch, Delta, HyperSimulation, LMatch, LPredicate, SematicCluster};
4
+ use graph_simulation::{algorithm::hyper_simulation::{DMatch, Delta, HSEvent, HyperSimulation, HyperSimulationTrace, LMatch, LPredicate, SematicCluster}, utils::logger::TraceLog};
5
5
  use graph_base::interfaces::{edge, graph::{self, SingleId}, hypergraph::{self, ContainedHyperedge}, typed, vertex};
6
+
6
7
  // use graph_base::interfaces::hypergraph;
7
8
 
8
9
  #[derive(Clone, Debug, Eq)]
@@ -86,6 +87,25 @@ pub struct Hypergraph {
86
87
  l_predicate_fn: Option<Py<PyAny>>, // (Hyperedge, Hyperedge) -> bool
87
88
  }
88
89
 
90
+ #[pyclass(name = "Event")]
91
+ pub struct Event {
92
+ pub phrase: String,
93
+ pub sc_id: usize,
94
+ pub binary_relation: HashSet<(usize, usize)>
95
+ }
96
+
97
+ #[pymethods]
98
+ impl Event {
99
+ #[new]
100
+ pub fn new(phrase: String, sc_id: usize, binary_relation: HashSet<(usize, usize)>) -> Self {
101
+ Event {
102
+ phrase,
103
+ sc_id,
104
+ binary_relation,
105
+ }
106
+ }
107
+ }
108
+
89
109
  #[pymethods]
90
110
  impl Hypergraph {
91
111
  #[new]
@@ -153,6 +173,25 @@ impl Hypergraph {
153
173
  .map(|(k, v)| (k.id(), v.into_iter().map(|n| n.id()).collect()))
154
174
  .collect()
155
175
  }
176
+
177
+ pub fn get_hyper_simulation_trace(&self) -> Vec<Event> {
178
+ let trace = HyperSimulationTrace::get_trace("hyper_simulation.trace").unwrap();
179
+ let events = trace.into_iter().map(|event| {
180
+ match event {
181
+ HSEvent::Base(sc_id, relation) => Event {
182
+ phrase: "base".to_string(),
183
+ sc_id,
184
+ binary_relation: relation
185
+ },
186
+ HSEvent::Derivation(sc_id, relation) => Event {
187
+ phrase: "derivation".to_string(),
188
+ sc_id,
189
+ binary_relation: relation
190
+ }
191
+ }
192
+ }).collect();
193
+ events
194
+ }
156
195
  }
157
196
 
158
197
  impl Display for Node {
@@ -381,9 +420,8 @@ impl DMatchImpl {
381
420
  }
382
421
  }
383
422
 
384
- // #[pyclass(name = "Delta")]
385
423
  struct DeltaImpl<'a> {
386
- sematic_cluster: HashMap<(&'a Node, &'a Node), Vec<(SematicCluster<'a, Hyperedge>, SematicCluster<'a, Hyperedge>)>>
424
+ sematic_cluster: HashMap<(&'a Node, &'a Node), Vec<(SematicCluster<'a, Hyperedge>, SematicCluster<'a, Hyperedge>)>>,
387
425
  }
388
426
 
389
427
  impl<'a> Delta<'a> for DeltaImpl<'a> {
@@ -414,12 +452,16 @@ impl<'a> DeltaImpl<'a> {
414
452
 
415
453
  let sc_q = SematicCluster::new(q_id, q_edges);
416
454
  let sc_d = SematicCluster::new(d_id, d_edges);
455
+ // Update sematic_cluster_cache
417
456
 
457
+ // sematic_cluster_cache.insert((&sc_q, &sc_d), q_id);
458
+
418
459
  pair_map.entry((u, v)).or_default().push((sc_q, sc_d));
419
460
  }
420
461
  }
462
+
421
463
  let res = DeltaImpl {
422
- sematic_cluster: pair_map
464
+ sematic_cluster: pair_map,
423
465
  };
424
466
 
425
467
  return res;
@@ -431,7 +473,7 @@ impl<'a> DeltaImpl<'a> {
431
473
  #[derive(Clone)]
432
474
  #[pyclass(name = "Delta")]
433
475
  pub struct DeltaPy {
434
- sematic_cluster_cache: HashMap<(usize, usize), Vec<((Vec<usize>, usize), (Vec<usize>, usize))>>,
476
+ sematic_cluster_cache: HashMap<(usize, usize), Vec<((Vec<usize>, usize), (Vec<usize>, usize))>>, // (u_id, v_id) -> Vec<((q_edge_ids, sc_id), (d_edge_ids, sc_id))>
435
477
  global_cnt: usize
436
478
  }
437
479
 
@@ -13,6 +13,7 @@ fn simulation(m: &Bound<'_, PyModule>) -> PyResult<()> {
13
13
  m.add_class::<graph::hypergraph::LMatchImpl>()?;
14
14
  m.add_class::<graph::hypergraph::DeltaPy>()?;
15
15
  m.add_class::<graph::hypergraph::DMatchImpl>()?;
16
+ m.add_class::<graph::hypergraph::Event>()?;
16
17
 
17
18
  m.add_function(wrap_pyfunction!(graph::networkx_graph::get_simulation_inter, m)?)?;
18
19
  m.add_function(wrap_pyfunction!(graph::networkx_graph::get_simulation_inter_fn, m)?)?;
File without changes
File without changes
File without changes