uk.ac.ucl.casa.andrew.phd.segregationModelAddRemove
Class SegGISModel

java.lang.Object
  extended byuchicago.src.sim.engine.SimModelImpl
      extended byuk.ac.ucl.casa.andrew.phd.segregationModelAddRemove.SegGISModel
All Implemented Interfaces:
uchicago.src.reflector.DescriptorContainer, uchicago.src.sim.engine.SimEventProducer, uchicago.src.sim.engine.SimModel

public class SegGISModel
extends uchicago.src.sim.engine.SimModelImpl

This is the the same model as segregationModel However agents can be added and removed from the system. As with the model it is based on, the agents have only preferences for their own group and nothing else.

Version:
1 01-Dec-06
Author:
Andrew Crooks
Centre for Advanced Spatial Analysis, University College London.

Nested Class Summary
(package private)  class SegGISModel.happystats
           
(package private)  class SegGISModel.happystatsBlues
          Start of creating a graph Methods To create a graph there needs to be an inner class which impliments Repast's "DataSource" and "Sequence" interface which require 2 methods: An execute method that returns an Object A "getSValue method that returns a double (datatype).
(package private)  class SegGISModel.happystatsReds
           
(package private)  class SegGISModel.landuseStats
           
(package private)  class SegGISModel.landuseStatsNine
           
(package private)  class SegGISModel.landuseStatsThree
           
(package private)  class SegGISModel.landuseStatsTwo
           
(package private)  class SegGISModel.removedResidentBecauseToOldCount
           
(package private)  class SegGISModel.residentAgentsCount
           
(package private)  class SegGISModel.residentAgentsRemovedAsUnHappy
           
(package private)  class SegGISModel.residentAgentsRemovedAsUnHappyBlue
           
(package private)  class SegGISModel.residentAgentsRemovedAsUnHappyRed
           
(package private)  class SegGISModel.residentAgentsSocCountBlue
           
(package private)  class SegGISModel.residentAgentsSocCountRed
           
(package private)  class SegGISModel.totalHappyAndUnhappyAgents
           
(package private)  class SegGISModel.unhappystats
           
(package private)  class SegGISModel.unhappystatsBlues
           
(package private)  class SegGISModel.unhappystatsReds
           
 
Field Summary
(package private) static int addAgents
           
(package private) static int ADDAGENTS
           
(package private)  boolean addNewAgentOn
           
(package private) static int blue_blue
           
(package private) static int BLUE_BLUE
           
(package private) static java.lang.String datasource1
           
(package private)  javax.swing.JFileChooser fileChooser
           
(package private)  OpenMapData gisData
           
private  uchicago.src.sim.analysis.OpenSequenceGraph landuseGraph
           
(package private) static org.apache.log4j.Category log
          Instance fields *
(package private) static int movement
           
(package private) static int MOVEMENT
           
(package private) static int moveToWithIn
           
(package private) static int MOVETOWITHIN
           
(package private) static java.lang.String neighbourhoodFile1
           
private  uchicago.src.sim.gui.Legend newlegend
           
(package private)  anl.repast.gis.display.OpenMapDisplay omDisplay
           
(package private) static int perAgents
           
(package private) static int PERAGNETS
           
private  uchicago.src.sim.analysis.OpenSequenceGraph recorderHappyAgentsGraph
           
private  uchicago.src.sim.analysis.DataRecorder recorderLanduse
           
private  uchicago.src.sim.analysis.OpenSequenceGraph recorderTotalHappyAndSad
           
(package private) static int red_red
           
(package private) static int RED_RED
           
(package private)  boolean removeAgentsOn
           
(package private)  int removedResidentBecauseToOld
           
(package private)  java.util.ArrayList residentAgentsList
           
(package private) static boolean saveDataOn
           
(package private)  uchicago.src.sim.engine.Schedule schedule
           
(package private) static int search
           
(package private) static int SEARCH
           
(package private) static boolean searchOn
           
private  int simulationSpeed
           
(package private) static float sizeOfAgent
           
(package private) static float SIZEOFAGENT
           
(package private) static boolean snapshotOn
           
(package private)  int STEP_NUM
           
(package private)  double totalArea
           
(package private)  java.util.ArrayList urbanAgentList
           
 
Fields inherited from class uchicago.src.sim.engine.SimModelImpl
descriptors, modelManipulator
 
