CraftyMason is a Java/MASON-based land-use change simulation framework built around the CRAFTY modeling concepts. It simulates how land managers (agent functional types, or AFTs) compete for cells on a landscape while trying to satisfy ecosystem-service demand, and it supports adaptive policy interventions via fuzzy logic (taxes, subsidies, and protection rules).
At a high level, each simulation tick:
- Loads/updates annual capitals and demand from CSV input data.
- Computes utility as the gap between demand and current supply per service.
- Lets managers evaluate and potentially take over land cells based on competitiveness.
- Recomputes total service supply after ownership changes.
- Lets institutions adapt policies (via fuzzy inference) and influence utility and land protection.
- Optionally updates visualization (grid map and charts).
Core simulation orchestration is implemented with MASON SimState and scheduled steppables.
src/main/java/
crafty/ # Core data model: cells, managers, data loading, utility/production math
updaters/ # Scheduled update pipeline (capital, demand, utility, supply, map)
institution/ # Policy actors and policy objects (agri + nature institutions)
modelRunner/ # Simulation entry points and base runner
display/ # MASON UI and JFreeChart live charts
experiments/ # Experiment-specific runners/parameter exposure
test/ # Fuzzy rule test harness
resources/fcl/ # FCL fuzzy rule definitions
libs/ # Bundled third-party jars
in.params # Example parameter sweep config
pom.xml # Maven build config
AbstractModelRunnerextends MASONSimState, owns astateManagerlist, and drivessetup()+ scheduling for all model states.ModelRunneris the default concrete runner and wires a default state pipeline.experiments.Intraandexperiments.IndividualPoliciesoverride the state pipeline for scenario-specific experiments.
The execution order is controlled by insertion order in stateManager and scheduled priorities via modelRunner.indexOf(this).
DataCenter: central hub for reading CSV inputs, maintaining service/capital names, demand/supply/utility maps, and AFT counters.LandCell/AbstractCell: represent grid cells with capital values, production filters, and current owner.Manager/AbstractManager: represent agents that produce services from owned land and compete for ownership changes.Methods: production and competitiveness calculations.ManagerSetandCellSet: collections that also participate in model lifecycle (ModelState).
SupplyInitializer(one-time at tick 0): stores baseline supply.CapitalUpdater: applies next annual capital raster/table.DemandUpdater: applies next annual demand row.UtilityUpdater/InfluencedUtilityUpdater: computes utility from demand-supply gap; influenced variant also applies institutional policy effects.SupplyUpdater: recomputes aggregate supply after agent actions.MapUpdater: fills theIntGrid2Dvisualization map by AFT index.
AbstractInstitution: common lifecycle for policy systems.AgriInstitution: adaptive policies targeting agricultural services (e.g., Meat, Crops).NatureInstitution: adaptive biodiversity/protection-oriented policies.Policy: builder-based policy object with lag, inertia, intervention history, and goal.- Fuzzy logic rules are loaded from
resources/fcl/fuzzyPolicy.fclusing jFuzzyLogic.
ModelRunnerWithUI: MASON GUI wrapper and 2D grid visualization.GridOfCharts: JFreeChart frame with time series of supply vs demand per service.
The model expects CSV-based inputs for:
- Service definitions (
Services.csv)- Includes at least
NameandIndexcolumns.
- Includes at least
- Capital definitions (
Capitals.csv)- Includes at least
Namecolumn.
- Includes at least
- Agent sensitivity files (directory of CSVs)
- One file per AFT; file name becomes
managerType. - Must include
Productionplus capital columns corresponding toCapitals.csv.
- One file per AFT; file name becomes
- Baseline map (cell-level CSV)
- Uses at least
x,y,FRand capital columns. FRmaps each cell to an initial AFT file name.
- Uses at least
- Annual capital directory
- Sequence of CSVs with per-cell capital updates keyed by
x,y.
- Sequence of CSVs with per-cell capital updates keyed by
- Annual demand CSV
- Time rows; each service name is a column.
ModelRunner currently hard-codes Windows-style absolute paths for these files. You will almost certainly need to override these in your experiment class or update the defaults before running locally.
- Java 17
- Maven 3.8+
The project references several dependencies and includes jars in libs/. Depending on your local Maven setup, you may need to ensure all required artifacts are resolvable.
mvn -DskipTests compileYou can choose the entry point using exec.mainClass:
mvn -DskipTests exec:java -Dexec.mainClass=experiments.IntraOther useful entry points:
modelRunner.ModelRunner(default non-experiment runner)experiments.IndividualPoliciesdisplay.ModelRunnerWithUI(GUI console)test.TestTipper2(fuzzy rule debugging)
start()inAbstractModelRunnerclears stale states, rebuilds the state list, runs setup for each component, and schedules them.DataCenter.setup():- reads names and mappings,
- loads AFT sensitivities,
- loads baseline cells and assigns initial managers,
- initializes maps for zero production, utility strategy, demand iterator, capital iterator.
- Tick updates run via scheduled updaters and manager/institution steps.
- Managers compute production and (for representative managers) search/compete for land takeovers.
- Institutions monitor demand-supply outcomes, update policy interventions via fuzzy systems, and modify utility/protection outcomes.
experiments.Intra exposes many getters/setters that are convenient for MASON batch runs and UI parameter panels, including:
- policy goals (
meatGoal,cropGoal,divGoal) - policy lag
- threshold values
- output metrics (service supplies and AFT counts)
in.params provides a sample sweep configuration targeting:
- model:
experiments.Intra - independent variable:
PolicyLag - dependent metric:
IP - trial count, threads, steps, and output CSV target
- Several values and assumptions are currently hard-coded (service names like
Meat,Crops,Diversity; specific AFT labels). - File paths in
ModelRunnerare environment-specific (Windows absolute paths). - Some classes are placeholders or partially implemented (
Bugdet, some TODO methods,addAlloverrides returningfalse).
Typical extension points:
- Add a new institution by extending
AbstractInstitutionand registering it in a runner’sloadStateManager(). - Add new update stages by implementing
AbstractUpdaterand inserting them in state order. - Add new services/capitals through input CSVs and matching sensitivity columns.
- Introduce new scenarios by subclassing
ModelRunnerinexperiments/and exposing parameters via getters/setters.
No license file is currently present in the repository. If you intend to distribute or publish this project, add an explicit license.