Giter VIP home page Giter VIP logo

systemdynamics-framework's Introduction

System Dynamics Java-Framework

Introduction

This Framework allows you to create your own System Dynamics model of complex systems and to simulate its dynamic behavior.

Usage

Best practise sample

1. Create the model

Model model = new Model(0, 10, 0.1, new EulerCauchyIntegration());

2. Create all system elements

// create a stock
Stock populationPrey = (Stock) model.createModelEntity(ModelEntityType.STOCK, POPULATION_PREY_KEY);
// set initial value
populationPrey.setInitialValue(100);

// create a variable
Variable expansionRatePrey = (Variable) model.createModelEntity(ModelEntityType.VARIABLE, BIRTH_RATE_PREY_KEY);
// set initial value
expansionRatePrey.setInitialValue(0.1);

// create another variable
Variable meetings = (Variable) model.createModelEntity(ModelEntityType.VARIABLE, MEETINGS_KEY);

3. Create the flows

// create some flows
Flow birthsPrey = (Flow) model.createModelEntity(ModelEntityType.FLOW, BIRTHS_PREY_KEY);
Flow deathsPrey = (Flow) model.createModelEntity(ModelEntityType.FLOW, DEATHS_PREY_KEY);
  
// add them to a stock
populationPrey.addInputFlows(birthsPrey);
populationPrey.addOutputFlows(deathsPrey);

// set calculation function
populationPrey.setChangeRateFunction(
	() -> birthsPrey.getCurrentValue() โ€“ deathsPrey.getCurrentValue()
);

4. Define the converters

// define a converter
Converter deathsPreyConverter = model.createConverter(deathsPrey, meetings, lossRatePrey);

// set function
deathsPreyConverter.setFunction(
	() -> meetings.getCurrentValue() * lossRatePrey.getCurrentValue()
);

5. Create the simulation

Simulation simulation = new Simulation(model);

6. Add result handler

// add a CSVExport
simulation.addSimulationEventListener(
	new CSVExporter("output.csv", ";")
);

// Add a ChartViewer
simulation.addSimulationEventListener(
	new ChartViewer()
);

7. Run the simulation

simulation.run();

systemdynamics-framework's People

Contributors

matthiasstein avatar sebadro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

nixlim

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.