Constructor Summary
SegGISModel()
          SegGISModel constructor
 
Method Summary
private  void addNewResdientAgent()
          Used to add a new agent randonmly within the urban area, will add however many agents specified in the counter Once an agent is created it is added to the residentAgent list
 void begin()
          Calls the buildModel, buildDisplay and buildSchedule methods the method initialises the repast model In this order.
 void buildDisplay()
          This method does as it suggests, it builds a diplay for the model.
 void buildModel()
           
 void buildSchedule()
          Schedules the execution of the specified method (ie step)on the specified object(ie this model) to start at the specified clock tick and continue every tick thereafter.
 void createShapefileForAgents()
          creates a new point shapefile containting all the resident agents this uses information from the Resident class specifically information in the gisPropertyList()each element in the dbf file needs a get and set method in a similar way to reading in and storing changes in the urban agent.
private  void densityStats(java.util.ArrayList urbanAgentList)
          Used to calculate max and miniuim density of Urban agent along with average density of the area.
 int getAddAgents()
          Gets the number of agents to be added
 boolean getAddNewAgentOn()
          Gets wether to add agents or not
 int getBlue_blue()
          Gets prefereces for blue agents
 java.lang.String[] getInitParam()
          This method gets the inital parameters of the model it returns an array of string variables.
 int getMovement()
           
 int getMoveToWithin()
           
 java.lang.String getName()
          getName replaces repast with the name of the project on the control bar
 java.util.ArrayList getNeighborAgents(int[] neighbors)
           
 int getNeighbourhood()
           
 int getPerAgents()
           
 int getRed_red()
          Gets prefereces for red agents
 boolean getRemoveAgentsOn()
          Gets the agents to be removed
 java.util.ArrayList getResidentAgents()
           
 boolean getSaveDataOn()
           
 uchicago.src.sim.engine.Schedule getSchedule()
          Schedule manages the execution of BasicAction accoriding to the simulation clock.
 boolean getSearchOn()
           
 float getSizeOfAgent()
           
 boolean getSnapshotOn()
           
 int getSTEP_NUM()
           
 java.util.ArrayList getUrbanAgentList()
           
static void main(java.lang.String[] args)
           
 void metresToDecimalDegress()
           
static float movementInDegreesCalculation()
           
private  void numberOfHappyResdientAgents(java.util.ArrayList residentAgentsList)
          Used to calculate the number of unhappy agents in the area.
 void postStep()
           
 void preStep()
           
