com.xj.anylogic.engine
Class EnvironmentDiscrete2D

java.lang.Object
  extended by com.xj.anylogic.engine.Environment<AgentDiscrete2D>
      extended by com.xj.anylogic.engine.EnvironmentDiscrete2D
All Implemented Interfaces:
com.xj.anylogic.engine.internal.Child, java.io.Serializable

public class EnvironmentDiscrete2D
extends Environment<AgentDiscrete2D>

Agent environment class for discrete 2D space

Author:
XJ Technologies Company Ltd. www.anylogic.com
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.xj.anylogic.engine.Environment
Environment.AgentCollection<T extends Agent>
 
Field Summary
static int NEIGHBORHOOD_EUCLIDEAN
           
static int NEIGHBORHOOD_MOORE
           
 
Fields inherited from class com.xj.anylogic.engine.Environment
LAYOUT_ARRANGED, LAYOUT_RANDOM, LAYOUT_RING, LAYOUT_SPRING_MASS, LAYOUT_USER_DEFINED, NETWORK_ALL_IN_RANGE, NETWORK_RANDOM, NETWORK_RING_LATTICE, NETWORK_SCALE_FREE, NETWORK_SMALL_WORLD, NETWORK_USER_DEFINED, SPACE_CONTINUOUS_2D, SPACE_DISCRETE_2D, TIME_CONTINUOUS, TIME_DISCRETE
 
Constructor Summary
EnvironmentDiscrete2D(ActiveObject activeObject)
          Creates new environment
 
Method Summary
 void applyLayout()
          Rearranges agents in this environment according to the selected layout type.
 int[] findRandomEmptyCell()
          Tries to find a pseudo-randomly located empty cell and return its row and column in the array with two elements.
 java.lang.String formatSpaceType()
          Returns the name of the space type
 AgentDiscrete2D getAgentAtCell(int r, int c)
          Returns the agent located in the cell with a given row and column, or null.
 int getColumns()
          Returns the number of columns in the space.
 int getLayoutType()
          Returns the layout type.
 int getRows()
          Returns the number of rows in the space.
 int getSpaceType()
          Deprecated. 
 void setLayoutType(int type)
          Sets the layout type.
 void setSpaceDiscrete(double width, double height, int rows, int columns, int neighborhoodType)
          Deprecated. replaced with setupSpace(double, double, int, int, int)
 void setupSpace(double width, double height, int rows, int columns, int neighborhoodType)
          Sets the space type to discrete with the given dimensions and neighborhood type.
 
Methods inherited from class com.xj.anylogic.engine.Environment
applyNetwork, areStepsEnabled, deliverToAll, deliverToRandom, disableSteps, enableSteps, getAgentCollection, getConnectionsPerAgent, getHeight, getNeighborLinkProbability, getNetworkType, getRandomAgent, getScaleFreeM, getWidth, layoutTypeToString, onAfterStep, onBeforeStep, onDestroy, restoreOwner, setNetworkRandom, setNetworkRingLattice, setNetworkScaleFree, setNetworkSmallWorld, setNetworkUserDefined, size, spaceTypeToString, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NEIGHBORHOOD_MOORE

public static final int NEIGHBORHOOD_MOORE
See Also:
Constant Field Values

NEIGHBORHOOD_EUCLIDEAN

public static final int NEIGHBORHOOD_EUCLIDEAN
See Also:
Constant Field Values
Constructor Detail

EnvironmentDiscrete2D

public EnvironmentDiscrete2D(ActiveObject activeObject)
Creates new environment

Parameters:
activeObject - owner of new environment
Method Detail

getSpaceType

@Deprecated
public int getSpaceType()
Deprecated. 

Description copied from class: Environment
Returns the space type, e.g. Environment.SPACE_DISCRETE_2D
(In case of GIS-based environment, always returns Environment.SPACE_CONTINUOUS_2D)

Specified by:
getSpaceType in class Environment<AgentDiscrete2D>
Returns:
the space type

setSpaceDiscrete

@Deprecated
public void setSpaceDiscrete(double width,
                                        double height,
                                        int rows,
                                        int columns,
                                        int neighborhoodType)
Deprecated. replaced with setupSpace(double, double, int, int, int)


setupSpace

public void setupSpace(double width,
                       double height,
                       int rows,
                       int columns,
                       int neighborhoodType)
Sets the space type to discrete with the given dimensions and neighborhood type. A cell in such environment will have a size of (width/columns) by (height/rows).
This method should only be called when the environment is empty.

Parameters:
width - the width of the space
height - the height of the space
rows - the number of rows in the space
columns - the number of columns in the space
neighborhoodType - the type of neighborhood (Euclidean, Moore)

getRows

public int getRows()
Returns the number of rows in the space.

Returns:
the number of rows in the space

getColumns

public int getColumns()
Returns the number of columns in the space.

Returns:
the number of columns in the space

findRandomEmptyCell

public int[] findRandomEmptyCell()
Tries to find a pseudo-randomly located empty cell and return its row and column in the array with two elements.
The current implementation is 100% fairly random.

Returns:
the array with two elements (row and column) of the empty cell, or null

getAgentAtCell

public AgentDiscrete2D getAgentAtCell(int r,
                                      int c)
Returns the agent located in the cell with a given row and column, or null.

Parameters:
r - the row of the cell
c - the column of the cell
Returns:
the agent at (r,c) or null

setLayoutType

public void setLayoutType(int type)
Sets the layout type. To apply the layout call applyLayout(). The default layout is LAYOUT_USER_DEFINED, i.e. arbitrary.

Parameters:
type - the new layout type

getLayoutType

public int getLayoutType()
Returns the layout type. Note that this type has not necessarily been applied.

Returns:
the layout type

applyLayout

public void applyLayout()
Rearranges agents in this environment according to the selected layout type.

See Also:
setLayoutType(int)

formatSpaceType

public java.lang.String formatSpaceType()
Description copied from class: Environment
Returns the name of the space type

Specified by:
formatSpaceType in class Environment<AgentDiscrete2D>
Returns:
the name of the space type


Copyright © 1991-2008 XJ Technlogies. All Rights Reserved.