{"id":40254623,"url":"https://github.com/joshmcdonagh/modelarium","last_synced_at":"2026-04-16T06:02:30.677Z","repository":{"id":265805370,"uuid":"896258341","full_name":"JoshMcDonagh/Modelarium","owner":"JoshMcDonagh","description":"Modelarium is a modular, extensible, and multithreaded agent-based modelling (ABM) framework for Java.","archived":false,"fork":false,"pushed_at":"2026-04-12T20:28:46.000Z","size":671,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-12T21:23:36.927Z","etag":null,"topics":["agent-based","agent-based-framework","agent-based-model","agent-based-modeling","agent-based-simulation","agents","java","library","multithreaded"],"latest_commit_sha":null,"homepage":"https://modelarium.dev/","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JoshMcDonagh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-11-29T22:32:19.000Z","updated_at":"2026-03-29T19:21:19.000Z","dependencies_parsed_at":"2024-12-01T02:24:19.787Z","dependency_job_id":"811dc382-30a4-4f65-9117-93cd1ee58b2b","html_url":"https://github.com/JoshMcDonagh/Modelarium","commit_stats":null,"previous_names":["joshmcdonagh/agentarium-for-java","joshmcdonagh/agentarium-abm-library-for-java","joshmcdonagh/modelarium"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/JoshMcDonagh/Modelarium","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoshMcDonagh%2FModelarium","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoshMcDonagh%2FModelarium/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoshMcDonagh%2FModelarium/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoshMcDonagh%2FModelarium/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JoshMcDonagh","download_url":"https://codeload.github.com/JoshMcDonagh/Modelarium/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoshMcDonagh%2FModelarium/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31873606,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-15T15:24:51.572Z","status":"online","status_checked_at":"2026-04-16T02:00:06.042Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agent-based","agent-based-framework","agent-based-model","agent-based-modeling","agent-based-simulation","agents","java","library","multithreaded"],"created_at":"2026-01-20T01:34:20.240Z","updated_at":"2026-04-16T06:02:30.672Z","avatar_url":"https://github.com/JoshMcDonagh.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Modelarium Library for Agent-Based Modelling in Java\n\n**Modelarium** is a modular, extensible, and multithreaded agent-based modelling (ABM) framework for Java. It provides a flexible architecture for defining agents, environments, and behaviours using composable attributes, and supports high-performance simulation with optional cross-thread coordination.\n\n## Documentation\n\nAPI (Javadoc): https://joshmcdonagh.github.io/Modelarium/\n\n## Highlights\n\n- Attribute-based modelling of agents and environments  \n- Multi-core execution with optional cross-thread synchronisation  \n- Pluggable schedulers (in-order, random, or custom)  \n- Configurable results recording to memory or SQLite  \n- Warm-up ticks supported (run simulation without recording, then record)\n\n## Requirements\n\n- Java 21  \n- Maven\n\n\u003e CI is configured for Java 21. If you run tests locally with a newer JDK, Mockito/Byte Buddy may fail when instrumenting classes.\n\n## Installation (Maven Central)\n\nModelarium is published to Maven Central. Add it to your `pom.xml`:\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003edev.modelarium\u003c/groupId\u003e\n  \u003cartifactId\u003emodelarium\u003c/artifactId\u003e\n  \u003cversion\u003e1.2.1\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nThen build your project as usual:\n```bash\nmvn clean package\n```\n## Building from source\n\nClone and run tests:\n\n```bash\nmvn -B test\n```\n\nBuild a jar:\n\n```bash\nmvn -B package\n```\n\nInstall to your local Maven repository:\n\n```bash\nmvn -B install\n```\n\n## Core concepts\n\n- ModelElement - base concept for agents and environments  \n- Attribute / Property / Event - defines state and behaviour run each tick  \n- AttributeSet - groups related attributes and controls execution order  \n- AttributeSetCollection - attached to a ModelElement; runs all its sets  \n- AgentSet - collection of named agents  \n- AgentGenerator - defines how agents are created  \n- Environment - shared component ticked after agents  \n- EnvironmentGenerator - defines how the environment is created  \n- ModelScheduler - tick policy (in order, random, or custom)  \n- Results - stores raw and processed simulation outputs  \n\n## Built-in attributes\n\nModelarium provides a set of built-in properties, events, and actions to reduce the need for custom implementations.\n\nThese can be composed to define common behaviours without writing new classes.\n\n### Properties\n\n- `ConstantDoubleProperty` - immutable numeric value\n- `AddDoubleProperty` - increments a value each tick using a reference\n- `ClampDoubleProperty` - constrains a value within bounds\n- `CopyDoubleProperty` - derives its value from another property\n\n### Value references\n\n- `LiteralDoubleRef` - fixed numeric value\n- `PropertyDoubleRef` - resolves a value from another property at runtime\n\n### Actions\n\n- `SetDoubleAction` - sets a property to a value\n- `AddDoubleAction` - increments a property\n- `SetBooleanAction` - sets a boolean property\n- `ToggleBooleanAction` - toggles a boolean property\n\n### Events\n\n- `TimerEvent` - triggers periodically based on tick count\n- `ThresholdCrossingEvent` - triggers when a property crosses a threshold\n\n### Example\n\n```java\n// Hunger increases over time but is capped at 100\nAddDoubleProperty hunger = new AddDoubleProperty(\"hunger\", true,\n                new LiteralDoubleRef(1.0)\n        );\n\nClampDoubleProperty boundedHunger = new ClampDoubleProperty(\n        \"boundedHunger\",\n        true,\n        hunger,\n        0.0,\n        100.0\n);\n```\n\n## Extending Modelarium\n\nModelarium is designed to be extended with custom attributes.\n\n### Custom properties\n\nTo implement a custom `Property\u003cT\u003e`:\n\n- Extend `Property\u003cT\u003e`\n- Implement `get()` and `set()` as required\n- Provide a copy constructor\n\nExample:\n\n```java\npublic class MyProperty extends Property\u003cDouble\u003e {\n    public MyProperty(MyProperty other) {\n        super(other);\n        // copy fields here\n    }\n    \n    @Override\n    public Double get() { ... }\n    \n    @Override \n    public void set(Double value) { ... }\n}\n```\n\nImportant:\n\nModelarium uses reflection-based copying. Your property must provide a copy constructor taking its own type or deep copying will fail at runtime.\n\n### Custom events\n\nCustom `Event` implementations should:\n\n- Define `isTriggered()`\n- Define `run()`\n- Maintain any required internal state (for example, previous values for threshold logic)\n\nProviding a copy constructor is recommended if your event stores state.\n\n## Quickstart example\n\nA model run is driven by `ModelSettings`. The following example configures and runs a simple simulation model:\n\n```java\nModelSettings settings = new ModelSettings();\n\nsettings.setNumOfAgents(10);\nsettings.setNumOfCores(2);\nsettings.setNumOfTicksToRun(20);\nsettings.setNumOfWarmUpTicks(10);\n\nsettings.setBaseAgentAttributeSetCollection(\n    ModelAttributes.getAgentAttributeSetCollection()\n);\nsettings.setBaseEnvironmentAttributeSetCollection(\n    ModelAttributes.getEnvironmentAttributeSetCollection()\n);\n\nsettings.setAreProcessesSynced(true);\nsettings.setIsCacheUsed(true);\n\nsettings.setResultsClass(ModelResults.class);\nsettings.setResults(new ModelResults());\n\nsettings.setAgentGenerator(new DefaultAgentGenerator());\nsettings.setEnvironmentGenerator(new DefaultEnvironmentGenerator());\nsettings.setModelScheduler(new RandomOrderScheduler());\n\nResults results = new Model(settings).run();\n```\n\n## Results storage\n\nResults can be stored:\n\n- In memory - fastest, suitable for smaller simulations\n- On disk (SQLite) - suitable for large simulations or long runs\n\nEnable disk storage:\n\n```java\nsettings.setAreAttributeSetResultsStoredOnDisk(true);\n```\n\n### Notes\n\n- Disk-backed results use SQLite internally\n- Data is written incrementally during the simulation\n- The database is automatically created and managed by the framework\n- File lifecycle is handled by the results backend (no manual cleanup required in typical usage)\n\nDisk storage is slower than in-memory storage but avoids memory pressure for large-scale simulations.\n\n## Multithreading and synchronisation\n\n- `numOfCores` controls the worker thread count  \n- `areProcessesSynced` controls whether ticks are coordinated across threads\n\n### Modes\n\n- Synced (`true`)\n  - All agents progress in lockstep per tick\n  - Deterministic and safer for complex interactions\n  - Slightly slower\n- Unsynced (`false`)\n  - Agents may progress independently across threads\n  - Higher performance\n  - May introduce non-deterministic behaviour\n\n### Recommendation\n\n- Use synced mode when correctness and reproducibility matter\n- Use unsynced mode for performance experiments or independent agents\n\n## Examples\n\nThe integration tests under `src/test/java/integration` provide complete working examples, including:\n\n- Model setup\n- Multithreaded execution\n- Warm-up ticks\n- Results recording\n\nThese are the best places to start when building your own models.\n\n## Testing\n\nRun all tests:\n\n```bash\nmvn -B test\n```\n\nThe test suite includes both unit tests and end-to-end integration tests covering threading, schedulers, warm-up behaviour, and results backends.\n\n## License\n\nSee `LICENSE`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoshmcdonagh%2Fmodelarium","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoshmcdonagh%2Fmodelarium","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoshmcdonagh%2Fmodelarium/lists"}