{"slug": "show-hn-dynafx-simulation-meets-knowledge-graphs", "title": "Show HN: DynaFX – Simulation meets knowledge graphs", "summary": "DynaFX, an open-source, Python-native simulation framework, integrates system dynamics, agent-based modeling, and discrete-event simulation with a knowledge-graph engine supporting RDF/OWL/SPARQL semantics. Version 0.2.0, released on GitHub, enables runtime KB queries, evidence write-back, and closed-loop reasoning-simulation cycles for decision support. The framework provides a .sysd DSL, RK4/Euler integration, SPARQL evaluation, RDFS/OWL RL inference, and unified state management across all three simulation paradigms.", "body_md": "Multi-paradigm simulation (**SD + ABM + DES**) with a knowledge-graph engine — RDF/OWL/SPARQL semantics, production rules, and closed-loop KB↔simulation reasoning for decision support.\n\nMost simulation tools stop at modeling. DynaFX goes further — your models can **query knowledge graphs at runtime**, **let KB facts steer the dynamics**, and **write simulation results back as evidence** that rules and optimization can act on. It is open-source, Python-native, and designed so that simulation and reasoning are not separate tools but a single connected system.\n\nDynaFX provides a `.sysd`\n\nDSL for building stock-and-flow models with full arithmetic, lookup tables, and comparisons. The engine supports RK4 and Euler integration, automatic topological sorting of auxiliary variables, and higher-order delays (SMOOTH, SMOOTHI, DELAY3, DELAYN, DELAY_FIXED, CONVEY_BATCH). Time functions like PULSE, STEP, RAMP, and NOISE are built in.\n\nThe knowledge engine is built on a full RDF stack: a triple data model (NamedNode, BlankNode, Literal, Triple), a `TripleStore`\n\nwith SPO/POS/OSP indices and named graphs, and a Turtle/N-Triples parser and serializer. SPARQL queries can be evaluated directly against the store. RDFS inference (7 rules) and OWL RL inference (4 rules) run as forward-chaining passes.\n\nDynaFX supports agent-based modeling with typed properties, rule-based behavior, and a perceive-decide-act cycle. Agents evaluate conditions (comparisons against aux/stock values, or `always`\n\n), apply effects (`+=`\n\n, `-=`\n\n, `*=`\n\n, `/=`\n\n, absolute `=`\n\n), and clamp properties to valid ranges.\n\nRules are scoped to strategies, and agents can switch strategies mid-simulation with a configurable cooldown. Meta-rules allow behavior that activates before or after the current strategy's rules. Agents communicate via topic-based message passing (`SEND`\n\n), and a perceived inbox aggregates messages per step. The 4-step cycle (Deliver → Decide → Cleanup → Aggregate) ensures deterministic execution order. Aggregated metrics are collected per step for analysis.\n\nThe DES engine provides queues with capacity limits and service time expressions, multi-server departure processing, and resource pools with capacity constraints. Queue and resource utilization statistics (`QueueStats`\n\n, `ResourceStats`\n\n) are tracked automatically. Per-step DES metrics are merged into the shared aux namespace, so SD and ABM components can read queue lengths, utilization, and other DES state directly.\n\nSD, ABM, and DES share a unified state dictionary — all three paradigms read and write to the same namespace. A single `.sysd`\n\nfile can contain stocks, flows, agents, queues, and resources. DES queues can read ABM agent properties and SD aux values.\n\nThe `KBSimBridge`\n\nconnects the knowledge graph to the simulation: it extracts parameters from the KB, injects them into the model, and after simulation writes evidence triples back. `KB_QUERY`\n\ncan be used inside `.sysd`\n\nauxiliary expressions and ABM agent rules to read from the knowledge graph at runtime. `KB_ASSERT`\n\nallows agents to update the KB mid-simulation. The `ClosedLoopReasoner`\n\norchestrates multi-pass reasoning-simulation cycles where each pass informs the next.\n\nDownload the wheel from [GitHub Releases](https://github.com/Achref-Yak/DynaFX/releases/tag/v0.2.0):\n\n```\npip install dynafx-0.2.0-py3-none-any.whl\n```\n\nOr install from source:\n\n```\ngit clone https://github.com/Achref-Yak/DynaFX.git\ncd DynaFX\nuv pip install -e \".[all]\"\npython\nfrom dynafx import parse_sysd_file\n\nmodel = parse_sysd_file(\"data/models/global_solar_epc.sysd\")\nresult = model.simulate()\n\nprint(result.values[\"Global_Panel_Supply\"][-1])\nresult.plot(\"out.png\", stocks=[\"Global_Panel_Supply\"])\npython\nfrom dynafx import parse_turtle, grade_queries\n\nstore = parse_turtle(\"\"\"\n    @prefix ex: <http://ex.org/> .\n    ex:portfolio ex:revenue 950.0 .\n\"\"\")\n\nquery = \"PREFIX ex: <http://ex.org/> SELECT ?v WHERE { ex:portfolio ex:revenue ?v }\"\ngrades = grade_queries([(query, \"v\", 0.5, 0.0)], store)\nprint(grades)   # {'0': 1.0} — score in [0, 1]\npytest tests/ -q\n```\n\nModels can **query the knowledge graph at runtime** via `KB_QUERY`\n\nand **update it** via `KB_ASSERT`\n\n— the simulation and knowledge layers are bidirectionally connected.\n\nSee [CONTRIBUTING.md](/Achref-Yak/DynaFX/blob/main/CONTRIBUTING.md) for development setup and pull request guidelines. All contributions are welcome.\n\nMIT", "url": "https://wpnews.pro/news/show-hn-dynafx-simulation-meets-knowledge-graphs", "canonical_source": "https://github.com/Achref-Yak/DynaFX", "published_at": "2026-08-13 19:56:46+00:00", "updated_at": "2026-08-13 20:12:13.947507+00:00", "lang": "en", "topics": ["ai-tools", "ai-infrastructure"], "entities": ["DynaFX", "GitHub", "RDF", "OWL", "SPARQL", "KBSimBridge", "ClosedLoopReasoner"], "alternates": {"html": "https://wpnews.pro/news/show-hn-dynafx-simulation-meets-knowledge-graphs", "markdown": "https://wpnews.pro/news/show-hn-dynafx-simulation-meets-knowledge-graphs.md", "text": "https://wpnews.pro/news/show-hn-dynafx-simulation-meets-knowledge-graphs.txt", "jsonld": "https://wpnews.pro/news/show-hn-dynafx-simulation-meets-knowledge-graphs.jsonld"}}