Skip to content

A Predator-Prey Agent Based Model of prey colour polymorphism (CP) in Go

License

Notifications You must be signed in to change notification settings

benjamin-rood/abm-cp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Report Card

###Note that all code is alpha until version 1.0

###Current Version: 0.4.1a

abm preview

##ConditionParams Software for computing a Predator-Prey Agent Based Model of prey colour polymorphism (CP) in Go.

Written specifically to assist the research by Dr. James Dale in evaluating hypotheses for the evolutionary maintenance of extreme colour polymorphism.

##Goal

Server-side computation, client-side GUI controls and visualisation of the running ABM in a web browser.

Generalise system so any abm package with local model conditions, agent design, etc can be hot-swapped in (linked via a command line flag) and run.

###How to use:

Install Go from here.

Download my repo: go get -u github.com/benjamin-rood/abm-cp

Download external dependencies:

go get -u golang.org/x/net/websocket go get -u github.com/benjamin-rood/gobr go get -u github.com/pquerna/ffjson go get -u github.com/davecgh/go-spew/spew

(All dependecies will be vendored into the abm-cp package from v1.0.0 onwards)

Change current directory to $GOPATH/src/github.com/benjamin-rood/abm-cp/net and run go run server.go

Point web browser at localhost:9999

Current version only tested on Safari/Chrome on OS X and Chrome on Windows 7/8.1.

Can be left running for days:

Roadmap

0.1.0

Base requirements completed.

  • A simple interface for the CP Prey ABM, with the visualisation on the left, with conditionsual parameter controls on the right. ✅

  • Use P5js for render viewport. ✅

  • Browser recieves drawing instructions from ABM which get loaded into the P5 instance's draw loop. ✅

  • Responsive design, visualisation (render viewport) scales to the dimensions of available browser real estate. ✅

  • Server handles concurrent bi-directional connections for concurrent ABM modelling individual to each user, with data sent between client and server using Web Sockets. ✅

  • Server cleans up after user disconnections. ✅

  • Server receives new submitted conditionsual parameters as signal to start/restart ABM. ✅

  • Serialisation of data messages using JSON (prohibatively slow for anything approaching 10,000 agents). ✅

  • CP Prey agents implementation:

    • Rule-Based-Behaviour. ✅
    • Asexual Reproduction. ✅
    • Mutation (colouration). ✅
  • Visual Predator implementation:

    • Rule-Based-Behaviour. ✅
    • Exhaustive Prey Search (very slow). ✅
    • Colour Imprinting (needs tweaking, no baseline yet established). ✅
  • Simple concurrent execution of Predator/Prey RBB. ✅

  • Unit tests for geometry, calc, render packages. ✅

0.2.0

  • Dispatch errors along channels, use external handlers who receive the errors and process/print them. ✅

  • Essential unit tests for abm package ✅

  • Show live population and timeline statistics inside P5js viewport. ✅

  • Visual Predator implemenation:

    • Find baseline params for Colour Imprinting. ✅
    • Adaptation in response to hunger. ✅
    • Starvation ⟹ Death. ✅
    • Sexual Reproduction. ✅
  • General modelling and interactions between agent types in place, with all baseline parameters set for end-use. ✅

0.3.0

  • Toggle Visualisation on/off ✅

  • Record data of a running model to log files as JSON for statistical analysis as a concurrent process, independent of Visualisation or model computation. Toggleable. ✅

  • User determined frequency of data logging on client side. ✅

  • Better model for Predator specialisation through colour-imprinting which directly gives search/attack advantage, rather than being decided randomly. ✅

  • Complete tests for abm package ✅

0.4.0

  • Use ffjson–generated custom Marshal/Unmarshal JSON methods for ~2X speedup when serialising render messages to client ✅

  • Import JSON-formatted text files as pre-defined modelling ConditionParams via browser upload.

  • Automatically gzip JSON-formatted logging files.

  • Better Prey Search (using grid system), for ~2X speedup.

  • WebScktClient-side input validation.

0.5.0

  • Have complete control over ABM computation, logging, visualisation from command-line, rather than just starting up a web server and controlling through the the browser.

  • Use uncompressed JSON-formatted logging for debug only.

  • Switch to a compressed binary encoding for log files.

0.6.0

  • Switch data serialisation to Protocol Buffers (protobuf) ~10X speedup. Marshalling drawing instructions to JSON is currently the single most expensive action!

1.0.0 – June 2016?

  • Switch all public html file to templated/generated ones based on conditions parameters etc.

  • Switch to gopherjs for all front-end code?

  • Use k-dimensional tree for spatial partitioning of model environment, permitting optimal search.

  • Allow end-user to switch between different browser layouts: Visualisation only, Standard and Statistical? ⟵ Could use Jupyter to present graphing in browser?

  • Start ABM computation remotely and keep running after disconnection? i.e. start the model running, leave it, reconnect based on session UUID at a later tim to check up or review results.

  • Batch processing.

  • Email user when model session finishes.

  • Enable use in a distributed environment.

  • Complete testing suite.

  • Allow hot-swapping of different abm packages.

  • Store modelling sessions to server database along with statistical data for later retrieval.

  • Fluid ABM timescale controls? ⟵ Doable, but probably not without switching to gopherjs so I can integrate it all within the same codebase.

  • Optional recording of Visualisation to SVG frame sequence using ajstarks/svgo

About

A Predator-Prey Agent Based Model of prey colour polymorphism (CP) in Go

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published