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

java.lang.Object
  extended byuchicago.src.sim.engine.SimModelImpl
      extended byuk.ac.ucl.casa.andrew.phd.segModelFourTypesCombined.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 model extends segModelFourTypes and is the final model presented in the segregation website which incorporates several aspects of all the other models presented thus highlighting how different model components can be easily incorporated into a more detailed model to explore segregation. These include: the ability to add and remove agents (SegregationModelAddRemove), setting density limits for agent neighbourhoods (SegregationModelDensity), restricting the agents movement in the first iteration to only the area it is currently in (SegregationModelRestricted) and allowing agents to live by oneself (SegModelFourTypes). The SegregationModelNoNeighbourhoods demonstrated the importance of geographical features, while SegModelPreferencesForBothDislike and SegModelPreferencesForBothLike highlighted how different preferences can affect the pattern of segregation. By developing these models separately and seeing how each assumption affects the outcome of a particular simulation a thorough understanding of the models can be gained thus reducing the need to carry out unit tests of different parameters.

Author:
Andrew Crooks
Centre for Advanced Spatial Analysis, University College London.

Nested Class Summary
(package private)  class SegGISModel.blueresidentAgentsMoved
           
(package private)  class SegGISModel.greenresidentAgentsMoved
           
(package private)  class SegGISModel.happystats
           
(package private)  class SegGISModel.happystatsBlues
           
(package private)  class SegGISModel.happystatsGreen
           
(package private)  class SegGISModel.happystatsReds
           
(package private)  class SegGISModel.happystatsWhite
           
(package private)  class SegGISModel.landuseStats
           
(package private)  class SegGISModel.landuseStatsFive
           
(package private)  class SegGISModel.landuseStatsFour
           
(package private)  class SegGISModel.landuseStatsSix
           
(package private)  class SegGISModel.landuseStatsThree
           
(package private)  class SegGISModel.landuseStatsTwo
           
(package private)  class SegGISModel.redresidentAgentsMoved
           
(package private)  class SegGISModel.removedResidentBecauseToOldCount
           
(package private)  class SegGISModel.residentAgentsCount
           
(package private)  class SegGISModel.residentAgentsRemovedAsUnHappy
           
(package private)  class SegGISModel.residentAgentsRemovedAsUnHappyBlue
           
(package private)  class SegGISModel.residentAgentsRemovedAsUnHappyGreen
           
(package private)  class SegGISModel.residentAgentsRemovedAsUnHappyRed
           
(package private)  class SegGISModel.residentAgentsRemovedAsUnHappyWhite
           
(package private)  class SegGISModel.residentAgentsSocCountBlue
           
(package private)  class SegGISModel.residentAgentsSocCountGreen
           
(package private)  class SegGISModel.residentAgentsSocCountRed
           
(package private)  class SegGISModel.residentAgentsSocCountWhite
           
(package private)  class SegGISModel.totalHappyAndUnhappyAgents
           
(package private)  class SegGISModel.totalresidentAgentsMoved
           
(package private)  class SegGISModel.unhappystats
           
(package private)  class SegGISModel.unhappystatsBlues
           
(package private)  class SegGISModel.unhappystatsGreen
           
(package private)  class SegGISModel.unhappystatsReds
           
(package private)  class SegGISModel.unhappystatsWhite
           
(package private)  class SegGISModel.whiteresidentAgentsMoved
           
 
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 int blue_green
           
(package private) static int BLUE_GREEN
           
(package private) static int blue_red
           
(package private) static int BLUE_RED
           
(package private) static int blue_white
           
(package private) static int BLUE_WHITE
           
(package private) static boolean byOneSelfOn
           
(package private) static boolean closeModelOn
           
(package private) static java.lang.String datasource1
           
(package private) static boolean densityOn
           
(package private)  javax.swing.JFileChooser fileChooser
           
(package private)  OpenMapData gisData
           
(package private) static int green_blue
           
(package private) static int GREEN_BLUE
           
(package private) static int green_green
           
(package private) static int GREEN_GREEN
           
(package private) static int green_red
           
(package private) static int GREEN_RED
           
(package private) static int green_white
           
(package private) static int GREEN_WHITE
           
private  uchicago.src.sim.analysis.OpenSequenceGraph landuseGraph
           
(package private) static int maxDensity
           
(package private) static int MAXDENSITY
           
