#Model Schelling Segregation Model (2d)

##Description
This is a simple implementation of the Schelling Segregation Model in it's two
dimensional version (1978)

The set of agents populates a 2d lattice with discrete number of "patches".
Agents are blue or red. They prefer to have neighbours with equal colour,
but not too strongly. The parameter "tolerance" in [0,1] defines the fraction
of agents with a different colour that are O.K.

They look in their neighbourhood spanning "distance" patches in radius to see if they are content. They are content as long as the fraction of
neighbours with a different colour is at most equal to the "tolarance" level.

The number of agents is strictly less then the number of patches. If an agent is
not content with its situation, it moves to the closest place where it would be
content if such a place exists. In cases of ambiguity between options, a random
decision takes place. The agent does not anticipate the behaviour of other
agents.

The simulation stops when no agent wants to move, either because they are all
content or because they do not find a new position that would make them content.

##Specific Sub-Verisons:
There are some things that are most important for the "working" of the model, which are treated different in the literature. 1.) The Updating: parallel or sequential updating of "Content"ness and 2.) Movement: Move only if a new situation improves the "Content"ness or more randomly whenever one is not "Content".

This can be controlled by the parameters "SequentialUpdating" and "RationalExpectations". In the original description in the 1978 Article both are described as activated.

In order to get high fragmentation (i.e., segregation), the agents need to switch irespective of their anticipated result.

The parameter distance_type controls the shape of the neighbourhood. One may use the euclidean distance (0) to get a circular (Euclidean), (1) to get a traditional von Neumann neighbourhood (Manhatten) and (2) to get the Moore neighbourhood (Chebyshev).

##Parameters and Variables

Control:
[V]	Scheduler		: Represents the "Updating Scheme"
[V]	Initialise	: Initialisation of the Model	

Global (Sensitivity) Parameters :
[P] xn  			  : x-dimension of the space (integer>>3)
[P] yn  			  : y-dimension of the space (integer>>3)
[P] wrapping  	:

    there are 2^4 options. We use a bit-code (0=off):
    0-bit: left     : 0=0 1=1
    1-bit: right    : 0=0 1=2
    2-bit: top      : 0=0 1=4
    3-bit: bottom   : 0=0 1=8
    sum the values to generate desired wrapping (e.g. 15 - torus world, default)

[P] fracAgents	: relative number of agents compared to xn (0..1)
[P] fracBlue		: relative number of blue agents from total (0..1)
[P] tolerance		: the tolerance level (homogeneous, 0..1)
[P] distance		: size of the neighbourhood, to left and right (1, ... xn)
[P] distance_type : Kind of distance. (0) Euclidean, (1) Manhatten and (2) Chebyshev

[P] SequentialUpdating		: if on (1) agents decide on movement based on the current state. 
													.. if off (0) agents decide in parallel, i.e. with the same 
													   information set for all agents.
[P] RationalExpectations	: if on (1) agents only move if movement makes them content. 
													.. if off (0), they move randomly and when not content.
													
Lattice:
[p] lattice			:	graphical representation, only windowed, singular modus. 
    Options:
    0 - off
    1 - show & save start and final
    2 - show every timestep & save start and final
    3- show & save every timestep 
    4 - show & save every movement (careful!)													
																										

Agent:
[P] Colour			:	The colour of the agent (red=1/blue=5, decided by initialisation)
[F] locFracOther: Fraction of other coloured agents in the local neighbourhood. (take care of empty places!)
[F] Content			: 1.0 - the agent is content with the situation, 0.0 - it is not.
[V] Move				: Decide if the agent wants to move. If yes, move. Value: 0-no move, 1-move

Patch:
[F] isOption     : Dummy, based on the asking agent tells if it is an option or not.

Monitor / Output:
[P] lattice				: graphical representation, only windowed, singular modus. 
									.. Options: 0 - off, 1 - show 2- show & save every timestep 
									.. 3 - show & save every step (careful!)
[V] fracMove 		:	fraction of agents that move.
[V] fracContent	:	fraction of agents that are content with their situation
[V] dissimilarity	: measurement of segregation (dissimilarity index)

##Questions before running the model:
What do you expect?
What is underspecified?
How would you analys the model?
...


(PRESS CTRL+E TO EDIT EQUATIONS)

