tnfr 4.0.0__tar.gz → 4.3.0__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.
- {tnfr-4.0.0/src/tnfr.egg-info → tnfr-4.3.0}/PKG-INFO +12 -4
- {tnfr-4.0.0 → tnfr-4.3.0}/README.md +9 -1
- {tnfr-4.0.0 → tnfr-4.3.0}/pyproject.toml +6 -4
- {tnfr-4.0.0 → tnfr-4.3.0}/src/tnfr/__init__.py +54 -50
- {tnfr-4.0.0 → tnfr-4.3.0}/src/tnfr/cli.py +94 -1
- {tnfr-4.0.0 → tnfr-4.3.0}/src/tnfr/constants.py +30 -23
- {tnfr-4.0.0 → tnfr-4.3.0}/src/tnfr/dynamics.py +99 -33
- {tnfr-4.0.0 → tnfr-4.3.0}/src/tnfr/gamma.py +28 -9
- {tnfr-4.0.0 → tnfr-4.3.0}/src/tnfr/grammar.py +6 -0
- {tnfr-4.0.0 → tnfr-4.3.0}/src/tnfr/helpers.py +27 -1
- {tnfr-4.0.0 → tnfr-4.3.0}/src/tnfr/metrics.py +50 -27
- {tnfr-4.0.0 → tnfr-4.3.0}/src/tnfr/operators.py +59 -20
- {tnfr-4.0.0 → tnfr-4.3.0}/src/tnfr/presets.py +5 -1
- {tnfr-4.0.0 → tnfr-4.3.0}/src/tnfr/program.py +8 -0
- {tnfr-4.0.0 → tnfr-4.3.0}/src/tnfr/scenarios.py +9 -3
- {tnfr-4.0.0 → tnfr-4.3.0}/src/tnfr/sense.py +6 -21
- {tnfr-4.0.0 → tnfr-4.3.0}/src/tnfr/trace.py +15 -26
- {tnfr-4.0.0 → tnfr-4.3.0/src/tnfr.egg-info}/PKG-INFO +12 -4
- {tnfr-4.0.0 → tnfr-4.3.0}/src/tnfr.egg-info/SOURCES.txt +2 -0
- tnfr-4.3.0/tests/test_canon.py +30 -0
- {tnfr-4.0.0 → tnfr-4.3.0}/tests/test_edge_cases.py +1 -0
- tnfr-4.3.0/tests/test_history_series.py +27 -0
- {tnfr-4.0.0 → tnfr-4.3.0}/tests/test_invariants.py +5 -0
- {tnfr-4.0.0 → tnfr-4.3.0}/tests/test_remesh.py +19 -0
- {tnfr-4.0.0 → tnfr-4.3.0}/LICENSE.md +0 -0
- {tnfr-4.0.0 → tnfr-4.3.0}/setup.cfg +0 -0
- {tnfr-4.0.0 → tnfr-4.3.0}/src/tnfr/main.py +0 -0
- {tnfr-4.0.0 → tnfr-4.3.0}/src/tnfr/observers.py +0 -0
- {tnfr-4.0.0 → tnfr-4.3.0}/src/tnfr/ontosim.py +0 -0
- {tnfr-4.0.0 → tnfr-4.3.0}/src/tnfr/types.py +0 -0
- {tnfr-4.0.0 → tnfr-4.3.0}/src/tnfr.egg-info/dependency_links.txt +0 -0
- {tnfr-4.0.0 → tnfr-4.3.0}/src/tnfr.egg-info/entry_points.txt +0 -0
- {tnfr-4.0.0 → tnfr-4.3.0}/src/tnfr.egg-info/requires.txt +0 -0
- {tnfr-4.0.0 → tnfr-4.3.0}/src/tnfr.egg-info/top_level.txt +0 -0
- {tnfr-4.0.0 → tnfr-4.3.0}/tests/test_cli_sanity.py +0 -0
- {tnfr-4.0.0 → tnfr-4.3.0}/tests/test_gamma.py +0 -0
- {tnfr-4.0.0 → tnfr-4.3.0}/tests/test_grammar.py +0 -0
- {tnfr-4.0.0 → tnfr-4.3.0}/tests/test_history.py +0 -0
- {tnfr-4.0.0 → tnfr-4.3.0}/tests/test_program.py +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tnfr
|
|
3
|
-
Version: 4.
|
|
4
|
-
Summary: TNFR
|
|
3
|
+
Version: 4.3.0
|
|
4
|
+
Summary: Canonical TNFR: modular glyph-based dynamics on networks.
|
|
5
5
|
Author: fmg
|
|
6
6
|
License: MIT
|
|
7
7
|
Project-URL: Homepage, https://pypi.org/project/tnfr/
|
|
8
8
|
Project-URL: Repository, https://github.com/fermga/Teoria-de-la-naturaleza-fractal-resonante-TNFR-
|
|
9
|
-
Keywords: TNFR,fractal
|
|
9
|
+
Keywords: TNFR,resonant fractal,resonance,glyphs,networkx,dynamics,coherence,EPI,Kuramoto
|
|
10
10
|
Classifier: Programming Language :: Python :: 3
|
|
11
11
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
12
12
|
Classifier: Programming Language :: Python :: 3.9
|
|
@@ -25,7 +25,13 @@ License-File: LICENSE.md
|
|
|
25
25
|
Requires-Dist: networkx>=2.6
|
|
26
26
|
Dynamic: license-file
|
|
27
27
|
|
|
28
|
-
#
|
|
28
|
+
# TNFR — Canonical Glyph-Based Dynamics
|
|
29
|
+
|
|
30
|
+
Reference implementation of the Resonant Fractal Nature Theory (TNFR).
|
|
31
|
+
It models glyph-driven dynamics on NetworkX graphs, providing a modular
|
|
32
|
+
engine to simulate coherent reorganization processes.
|
|
33
|
+
|
|
34
|
+
## General Project Structure
|
|
29
35
|
|
|
30
36
|
* **Package entry point.** `__init__.py` registers modules under short names to avoid circular imports and exposes the public API: `preparar_red`, `step`, `run`, and observation utilities.
|
|
31
37
|
|
|
@@ -59,6 +65,8 @@ Dynamic: license-file
|
|
|
59
65
|
|
|
60
66
|
* **Network re-mesh.** Mixes the current state with a past one (memory `τ`) to stabilize the network, with clear precedence for `α` and conditions based on recent stability and synchrony history.
|
|
61
67
|
|
|
68
|
+
* **Γ(R) coupling.** Optional network term added to the nodal equation, parameterized by global phase order `R` with gain `β` and threshold `R0` (see `DEFAULTS["GAMMA"]`).
|
|
69
|
+
|
|
62
70
|
* **Callbacks & observers.** The `Γ(R)` system lets you hook functions before/after each step and after re-mesh, enabling monitoring or external intervention.
|
|
63
71
|
|
|
64
72
|
---
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
#
|
|
1
|
+
# TNFR — Canonical Glyph-Based Dynamics
|
|
2
|
+
|
|
3
|
+
Reference implementation of the Resonant Fractal Nature Theory (TNFR).
|
|
4
|
+
It models glyph-driven dynamics on NetworkX graphs, providing a modular
|
|
5
|
+
engine to simulate coherent reorganization processes.
|
|
6
|
+
|
|
7
|
+
## General Project Structure
|
|
2
8
|
|
|
3
9
|
* **Package entry point.** `__init__.py` registers modules under short names to avoid circular imports and exposes the public API: `preparar_red`, `step`, `run`, and observation utilities.
|
|
4
10
|
|
|
@@ -32,6 +38,8 @@
|
|
|
32
38
|
|
|
33
39
|
* **Network re-mesh.** Mixes the current state with a past one (memory `τ`) to stabilize the network, with clear precedence for `α` and conditions based on recent stability and synchrony history.
|
|
34
40
|
|
|
41
|
+
* **Γ(R) coupling.** Optional network term added to the nodal equation, parameterized by global phase order `R` with gain `β` and threshold `R0` (see `DEFAULTS["GAMMA"]`).
|
|
42
|
+
|
|
35
43
|
* **Callbacks & observers.** The `Γ(R)` system lets you hook functions before/after each step and after re-mesh, enabling monitoring or external intervention.
|
|
36
44
|
|
|
37
45
|
---
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "tnfr"
|
|
3
|
-
version = "4.
|
|
4
|
-
description = "TNFR
|
|
3
|
+
version = "4.3.0"
|
|
4
|
+
description = "Canonical TNFR: modular glyph-based dynamics on networks."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.9"
|
|
7
7
|
license = { text = "MIT" }
|
|
8
8
|
authors = [{ name = "fmg" }]
|
|
9
9
|
keywords = [
|
|
10
|
-
"TNFR", "fractal
|
|
11
|
-
"networkx", "
|
|
10
|
+
"TNFR", "resonant fractal", "resonance", "glyphs",
|
|
11
|
+
"networkx", "dynamics", "coherence", "EPI", "Kuramoto"
|
|
12
12
|
]
|
|
13
13
|
classifiers = [
|
|
14
14
|
"Programming Language :: Python :: 3",
|
|
@@ -37,3 +37,5 @@ Repository = "https://github.com/fermga/Teoria-de-la-naturaleza-fractal-resonant
|
|
|
37
37
|
[build-system]
|
|
38
38
|
requires = ["setuptools>=61", "wheel"]
|
|
39
39
|
build-backend = "setuptools.build_meta"
|
|
40
|
+
|
|
41
|
+
|
|
@@ -1,57 +1,61 @@
|
|
|
1
|
-
|
|
2
|
-
from __future__ import annotations
|
|
3
|
-
"""
|
|
4
|
-
TNFR — Teoría de la Naturaleza Fractal Resonante
|
|
5
|
-
API pública del paquete.
|
|
6
|
-
|
|
7
|
-
Ecuación nodal:
|
|
8
|
-
∂EPI/∂t = νf · ΔNFR(t)
|
|
9
|
-
"""
|
|
10
|
-
|
|
11
|
-
__version__ = "4.
|
|
12
|
-
|
|
13
|
-
# Re-exports de la API pública
|
|
14
|
-
from .dynamics import step, run, set_delta_nfr_hook
|
|
15
|
-
from .ontosim import preparar_red
|
|
16
|
-
from .observers import attach_standard_observer, coherencia_global, orden_kuramoto
|
|
17
|
-
from .gamma import GAMMA_REGISTRY, eval_gamma, kuramoto_R_psi
|
|
18
|
-
from .grammar import enforce_canonical_grammar, on_applied_glifo
|
|
19
|
-
from .sense import (
|
|
20
|
-
GLYPHS_CANONICAL, glyph_angle, glyph_unit,
|
|
21
|
-
sigma_vector_node, sigma_vector_global,
|
|
22
|
-
push_sigma_snapshot, sigma_series, sigma_rose,
|
|
23
|
-
register_sigma_callback,
|
|
24
|
-
)
|
|
1
|
+
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
"""
|
|
4
|
+
TNFR — Teoría de la Naturaleza Fractal Resonante
|
|
5
|
+
API pública del paquete.
|
|
6
|
+
|
|
7
|
+
Ecuación nodal:
|
|
8
|
+
∂EPI/∂t = νf · ΔNFR(t)
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
__version__ = "4.3.0"
|
|
12
|
+
|
|
13
|
+
# Re-exports de la API pública
|
|
14
|
+
from .dynamics import step, run, set_delta_nfr_hook, validate_canon
|
|
15
|
+
from .ontosim import preparar_red
|
|
16
|
+
from .observers import attach_standard_observer, coherencia_global, orden_kuramoto
|
|
17
|
+
from .gamma import GAMMA_REGISTRY, eval_gamma, kuramoto_R_psi
|
|
18
|
+
from .grammar import enforce_canonical_grammar, on_applied_glifo
|
|
19
|
+
from .sense import (
|
|
20
|
+
GLYPHS_CANONICAL, glyph_angle, glyph_unit,
|
|
21
|
+
sigma_vector_node, sigma_vector_global,
|
|
22
|
+
push_sigma_snapshot, sigma_series, sigma_rose,
|
|
23
|
+
register_sigma_callback,
|
|
24
|
+
)
|
|
25
25
|
from .metrics import (
|
|
26
26
|
register_metrics_callbacks,
|
|
27
27
|
Tg_global, Tg_by_node,
|
|
28
28
|
latency_series, glifogram_series,
|
|
29
|
-
glyph_top, glyph_dwell_stats,
|
|
29
|
+
glyph_top, glyph_dwell_stats, export_history,
|
|
30
30
|
)
|
|
31
|
-
from .trace import register_trace
|
|
32
|
-
from .program import play, seq, block, target, wait, THOL, TARGET, WAIT
|
|
33
|
-
from .cli import main as cli_main
|
|
34
|
-
from .scenarios import build_graph
|
|
35
|
-
from .presets import get_preset
|
|
36
|
-
from .types import NodeState
|
|
37
|
-
|
|
38
|
-
|
|
31
|
+
from .trace import register_trace
|
|
32
|
+
from .program import play, seq, block, target, wait, THOL, TARGET, WAIT, ejemplo_canonico_basico
|
|
33
|
+
from .cli import main as cli_main
|
|
34
|
+
from .scenarios import build_graph
|
|
35
|
+
from .presets import get_preset
|
|
36
|
+
from .types import NodeState
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
__all__ = [
|
|
39
40
|
"preparar_red",
|
|
40
|
-
"step", "run", "set_delta_nfr_hook",
|
|
41
|
-
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
41
|
+
"step", "run", "set_delta_nfr_hook", "validate_canon",
|
|
42
|
+
|
|
43
|
+
"attach_standard_observer", "coherencia_global", "orden_kuramoto",
|
|
44
|
+
"GAMMA_REGISTRY", "eval_gamma", "kuramoto_R_psi",
|
|
45
|
+
"enforce_canonical_grammar", "on_applied_glifo",
|
|
46
|
+
"GLYPHS_CANONICAL", "glyph_angle", "glyph_unit",
|
|
47
|
+
"sigma_vector_node", "sigma_vector_global",
|
|
48
|
+
"push_sigma_snapshot", "sigma_series", "sigma_rose",
|
|
49
|
+
"register_sigma_callback",
|
|
50
|
+
"register_metrics_callbacks",
|
|
51
|
+
"register_trace",
|
|
52
|
+
"Tg_global", "Tg_by_node",
|
|
53
|
+
"latency_series", "glifogram_series",
|
|
52
54
|
"glyph_top", "glyph_dwell_stats",
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
"export_history",
|
|
56
|
+
"play", "seq", "block", "target", "wait", "THOL", "TARGET", "WAIT",
|
|
57
|
+
"cli_main", "build_graph", "get_preset", "NodeState",
|
|
58
|
+
"ejemplo_canonico_basico",
|
|
59
|
+
"__version__",
|
|
60
|
+
]
|
|
61
|
+
|
|
@@ -18,10 +18,12 @@ from .metrics import (
|
|
|
18
18
|
latency_series,
|
|
19
19
|
glifogram_series,
|
|
20
20
|
glyph_top,
|
|
21
|
+
export_history,
|
|
21
22
|
)
|
|
22
23
|
from .trace import register_trace
|
|
23
24
|
from .program import play, seq, block, wait, target
|
|
24
|
-
from .dynamics import step, _update_history
|
|
25
|
+
from .dynamics import step, _update_history, default_glyph_selector, parametric_glyph_selector, validate_canon
|
|
26
|
+
from .gamma import GAMMA_REGISTRY
|
|
25
27
|
from .scenarios import build_graph
|
|
26
28
|
from .presets import get_preset
|
|
27
29
|
|
|
@@ -31,6 +33,24 @@ def _save_json(path: str, data: Any) -> None:
|
|
|
31
33
|
json.dump(data, f, ensure_ascii=False, indent=2)
|
|
32
34
|
|
|
33
35
|
|
|
36
|
+
def _str2bool(s: str) -> bool:
|
|
37
|
+
s = s.lower()
|
|
38
|
+
if s in {"true", "1", "yes", "y"}:
|
|
39
|
+
return True
|
|
40
|
+
if s in {"false", "0", "no", "n"}:
|
|
41
|
+
return False
|
|
42
|
+
raise argparse.ArgumentTypeError("expected true/false")
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def _args_to_dict(args: argparse.Namespace, prefix: str) -> Dict[str, Any]:
|
|
46
|
+
out: Dict[str, Any] = {}
|
|
47
|
+
pref = prefix.replace(".", "_")
|
|
48
|
+
for k, v in vars(args).items():
|
|
49
|
+
if k.startswith(pref) and v is not None:
|
|
50
|
+
out[k[len(pref):]] = v
|
|
51
|
+
return out
|
|
52
|
+
|
|
53
|
+
|
|
34
54
|
def _load_sequence(path: str) -> List[Any]:
|
|
35
55
|
with open(path, "r", encoding="utf-8") as f:
|
|
36
56
|
text = f.read()
|
|
@@ -72,6 +92,20 @@ def _attach_callbacks(G: nx.Graph) -> None:
|
|
|
72
92
|
def cmd_run(args: argparse.Namespace) -> int:
|
|
73
93
|
G = build_graph(n=args.nodes, topology=args.topology, seed=args.seed)
|
|
74
94
|
_attach_callbacks(G)
|
|
95
|
+
validate_canon(G)
|
|
96
|
+
gcanon = dict(DEFAULTS["GRAMMAR_CANON"])
|
|
97
|
+
gcanon.update(_args_to_dict(args, prefix="grammar."))
|
|
98
|
+
if hasattr(args, "grammar_canon") and args.grammar_canon is not None:
|
|
99
|
+
gcanon["enabled"] = bool(args.grammar_canon)
|
|
100
|
+
G.graph.setdefault("GRAMMAR_CANON", {}).update(gcanon)
|
|
101
|
+
if args.glyph_hysteresis_window is not None:
|
|
102
|
+
G.graph["GLYPH_HYSTERESIS_WINDOW"] = int(args.glyph_hysteresis_window)
|
|
103
|
+
G.graph["glyph_selector"] = default_glyph_selector if args.selector == "basic" else parametric_glyph_selector
|
|
104
|
+
G.graph["GAMMA"] = {
|
|
105
|
+
"type": args.gamma_type,
|
|
106
|
+
"beta": args.gamma_beta,
|
|
107
|
+
"R0": args.gamma_R0,
|
|
108
|
+
}
|
|
75
109
|
|
|
76
110
|
if args.preset:
|
|
77
111
|
program = get_preset(args.preset)
|
|
@@ -83,6 +117,8 @@ def cmd_run(args: argparse.Namespace) -> int:
|
|
|
83
117
|
|
|
84
118
|
if args.save_history:
|
|
85
119
|
_save_json(args.save_history, G.graph.get("history", {}))
|
|
120
|
+
if args.export_history_base:
|
|
121
|
+
export_history(G, args.export_history_base, fmt=args.export_format)
|
|
86
122
|
|
|
87
123
|
if args.summary:
|
|
88
124
|
tg = Tg_global(G, normalize=True)
|
|
@@ -96,6 +132,20 @@ def cmd_run(args: argparse.Namespace) -> int:
|
|
|
96
132
|
def cmd_sequence(args: argparse.Namespace) -> int:
|
|
97
133
|
G = build_graph(n=args.nodes, topology=args.topology, seed=args.seed)
|
|
98
134
|
_attach_callbacks(G)
|
|
135
|
+
validate_canon(G)
|
|
136
|
+
gcanon = dict(DEFAULTS["GRAMMAR_CANON"])
|
|
137
|
+
gcanon.update(_args_to_dict(args, prefix="grammar."))
|
|
138
|
+
if hasattr(args, "grammar_canon") and args.grammar_canon is not None:
|
|
139
|
+
gcanon["enabled"] = bool(args.grammar_canon)
|
|
140
|
+
G.graph.setdefault("GRAMMAR_CANON", {}).update(gcanon)
|
|
141
|
+
if args.glyph_hysteresis_window is not None:
|
|
142
|
+
G.graph["GLYPH_HYSTERESIS_WINDOW"] = int(args.glyph_hysteresis_window)
|
|
143
|
+
G.graph["glyph_selector"] = default_glyph_selector if args.selector == "basic" else parametric_glyph_selector
|
|
144
|
+
G.graph["GAMMA"] = {
|
|
145
|
+
"type": args.gamma_type,
|
|
146
|
+
"beta": args.gamma_beta,
|
|
147
|
+
"R0": args.gamma_R0,
|
|
148
|
+
}
|
|
99
149
|
|
|
100
150
|
if args.preset:
|
|
101
151
|
program = get_preset(args.preset)
|
|
@@ -108,12 +158,22 @@ def cmd_sequence(args: argparse.Namespace) -> int:
|
|
|
108
158
|
|
|
109
159
|
if args.save_history:
|
|
110
160
|
_save_json(args.save_history, G.graph.get("history", {}))
|
|
161
|
+
if args.export_history_base:
|
|
162
|
+
export_history(G, args.export_history_base, fmt=args.export_format)
|
|
111
163
|
return 0
|
|
112
164
|
|
|
113
165
|
|
|
114
166
|
def cmd_metrics(args: argparse.Namespace) -> int:
|
|
115
167
|
G = build_graph(n=args.nodes, topology=args.topology, seed=args.seed)
|
|
116
168
|
_attach_callbacks(G)
|
|
169
|
+
validate_canon(G)
|
|
170
|
+
G.graph.setdefault("GRAMMAR_CANON", DEFAULTS["GRAMMAR_CANON"]).update({"enabled": bool(args.grammar_canon)})
|
|
171
|
+
G.graph["glyph_selector"] = default_glyph_selector if args.selector == "basic" else parametric_glyph_selector
|
|
172
|
+
G.graph["GAMMA"] = {
|
|
173
|
+
"type": args.gamma_type,
|
|
174
|
+
"beta": args.gamma_beta,
|
|
175
|
+
"R0": args.gamma_R0,
|
|
176
|
+
}
|
|
117
177
|
for _ in range(int(args.steps or 200)):
|
|
118
178
|
step(G)
|
|
119
179
|
|
|
@@ -146,7 +206,22 @@ def main(argv: Optional[List[str]] = None) -> int:
|
|
|
146
206
|
p_run.add_argument("--seed", type=int, default=1)
|
|
147
207
|
p_run.add_argument("--preset", type=str, default=None)
|
|
148
208
|
p_run.add_argument("--save-history", dest="save_history", type=str, default=None)
|
|
209
|
+
p_run.add_argument("--export-history-base", dest="export_history_base", type=str, default=None)
|
|
210
|
+
p_run.add_argument("--export-format", dest="export_format", choices=["csv", "json"], default="json")
|
|
149
211
|
p_run.add_argument("--summary", action="store_true")
|
|
212
|
+
p_run.add_argument("--no-canon", dest="grammar_canon", action="store_false", default=True, help="Desactiva gramática canónica")
|
|
213
|
+
p_run.add_argument("--grammar.enabled", dest="grammar_enabled", type=_str2bool, default=None)
|
|
214
|
+
p_run.add_argument("--grammar.zhir_requires_oz_window", dest="grammar_zhir_requires_oz_window", type=int, default=None)
|
|
215
|
+
p_run.add_argument("--grammar.zhir_dnfr_min", dest="grammar_zhir_dnfr_min", type=float, default=None)
|
|
216
|
+
p_run.add_argument("--grammar.thol_min_len", dest="grammar_thol_min_len", type=int, default=None)
|
|
217
|
+
p_run.add_argument("--grammar.thol_max_len", dest="grammar_thol_max_len", type=int, default=None)
|
|
218
|
+
p_run.add_argument("--grammar.thol_close_dnfr", dest="grammar_thol_close_dnfr", type=float, default=None)
|
|
219
|
+
p_run.add_argument("--grammar.si_high", dest="grammar_si_high", type=float, default=None)
|
|
220
|
+
p_run.add_argument("--glyph.hysteresis_window", dest="glyph_hysteresis_window", type=int, default=None)
|
|
221
|
+
p_run.add_argument("--selector", choices=["basic", "param"], default="basic")
|
|
222
|
+
p_run.add_argument("--gamma-type", choices=list(GAMMA_REGISTRY.keys()), default="none")
|
|
223
|
+
p_run.add_argument("--gamma-beta", type=float, default=0.0)
|
|
224
|
+
p_run.add_argument("--gamma-R0", type=float, default=0.0)
|
|
150
225
|
p_run.set_defaults(func=cmd_run)
|
|
151
226
|
|
|
152
227
|
p_seq = sub.add_parser("sequence", help="Ejecutar una secuencia (preset o YAML/JSON)")
|
|
@@ -156,6 +231,19 @@ def main(argv: Optional[List[str]] = None) -> int:
|
|
|
156
231
|
p_seq.add_argument("--preset", type=str, default=None)
|
|
157
232
|
p_seq.add_argument("--sequence-file", type=str, default=None)
|
|
158
233
|
p_seq.add_argument("--save-history", dest="save_history", type=str, default=None)
|
|
234
|
+
p_seq.add_argument("--export-history-base", dest="export_history_base", type=str, default=None)
|
|
235
|
+
p_seq.add_argument("--export-format", dest="export_format", choices=["csv", "json"], default="json")
|
|
236
|
+
p_seq.add_argument("--gamma-type", choices=list(GAMMA_REGISTRY.keys()), default="none")
|
|
237
|
+
p_seq.add_argument("--gamma-beta", type=float, default=0.0)
|
|
238
|
+
p_seq.add_argument("--gamma-R0", type=float, default=0.0)
|
|
239
|
+
p_seq.add_argument("--grammar.enabled", dest="grammar_enabled", type=_str2bool, default=None)
|
|
240
|
+
p_seq.add_argument("--grammar.zhir_requires_oz_window", dest="grammar_zhir_requires_oz_window", type=int, default=None)
|
|
241
|
+
p_seq.add_argument("--grammar.zhir_dnfr_min", dest="grammar_zhir_dnfr_min", type=float, default=None)
|
|
242
|
+
p_seq.add_argument("--grammar.thol_min_len", dest="grammar_thol_min_len", type=int, default=None)
|
|
243
|
+
p_seq.add_argument("--grammar.thol_max_len", dest="grammar_thol_max_len", type=int, default=None)
|
|
244
|
+
p_seq.add_argument("--grammar.thol_close_dnfr", dest="grammar_thol_close_dnfr", type=float, default=None)
|
|
245
|
+
p_seq.add_argument("--grammar.si_high", dest="grammar_si_high", type=float, default=None)
|
|
246
|
+
p_seq.add_argument("--glyph.hysteresis_window", dest="glyph_hysteresis_window", type=int, default=None)
|
|
159
247
|
p_seq.set_defaults(func=cmd_sequence)
|
|
160
248
|
|
|
161
249
|
p_met = sub.add_parser("metrics", help="Correr breve y volcar métricas clave")
|
|
@@ -163,6 +251,11 @@ def main(argv: Optional[List[str]] = None) -> int:
|
|
|
163
251
|
p_met.add_argument("--topology", choices=["ring", "complete", "erdos"], default="ring")
|
|
164
252
|
p_met.add_argument("--steps", type=int, default=300)
|
|
165
253
|
p_met.add_argument("--seed", type=int, default=1)
|
|
254
|
+
p_met.add_argument("--no-canon", dest="grammar_canon", action="store_false", default=True, help="Desactiva gramática canónica")
|
|
255
|
+
p_met.add_argument("--selector", choices=["basic", "param"], default="basic")
|
|
256
|
+
p_met.add_argument("--gamma-type", choices=list(GAMMA_REGISTRY.keys()), default="none")
|
|
257
|
+
p_met.add_argument("--gamma-beta", type=float, default=0.0)
|
|
258
|
+
p_met.add_argument("--gamma-R0", type=float, default=0.0)
|
|
166
259
|
p_met.add_argument("--save", type=str, default=None)
|
|
167
260
|
p_met.set_defaults(func=cmd_metrics)
|
|
168
261
|
|
|
@@ -72,18 +72,25 @@ DEFAULTS: Dict[str, Any] = {
|
|
|
72
72
|
# Criterios de estabilidad (para activar RE’MESH de red)
|
|
73
73
|
"EPS_DNFR_STABLE": 1e-3,
|
|
74
74
|
"EPS_DEPI_STABLE": 1e-3,
|
|
75
|
-
"FRACTION_STABLE_REMESH": 0.80, # fracción de nodos estables requerida
|
|
76
|
-
"REMESH_COOLDOWN_VENTANA": 20, # pasos mínimos entre RE’MESH
|
|
75
|
+
"FRACTION_STABLE_REMESH": 0.80, # fracción de nodos estables requerida
|
|
76
|
+
"REMESH_COOLDOWN_VENTANA": 20, # pasos mínimos entre RE’MESH
|
|
77
|
+
"REMESH_COOLDOWN_TS": 0.0, # cooldown adicional por tiempo simulado
|
|
77
78
|
# Gating adicional basado en observadores (conmutador + ventana)
|
|
78
|
-
"REMESH_REQUIRE_STABILITY": False, # si True, exige ventana de estabilidad multi-métrica
|
|
79
|
-
"REMESH_STABILITY_WINDOW": 25, # tamaño de ventana para evaluar estabilidad
|
|
80
|
-
"REMESH_MIN_PHASE_SYNC": 0.85, # media mínima de sincronía de fase en ventana
|
|
81
|
-
"REMESH_MAX_GLYPH_DISR": 0.35, # media máxima de carga glífica disruptiva en ventana
|
|
82
|
-
"
|
|
83
|
-
|
|
84
|
-
#
|
|
85
|
-
"
|
|
86
|
-
|
|
79
|
+
"REMESH_REQUIRE_STABILITY": False, # si True, exige ventana de estabilidad multi-métrica
|
|
80
|
+
"REMESH_STABILITY_WINDOW": 25, # tamaño de ventana para evaluar estabilidad
|
|
81
|
+
"REMESH_MIN_PHASE_SYNC": 0.85, # media mínima de sincronía de fase en ventana
|
|
82
|
+
"REMESH_MAX_GLYPH_DISR": 0.35, # media máxima de carga glífica disruptiva en ventana
|
|
83
|
+
"REMESH_MIN_SIGMA_MAG": 0.50, # magnitud mínima de σ en ventana
|
|
84
|
+
"REMESH_MIN_KURAMOTO_R": 0.80, # R de Kuramoto mínimo en ventana
|
|
85
|
+
"REMESH_MIN_SI_HI_FRAC": 0.50, # fracción mínima de nodos con Si alto
|
|
86
|
+
"REMESH_LOG_EVENTS": True, # guarda eventos y metadatos del RE’MESH
|
|
87
|
+
|
|
88
|
+
# RE’MESH: memoria τ y mezcla α (global/local)
|
|
89
|
+
"REMESH_TAU": 8, # compatibilidad: tau global por defecto
|
|
90
|
+
"REMESH_TAU_GLOBAL": 8, # pasos hacia atrás (escala global)
|
|
91
|
+
"REMESH_TAU_LOCAL": 4, # pasos hacia atrás (escala local)
|
|
92
|
+
"REMESH_ALPHA": 0.5, # mezcla con pasado
|
|
93
|
+
"REMESH_ALPHA_HARD": False, # si True ignora GLYPH_FACTORS['REMESH_alpha']
|
|
87
94
|
|
|
88
95
|
# Histéresis glífica
|
|
89
96
|
"GLYPH_HYSTERESIS_WINDOW": 7,
|
|
@@ -92,13 +99,13 @@ DEFAULTS: Dict[str, Any] = {
|
|
|
92
99
|
"GLYPH_SELECTOR_MARGIN": 0.05,
|
|
93
100
|
|
|
94
101
|
# Ventana para estimar la carga glífica en history/plots
|
|
95
|
-
"GLYPH_LOAD_WINDOW": 50,
|
|
102
|
+
"GLYPH_LOAD_WINDOW": 50,
|
|
96
103
|
|
|
97
104
|
# Tamaño de ventana para coherencia promedio W̄
|
|
98
105
|
"WBAR_WINDOW": 25,
|
|
99
106
|
|
|
100
107
|
# Factores suaves por glifo (operadores)
|
|
101
|
-
"GLYPH_FACTORS": {
|
|
108
|
+
"GLYPH_FACTORS": {
|
|
102
109
|
"AL_boost": 0.05, # A’L — pequeña emisión
|
|
103
110
|
"EN_mix": 0.25, # E’N — mezcla con vecindad
|
|
104
111
|
"IL_dnfr_factor": 0.7, # I’L — reduce ΔNFR
|
|
@@ -107,7 +114,7 @@ DEFAULTS: Dict[str, Any] = {
|
|
|
107
114
|
"RA_epi_diff": 0.15, # R’A — difusión EPI
|
|
108
115
|
"SHA_vf_factor": 0.85, # SH’A — baja νf
|
|
109
116
|
"VAL_scale": 1.15, # VA’L — expande EPI
|
|
110
|
-
"NUL_scale": 0.85, # NU’L — contrae EPI
|
|
117
|
+
"NUL_scale": 0.85, # NU’L — contrae EPI
|
|
111
118
|
"THOL_accel": 0.10, # T’HOL — acelera (seg. deriv.) si hay umbral
|
|
112
119
|
"ZHIR_theta_shift": 1.57079632679, # Z’HIR — desplazamiento ~π/2
|
|
113
120
|
"NAV_jitter": 0.05, # NA’V — pequeña inestabilidad creativa
|
|
@@ -154,6 +161,7 @@ DEFAULTS: Dict[str, Any] = {
|
|
|
154
161
|
"R0": 0.0,
|
|
155
162
|
},
|
|
156
163
|
"CALLBACKS_STRICT": False, # si True, un error en callback detiene; si False, se loguea y continúa
|
|
164
|
+
"VALIDATORS_STRICT": False, # si True, alerta si se clampa fuera de rango
|
|
157
165
|
}
|
|
158
166
|
|
|
159
167
|
# Gramática glífica canónica
|
|
@@ -174,11 +182,7 @@ DEFAULTS.setdefault("GRAMMAR_CANON", {
|
|
|
174
182
|
|
|
175
183
|
def attach_defaults(G, override: bool = False) -> None:
|
|
176
184
|
"""Escribe DEFAULTS en G.graph (sin sobreescribir si override=False)."""
|
|
177
|
-
G
|
|
178
|
-
for k, v in DEFAULTS.items():
|
|
179
|
-
if override or k not in G.graph:
|
|
180
|
-
G.graph[k] = v
|
|
181
|
-
G.graph["_tnfr_defaults_attached"] = True
|
|
185
|
+
inject_defaults(G, DEFAULTS, override=override)
|
|
182
186
|
|
|
183
187
|
|
|
184
188
|
def inject_defaults(G, defaults: Dict[str, Any] = DEFAULTS, override: bool = False) -> None:
|
|
@@ -207,7 +211,10 @@ def merge_overrides(G, **overrides) -> None:
|
|
|
207
211
|
ALIAS_VF = ("νf", "nu_f", "nu-f", "nu", "freq", "frequency")
|
|
208
212
|
ALIAS_THETA = ("θ", "theta", "fase", "phi", "phase")
|
|
209
213
|
ALIAS_DNFR = ("ΔNFR", "delta_nfr", "dnfr")
|
|
210
|
-
ALIAS_EPI = ("EPI", "psi", "PSI", "value")
|
|
211
|
-
ALIAS_SI = ("Si", "sense_index", "S_i", "sense", "meaning_index")
|
|
212
|
-
ALIAS_dEPI = ("dEPI_dt", "dpsi_dt", "dEPI", "velocity")
|
|
213
|
-
ALIAS_D2EPI = ("d2EPI_dt2", "d2psi_dt2", "d2EPI", "accel")
|
|
214
|
+
ALIAS_EPI = ("EPI", "psi", "PSI", "value")
|
|
215
|
+
ALIAS_SI = ("Si", "sense_index", "S_i", "sense", "meaning_index")
|
|
216
|
+
ALIAS_dEPI = ("dEPI_dt", "dpsi_dt", "dEPI", "velocity")
|
|
217
|
+
ALIAS_D2EPI = ("d2EPI_dt2", "d2psi_dt2", "d2EPI", "accel")
|
|
218
|
+
ALIAS_dVF = ("dνf_dt", "dvf_dt", "dnu_dt", "dvf")
|
|
219
|
+
ALIAS_D2VF = ("d2νf_dt2", "d2vf_dt2", "d2nu_dt2", "B")
|
|
220
|
+
ALIAS_dSI = ("δSi", "delta_Si", "dSi")
|