(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_blue
           
(package private) static int RED_BLUE
           
(package private) static int red_green
           
(package private) static int RED_GREEN
           
(package private) static int red_red
           
(package private) static int RED_RED
           
(package private) static int red_white
           
(package private) static int RED_WHITE
           
(package private)  boolean removeAgentsOn
           
(package private)  int removedResidentBecauseToOld
           
(package private)  java.util.ArrayList residentAgentsList
           
(package private) static boolean restrictOn
           
(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
           
static int STEP_NUM
           
(package private)  double totalArea
           
(package private)  java.util.ArrayList urbanAgentList
           
(package private) static int white_blue
           
(package private) static int WHITE_BLUE
           
(package private) static int white_green
           
(package private) static int WHITE_GREEN
           
(package private) static int white_red
           
(package private) static int WHITE_RED
           
(package private) static int white_white
           
(package private) static int WHITE_WHITE
           
 
Fields inherited from class uchicago.src.sim.engine.SimModelImpl
descriptors, modelManipulator
 
Constructor Summary
SegGISModel()
           
 
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.
 void begin()
          alls the buildModel, buildDisplay and buildSchedule methods the method initialises the repast model In this order.
 void buildDisplay()
          Builds the display for the model
 void buildModel()
          Reads in the data and builds the model
 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 closeModel()
          Checks to see if all the agents are happy.
 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()
           
 boolean getAddNewAgentOn()
           
 int getBlue_blue()
           
 int getBlue_green()
           
 int getBlue_red()
           
 int getBlue_white()
           
 boolean getByOneSelfOn()
           
 boolean getCloseModelOn()
           
 boolean getDensityOn()
           
 int getGreen_blue()
           
 int getGreen_green()
           
 int getGreen_red()
           
 int getGreen_white()
           
 java.lang.String[] getInitParam()
          This method gets the inital parameters of the model it returns an array of string variables.
 int getMaxDensity()
           
 int getMovement()
           
 int getMoveToWithin()
           
 java.lang.String getName()
          Replaces repast with the name of the project on the control bar
 java.util.ArrayList getNeighborAgents(int[] neighbors)
          Gets the neighbourhood info for the urban agents
 int getNeighbourhood()
           
 int getPerAgents()
           
 int getRed_blue()
           
 int getRed_green()
           
 int getRed_red()
           
 int getRed_white()
           
 boolean getRemoveAgentsOn()
           
 java.util.ArrayList getResidentAgents()
           
 boolean getRestrictOn()
           
 boolean getSaveDataOn()
           
 uchicago.src.sim.engine.Schedule getSchedule()
          gets the schedule
 boolean getSearchOn()
           
 float getSizeOfAgent()
           
 boolean getSnapshotOn()
           
 int getSTEP_NUM()
           
 java.util.ArrayList getUrbanAgentList()
           
 int getWhite_blue()
           
 int getWhite_green()
           
 int getWhite_red()
           
 int getWhite_white()
           
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()
          Calls methods and functions to be carried out in PostStep
 void preStep()
          Calls methods to be carried out in 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 method is called whenever the model is reset.
 void saveGALFile()
          Takes a copy of the existing gal file and creates a new copy of it
 void saveShapefile()
          Any change to the urban layer is saved to a new shapefile
 void setAddAgents(int addNewAgent)
           
 void setAddNewAgentOn(boolean showAdd)
           
 void setBlue_blue(int i)
           
 void setBlue_green(int k)
           
 void setBlue_red(int j)
           
 void setBlue_white(int l)
           
 void setByOneSelfOn(boolean show)
           
 void setCloseModelOn(boolean on)
           
 void setDensityOn(boolean show)
           
 void setGreen_blue(int g)
           
 void setGreen_green(int e)
           
 void setGreen_red(int f)
           
 void setGreen_white(int h)
           
 void setMaxDensity(int newMaxDensity)
           
 void setMovement(int mov)
           
 void setMoveToWithin(int newMovementToWithin)
           
 void setNeighbourhood(int ser)
           
 void setPerAgents(int pa)
           
 void setRed_blue(int c)
           
 void setRed_green(int b)
           
 void setRed_red(int a)
           
 void setRed_white(int d)
           
 void setRemoveAgentsOn(boolean showRemove)
           
 void setResidentAgents(java.util.ArrayList residentAgents)
           
 void setRestrictOn(boolean show)
           
 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 setWhite_blue(int p)
           
 void setWhite_green(int o)
           
 void setWhite_red(int n)
           
 void setWhite_white(int m)
           
 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()
           
 
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

fileChooser

javax.swing.JFileChooser fileChooser

RED_RED

static final int RED_RED
See Also:
Constant Field Values

red_red

static int red_red

RED_GREEN

static final int RED_GREEN
See Also:
Constant Field Values

red_green

static int red_green

RED_BLUE

static final int RED_BLUE
See Also:
Constant Field Values

red_blue

static int red_blue

RED_WHITE

static final int RED_WHITE
See Also:
Constant Field Values

red_white

static int red_white

GREEN_GREEN

static final int GREEN_GREEN
See Also:
Constant Field Values

green_green

static int green_green

GREEN_RED

static final int GREEN_RED
See Also:
Constant Field Values

green_red

static int green_red

GREEN_BLUE

static final int GREEN_BLUE
See Also:
Constant Field Values

green_blue

static int green_blue

GREEN_WHITE

static final int GREEN_WHITE
See Also:
Constant Field Values

green_white

static int green_white

BLUE_BLUE

static final int BLUE_BLUE
See Also:
Constant Field Values

blue_blue

static int blue_blue

BLUE_RED

static final int BLUE_RED
See Also:
Constant Field Values

blue_red

static int blue_red

BLUE_GREEN

static final int BLUE_GREEN
See Also:
Constant Field Values

blue_green

static int blue_green

BLUE_WHITE

static final int BLUE_WHITE
See Also:
Constant Field Values

blue_white

static int blue_white

WHITE_WHITE

static final int WHITE_WHITE
See Also:
Constant Field Values

white_white

static int white_white

WHITE_RED

static final int WHITE_RED
See Also:
Constant Field Values

white_red

static int white_red

WHITE_GREEN

static final int WHITE_GREEN
See Also:
Constant Field Values

white_green

static int white_green

WHITE_BLUE

static final int WHITE_BLUE
See Also:
Constant Field Values

white_blue

static int white_blue

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

removeAgentsOn

boolean removeAgentsOn

addNewAgentOn

boolean addNewAgentOn

removedResidentBecauseToOld

int removedResidentBecauseToOld

MAXDENSITY

static final int MAXDENSITY
See Also:
Constant Field Values

maxDensity

static int maxDensity

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

public static 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

snapshotOn

static boolean snapshotOn

saveDataOn

static boolean saveDataOn

closeModelOn

static boolean closeModelOn

densityOn

static boolean densityOn

restrictOn

static boolean restrictOn

byOneSelfOn

static boolean byOneSelfOn

newlegend

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

SegGISModel

public SegGISModel()
Method Detail

main

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

begin

public void begin()
alls 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()
Reads in the data and builds the model


buildDisplay

public void buildDisplay()
Builds the display for the model


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()
Calls methods to be carried out in PreStep


postStep

public void postStep()
Calls methods and functions to be carried out in 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


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.


closeModel

public void closeModel()
Checks to see if all the agents are happy. if they are the model will close.


takesnapshot

public void takesnapshot()

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)
Gets the neighbourhood info for the urban agents


setup

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


reset

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


getSchedule

public uchicago.src.sim.engine.Schedule getSchedule()
gets the schedule


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. Needed 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()
Takes a copy of the existing gal file and creates a new copy of it


getName

public java.lang.String 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.


getMaxDensity

public int getMaxDensity()

setMaxDensity

public void setMaxDensity(int newMaxDensity)

getCloseModelOn

public boolean getCloseModelOn()

setCloseModelOn

public void setCloseModelOn(boolean on)

getAddAgents

public int getAddAgents()

setAddAgents

public void setAddAgents(int addNewAgent)

getRemoveAgentsOn

public boolean getRemoveAgentsOn()

setRemoveAgentsOn

public void setRemoveAgentsOn(boolean showRemove)

getByOneSelfOn

public boolean getByOneSelfOn()

setByOneSelfOn

public void setByOneSelfOn(boolean show)

getAddNewAgentOn

public boolean getAddNewAgentOn()

setAddNewAgentOn

public void setAddNewAgentOn(boolean showAdd)

getRed_red

public int getRed_red()

setRed_red

public void setRed_red(int a)

getRed_green

public int getRed_green()

setRed_green

public void setRed_green(int b)

getRed_blue

public int getRed_blue()

setRed_blue

public void setRed_blue(int c)

getRed_white

public int getRed_white()

setRed_white

public void setRed_white(int d)

getGreen_green

public int getGreen_green()

setGreen_green

public void setGreen_green(int e)

getGreen_red

public int getGreen_red()

setGreen_red

public void setGreen_red(int f)

getGreen_blue

public int getGreen_blue()

setGreen_blue

public void setGreen_blue(int g)

getGreen_white

public int getGreen_white()

setGreen_white

public void setGreen_white(int h)

getBlue_blue

public int getBlue_blue()

setBlue_blue

public void setBlue_blue(int i)

getBlue_red

public int getBlue_red()

setBlue_red

public void setBlue_red(int j)

getBlue_green

public int getBlue_green()

setBlue_green

public void setBlue_green(int k)

getBlue_white

public int getBlue_white()

setBlue_white

public void setBlue_white(int l)

getWhite_white

public int getWhite_white()

setWhite_white

public void setWhite_white(int m)

getWhite_red

public int getWhite_red()

setWhite_red

public void setWhite_red(int n)

getWhite_green

public int getWhite_green()

setWhite_green

public void setWhite_green(int o)

getWhite_blue

public int getWhite_blue()

setWhite_blue

public void setWhite_blue(int p)

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)

getSearchOn

public boolean getSearchOn()

setSearchOn

public void setSearchOn(boolean show)

getDensityOn

public boolean getDensityOn()

setDensityOn

public void setDensityOn(boolean show)

getRestrictOn

public boolean getRestrictOn()

setRestrictOn

public void setRestrictOn(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()