private  int removeResidents()
          Used to remove an agent at the moment it is only used when an agent becomes to old ie 50+ Resdients are removed but their index (gisResidentAgentIndex is not altered.
 void reset()
          The reset mmethod is called whenever the model is reset.
 void saveGALFile()
          Makes a copy of the gal file
 void saveShapefile()
          Any change to the urban layer is saved to a new shapefile
 void setAddAgents(int addNewAgent)
          Sets the number of agents to be added
 void setAddNewAgentOn(boolean showAdd)
          Sets wether to add agents or not
 void setBlue_blue(int i)
          Sets prefereces for blue agents
 void setMovement(int mov)
           
 void setMoveToWithin(int newMovementToWithin)
           
 void setNeighbourhood(int ser)
           
 void setPerAgents(int pa)
           
 void setRed_red(int a)
          Sets prefereces for red agents
 void setRemoveAgentsOn(boolean showRemove)
          Sets the agents to be removed
 void setResidentAgents(java.util.ArrayList residentAgents)
           
 void setSaveDataOn(boolean show)
           
 void setSearchOn(boolean show)
           
 void setSizeOfAgent(float soa)
           
 void setSnapshotOn(boolean show)
           
 void setSnapShotRecording()
          Created to save time when images are wanted when running a simulation.
 void setSTEP_NUM(int step_num)
           
 void setup()
          The setup() function returns the model to the initial conditions
 void setUrbanAgentList(java.util.ArrayList agentList)
           
 void step()
          Step method tells the program what to do at evey step THis therefore should contain infomation about agent movement, what agents are where etc.
 void takesnapshot()
          Record snapshots of all of the displays, so one does not have to select the displays to be saved manually
 
Methods inherited from class uchicago.src.sim.engine.SimModelImpl
addPropertyListener, addSimEventListener, clearMediaProducers, clearPropertyListeners, fireBooleanPropertyEvent, fireEndSim, fireNumericPropertyEvent, fireObjectPropertyEvent, firePauseSim, fireSimEvent, fireStopSim, fireStringPropertyEvent, generateNewSeed, getController, getMediaProducers, getModelManipulator, getParameterDescriptors, getPropertiesValues, getRngSeed, getTickCount, pause, registerDisplaySurface, registerMediaProducer, removePropertyListener, removeSimEventListener, setController, setRngSeed, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

static org.apache.log4j.Category log
Instance fields *


fileChooser

javax.swing.JFileChooser fileChooser

RED_RED

static final int RED_RED
See Also:
Constant Field Values

red_red

static int red_red

BLUE_BLUE

static final int BLUE_BLUE
See Also:
Constant Field Values

blue_blue

static int blue_blue

snapshotOn

static boolean snapshotOn

saveDataOn

static boolean saveDataOn

PERAGNETS

static final int PERAGNETS
See Also:
Constant Field Values

SIZEOFAGENT

static float SIZEOFAGENT

MOVEMENT

static final int MOVEMENT
See Also:
Constant Field Values

SEARCH

static final int SEARCH
See Also:
Constant Field Values

perAgents

static int perAgents

sizeOfAgent

static float sizeOfAgent

search

static int search

movement

static int movement

ADDAGENTS

static final int ADDAGENTS
See Also:
Constant Field Values

addAgents

static int addAgents

removedResidentBecauseToOld

int removedResidentBecauseToOld

totalArea

double totalArea

MOVETOWITHIN

static final int MOVETOWITHIN
See Also:
Constant Field Values

moveToWithIn

static int moveToWithIn

datasource1

static java.lang.String datasource1

neighbourhoodFile1

static java.lang.String neighbourhoodFile1

gisData

OpenMapData gisData

omDisplay

anl.repast.gis.display.OpenMapDisplay omDisplay

urbanAgentList

java.util.ArrayList urbanAgentList

residentAgentsList

java.util.ArrayList residentAgentsList

schedule

uchicago.src.sim.engine.Schedule schedule

STEP_NUM

int STEP_NUM

simulationSpeed

private int simulationSpeed

landuseGraph

private uchicago.src.sim.analysis.OpenSequenceGraph landuseGraph

recorderLanduse

private uchicago.src.sim.analysis.DataRecorder recorderLanduse

recorderHappyAgentsGraph

private uchicago.src.sim.analysis.OpenSequenceGraph recorderHappyAgentsGraph

recorderTotalHappyAndSad

private uchicago.src.sim.analysis.OpenSequenceGraph recorderTotalHappyAndSad

searchOn

static boolean searchOn

removeAgentsOn

boolean removeAgentsOn

addNewAgentOn

boolean addNewAgentOn

newlegend

private uchicago.src.sim.gui.Legend newlegend
Constructor Detail

SegGISModel

public SegGISModel()
SegGISModel constructor

Method Detail

main

public static void main(java.lang.String[] args)
Parameters:
args -

begin

public void begin()
Calls the buildModel, buildDisplay and buildSchedule methods the method initialises the repast model In this order. Therefore things created in build model are seen in builddisplay etc.


buildModel

public void buildModel()

buildDisplay

public void buildDisplay()
This method does as it suggests, it builds a diplay for the model. It works by going through the list of agents in the model parameters, then adds the data to the display


setSnapShotRecording

public void setSnapShotRecording()
Created to save time when images are wanted when running a simulation. Images are stored in the same location as the shapefiles.


takesnapshot

public void takesnapshot()
Record snapshots of all of the displays, so one does not have to select the displays to be saved manually


buildSchedule

public void buildSchedule()
Schedules the execution of the specified method (ie step)on the specified object(ie this model) to start at the specified clock tick and continue every tick thereafter.


step

public void step()
Step method tells the program what to do at evey step THis therefore should contain infomation about agent movement, what agents are where etc.


preStep

public void preStep()

postStep

public void postStep()

removeResidents

private int removeResidents()
Used to remove an agent at the moment it is only used when an agent becomes to old ie 50+ Resdients are removed but their index (gisResidentAgentIndex is not altered. Take the resident list, and -1, and go through the list-- till all the arraylist has been checked.


addNewResdientAgent

private void addNewResdientAgent()
Used to add a new agent randonmly within the urban area, will add however many agents specified in the counter Once an agent is created it is added to the residentAgent list


numberOfHappyResdientAgents

private void numberOfHappyResdientAgents(java.util.ArrayList residentAgentsList)
Used to calculate the number of unhappy agents in the area. Make a new iterater based on residentlist, get each residents happyness and then count them. Then print out the totals.


densityStats

private void densityStats(java.util.ArrayList urbanAgentList)
Used to calculate max and miniuim density of Urban agent along with average density of the area. Uses popDensity method from Urban Agent.


getNeighborAgents

public java.util.ArrayList getNeighborAgents(int[] neighbors)

setup

public void setup()
The setup() function returns the model to the initial conditions


reset

public void reset()
The reset mmethod is called whenever the model is reset. Everything is reset to null.


getSchedule

public uchicago.src.sim.engine.Schedule getSchedule()
Schedule manages the execution of BasicAction accoriding to the simulation clock. Actions schedulled on a schedule will be executed in a random order.


saveShapefile

public void saveShapefile()
Any change to the urban layer is saved to a new shapefile


createShapefileForAgents

public void createShapefileForAgents()
creates a new point shapefile containting all the resident agents this uses information from the Resident class specifically information in the gisPropertyList()each element in the dbf file needs a get and set method in a similar way to reading in and storing changes in the urban agent. Need to rewrite anl.repast.gis.data.OpenMapData class specifically writeDbfFromAgents() becuase write to string was not working. Also writeAgentsNoShp() so a point file would be created from an OM circle otherwise the file would be of type polygon.


saveGALFile

public void saveGALFile()
Makes a copy of the gal file


getName

public java.lang.String getName()
getName replaces repast with the name of the project on the control bar


getInitParam

public java.lang.String[] getInitParam()
This method gets the inital parameters of the model it returns an array of string variables. Each parameter in the list needs a get and set method.


getRed_red

public int getRed_red()
Gets prefereces for red agents


setRed_red

public void setRed_red(int a)
Sets prefereces for red agents

Parameters:
a -

getBlue_blue

public int getBlue_blue()
Gets prefereces for blue agents

Returns:

setBlue_blue

public void setBlue_blue(int i)
Sets prefereces for blue agents

Parameters:
i -

getSaveDataOn

public boolean getSaveDataOn()

setSaveDataOn

public void setSaveDataOn(boolean show)

getSnapshotOn

public boolean getSnapshotOn()

setSnapshotOn

public void setSnapshotOn(boolean show)

getMoveToWithin

public int getMoveToWithin()

setMoveToWithin

public void setMoveToWithin(int newMovementToWithin)

getAddAgents

public int getAddAgents()
Gets the number of agents to be added

Returns:

setAddAgents

public void setAddAgents(int addNewAgent)
Sets the number of agents to be added

Parameters:
addNewAgent -

getRemoveAgentsOn

public boolean getRemoveAgentsOn()
Gets the agents to be removed

Returns:

setRemoveAgentsOn

public void setRemoveAgentsOn(boolean showRemove)
Sets the agents to be removed

Parameters:
showRemove -

getAddNewAgentOn

public boolean getAddNewAgentOn()
Gets wether to add agents or not

Returns:

setAddNewAgentOn

public void setAddNewAgentOn(boolean showAdd)
Sets wether to add agents or not

Parameters:
showAdd -

getSearchOn

public boolean getSearchOn()

setSearchOn

public void setSearchOn(boolean show)

getPerAgents

public int getPerAgents()

setPerAgents

public void setPerAgents(int pa)

getSizeOfAgent

public float getSizeOfAgent()

setSizeOfAgent

public void setSizeOfAgent(float soa)

getMovement

public int getMovement()

setMovement

public void setMovement(int mov)

getNeighbourhood

public int getNeighbourhood()

setNeighbourhood

public void setNeighbourhood(int ser)

getUrbanAgentList

public java.util.ArrayList getUrbanAgentList()

setUrbanAgentList

public void setUrbanAgentList(java.util.ArrayList agentList)

getResidentAgents

public java.util.ArrayList getResidentAgents()

setResidentAgents

public void setResidentAgents(java.util.ArrayList residentAgents)

getSTEP_NUM

public int getSTEP_NUM()

setSTEP_NUM

public void setSTEP_NUM(int step_num)

metresToDecimalDegress

public void metresToDecimalDegress()

movementInDegreesCalculation

public static float movementInDegreesCalculation()