• MARS Website
  • Core API
  • SmartOpenHamburg API
  • Model Components API
  • Common API
Show / Hide Table of Contents
  • Mars.Components
    • DependencyRegistrationModelling
  • Mars.Components.Agents
    • AbstractAgent
    • AbstractEntity
    • Agent
  • Mars.Components.Environments
    • AbstractEnvironment
    • AbstractGraphElement
    • AlwaysPassingNodeGuard
    • EntityLane<TEntity>
    • GeoEnvironment
    • GeoHashEnvironment<T>
    • IEnvironmentMediator
    • IModalChoiceResolver
    • PathHeuristics
    • SpatialEdge
    • SpatialGraphEntityExtensions
    • SpatialGraphEnvironment
    • SpatialGraphHelper
    • SpatialHashEnvironment<TEntity>
    • SpatialLane
    • SpatialNode
    • WorldIndexExtensions
  • Mars.Components.Environments.Cartesian
    • CartesianEnvironment<TEntity>
    • CollisionEnvironment<TCharacter, TObstacle>
    • CollisionKind
    • ConeExplorationView
    • ExplorationView
    • GeometryFactory
    • ICartesianEnvironment<TEntity>
    • ICharacter
    • ICollidable
    • ICollisionEnvironment<TCharacter, TObstacle>
    • IObstacle
    • IVisible
    • RayExplorationView
    • TrapezoidExploration
    • VisibilityKind
  • Mars.Components.Environments.Cartesian.Routing
    • CartesianRoutingService<TObstacle>
    • GeometryCoordinatesRoutingPointsGenerator
    • HomogenousRoutingPointsGenerator
    • IRoutingPointsGenerator
    • RandomRoutingPointsGenerator
    • SectionalRandomRoutingPointsGenerator
  • Mars.Components.Layers
    • AbstractActiveLayer
    • AbstractEnvelopedLayer
    • AbstractLayer
    • AbstractVectorFeature
    • AgentSchedulerLayer<TAgent, TLayer>
    • QuerySourceLoader
    • RasterLayer
    • SchedulerEntry
    • SchedulerLayer
    • VectorFeature
    • VectorLayer
    • VectorLayer<T>
    • VectorLayerHelper
  • Mars.Components.Layers.Temporal
    • IQueryFieldProvider
    • ITemporalObjectCatalog
    • ITemporalObjectIterator
    • TemporalCatalogFeature<TKey>
    • TemporalFeatureKind
    • TemporalMetadataLoader
  • Mars.Components.Services
    • AgentManager
  • Mars.Components.Services.Explorations
    • BoltzmannExploration
    • EpsilonGreedyExploration
    • IExplorationPolicy
    • RouletteWheelExploration
    • TabuSearchExploration
  • Mars.Components.Services.Learning
    • InfiniteQLearning
    • QLearning
    • Sarsa
  • Mars.Components.Services.Planning
    • ActionPlanResult
    • GoapAction
    • GoapAgentStates
    • GoapGoal
    • GoapPlanner
    • GoapStateKey<T>
    • GoapStateProperty
    • GoapStateProperty<TElement>
    • IGoapAction
    • IGoapAgentStates
    • IGoapGoal
    • IGoapPlanner
    • IGoapStateKey
    • StatesCommons
  • Mars.Components.Services.Planning.ActionCommons
    • AllGoalsSatisfiedAction
    • NoGoalReachableAction
  • Mars.Components.Starter
    • Command
    • CommandArgumentContainer
    • CommandParser
    • CommandSet
    • HelpCommand
    • Option
    • OptionContext
    • OptionException
    • OptionSet
    • OptionValueCollection
    • OptionValueType
    • SimulationStarter
  • Mars.Components.Starter.Exceptions
    • SimulationStartupException
  • Mars.Interfaces
    • IModelObject
    • ISimulationContainer
    • ISimulationContext
    • ISimulationModule
    • ISimulationState
    • IStepExecutionContext
    • SimulationContext
    • SimulationContext.WorkflowStateType
    • StepExecutionContext
  • Mars.Interfaces.Agents
    • IAgent
    • IAgent<TLayer>
    • IEntity
    • IMarsDslAgent
    • IModalCapabilitiesAgent
    • ISpatialGraphEntity
    • ITickClient
  • Mars.Interfaces.Annotations
    • ActiveConstructor
    • PropertyDescription
  • Mars.Interfaces.Data
    • AbstractDomainData
    • GeometryData
    • IDomainData
    • IGeometryData
    • IIdentifiableData
    • IMarsFeature
    • IRasterBandData
    • ISource
    • IStringData
    • IStringStructuredData
    • IStructuredData
    • IStructuredDataGeometry
    • IValueData
    • LayerInitData
    • RasterBandData
    • StringDataDto
    • StructuredData
    • VectorStructuredData
  • Mars.Interfaces.Environments
    • BoundingBox
    • DirectionType
    • EdgeExploreResult
    • EdgeStop
    • ExploreDirection
    • GeoPositionExtension
    • HighwayType
    • IEdge<TEdge, TNode>
    • IEntityLane<TEntity>
    • IEnvironment
    • IEnvironment<TEntity>
    • IGeoGridEnvironment<T>
    • IGraphEntity
    • IGraphEnvironment<TEdge, TNode>
    • INode<TEdge, TNode>
    • INodeGuard
    • IPositionable
    • IRoutePlanner
    • ISpatialEdge
    • ISpatialGraphEnvironment
    • ISpatialLane
    • ISpatialNode
    • LaneExploreResult
    • ModalChoice
    • MultimodalRoute
    • NodeIntegrationKind
    • Position
    • Route
    • RouteStop
    • Size
    • SpatialGraphExploreResult
    • SpatialModalityType
    • TrafficLightPhase
  • Mars.Interfaces.Layers
    • FinallySimulationStep
    • IChangingLayer
    • IDataContainer
    • IDataLayer
    • IDataSet
    • IEnvelopDataLayer
    • ILayer
    • IMarsDslLayer
    • IModalChoiceConsumer
    • InitSimulationStep
    • INotifyChangedSource<T>
    • IRaster<TValue>
    • IRasterLayer
    • ISteppedActiveLayer
    • IVectorFeature
    • IVectorLayer
    • IVectorLayer<T>
    • IVectorNode<TEntity>
    • RegisterAgent
    • UnregisterAgent
  • Mars.Interfaces.Model
    • ActiveTypeMapping
    • AgentMapping
    • AgentType
    • ConstructorType
    • ContainsOperator
    • DataContainer
    • DataType
    • EntityMapping
    • EntityType
    • Execution
    • FeatureType
    • Globals
    • IdentifiableElement
    • IndividualMapping
    • Input
    • InputConfiguration
    • LayerMapping
    • LayerType
    • ModelDescription
    • ModelElement
    • ObjectType
    • Output
    • OutputConfiguration
    • OutputFilter
    • OutputKind
    • OutputTargetType
    • ParameterMapping
    • Processing
    • ProcessingConfiguration
    • ProcessingTargetType
    • PropertyType
    • SimulationConfig
    • TimeSpanUnit
    • TimeSpanUnitExtensions
    • TypeElement
    • TypeMapping
  • Mars.Interfaces.Model.Converters
    • CultureConverter
    • SerializationTypeConverter
    • TimeSpanUnitConverter
  • Mars.Interfaces.Model.Exceptions
    • InvalidTypeException
    • MissingTypeException
  • Mars.Interfaces.Model.Options
    • AbstractEndpointOptions
    • AbstractFileOptions
    • AbstractOptions
    • AscOptions
    • CsvOptions
    • GeoJsonOptions
    • MongoOptions
    • MqttOptions
    • PostgresSqlOptions
    • RedisOptions
    • RelationalEndpointOptions
    • SerializationType
    • SocketOutputOptions
    • SpatialGraphOptions
    • SqLiteOptions
    • TripsOptions

Class SpatialHashEnvironment<TEntity>

Represents the spatial hash environment for a grid-based index with exploration, movement and lookup. This class provides all base functionality with provided properties and the initialization of the index.
Inheritance
System.Object
AbstractEnvironment
SpatialHashEnvironment<TEntity>
Implements
IEnvironment<TEntity>
IEnvironment
IModelObject
System.IDisposable
Inherited Members
AbstractEnvironment.ArrayComparer
AbstractEnvironment.DistanceFunction
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Mars.Components.Environments
Assembly: Mars.Components.dll
Syntax
public sealed class SpatialHashEnvironment<TEntity> : AbstractEnvironment, IEnvironment<TEntity>, IEnvironment, IModelObject, IDisposable where TEntity : IPositionable, IEntity
Type Parameters
Name Description
TEntity The type to store within the index.

Constructors

| Improve this Doc View Source

SpatialHashEnvironment(Double, Double, Boolean, Int32)

Creates a spatial hash grid environment without boundaries and the centre specified by the and
Declaration
public SpatialHashEnvironment(double dimensionX, double dimensionY, bool withBoundaries = false, int cellSize = 1)
Parameters
Type Name Description
System.Double dimensionX The X axes of this grid environment
System.Double dimensionY The Y axes of this grid environment
System.Boolean withBoundaries Indicates whether this environment has boundaries specified by the dimensions
System.Int32 cellSize The size of each grid cell, Default is 1
Exceptions
Type Condition
System.ArgumentException cannot be negative cannot be negative cannot be zero or negative

Properties

| Improve this Doc View Source

CellSize

The size of each grid cell covering the passed radius for exploration.
Declaration
public int CellSize { get; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

Centre

The centre point of this environment
Declaration
public Position Centre { get; }
Property Value
Type Description
Position
| Improve this Doc View Source

CheckBoundaries

Gets or sets the flag to check for boundaries of this environment and repositioning of entities if they try to move outside the desired DimensionX and DimensionY.
Declaration
public bool CheckBoundaries { get; set; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

DimensionX

The extension and maximum x-position of this environment.
Declaration
public int DimensionX { get; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

DimensionY

The extension and maximum y-position of this environment.
Declaration
public int DimensionY { get; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

Entities

All managed entities of type within this environment.
Declaration
public IEnumerable<TEntity> Entities { get; }
Property Value
Type Description
System.Collections.Generic.IEnumerable<TEntity>
| Improve this Doc View Source

GridHeight

Gets the amount of grid cell in y-direction
Declaration
public int GridHeight { get; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

GridWidth

Gets the amount of grid cell in x-direction
Declaration
public int GridWidth { get; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

IsDiscretizePosition

Gets or sets the flag indicating whether the environment should discretize the (x,y) position coordinate or should keep it continuous.
Declaration
public bool IsDiscretizePosition { get; set; }
Property Value
Type Description
System.Boolean

Methods

| Improve this Doc View Source

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Declaration
public void Dispose()
| Improve this Doc View Source

Explore(Position, Double, Int32, Func<TEntity, Boolean>)

Represents the spatial hash environment for a grid-based index with exploration, movement and lookup. This class provides all base functionality with provided properties and the initialization of the index.
Declaration
public IEnumerable<TEntity> Explore(Position position = null, double radius = -1, int count = -1, Func<TEntity, bool> predicate = null)
Parameters
Type Name Description
Position position
System.Double radius
System.Int32 count
System.Func<TEntity, System.Boolean> predicate
Returns
Type Description
System.Collections.Generic.IEnumerable<TEntity>
| Improve this Doc View Source

Explore(Double, Double, Double, Int32, Func<TEntity, Boolean>)

Queries the environment for entities of type from a specified position in form of a 2D coordinate (x,y). The query can be restricted by optional passed query limit and the radius to lookup. Also the lookup in up-/downwards or in right/leftwards can be configured.
Declaration
public IEnumerable<TEntity> Explore(double x, double y, double radius = -1, int count = -1, Func<TEntity, bool> predicate = null)
Parameters
Type Name Description
System.Double x The outgoing x coordinate.
System.Double y The outgoing y coordinate.
System.Double radius Optional radius interpreted as euclidean coordinate distance.
System.Int32 count Optional limit of entities to query.
System.Func<TEntity, System.Boolean> predicate Optional predicate which will be applied during query execution to filter out entities matching a specific condition.
Returns
Type Description
System.Collections.Generic.IEnumerable<TEntity> Returns a collection of distance-based ordered entities of type .
| Improve this Doc View Source

Explore(Double[], Double, Int32, Func<TEntity, Boolean>)

Represents the spatial hash environment for a grid-based index with exploration, movement and lookup. This class provides all base functionality with provided properties and the initialization of the index.
Declaration
public IEnumerable<TEntity> Explore(double[] position, double radius = -1, int count = -1, Func<TEntity, bool> predicate = null)
Parameters
Type Name Description
System.Double[] position
System.Double radius
System.Int32 count
System.Func<TEntity, System.Boolean> predicate
Returns
Type Description
System.Collections.Generic.IEnumerable<TEntity>
| Improve this Doc View Source

Insert(TEntity)

Inserts an positionable entity into the environment defined by their
Declaration
public bool Insert(TEntity entity)
Parameters
Type Name Description
TEntity entity The entity to passionate.
Returns
Type Description
System.Boolean Returns True if the entity was successfully inserted
| Improve this Doc View Source

InsertExplicit(TEntity)

Inserts an entity explicitly into environment so that when it is not boundary conform. The nearest edge position will be calculated and the agent will be set directly there.
Declaration
public bool InsertExplicit(TEntity entity)
Parameters
Type Name Description
TEntity entity The entity to insert
Returns
Type Description
System.Boolean Returns true when the entity was successfully inserted.
| Improve this Doc View Source

IntersectionPoints(Double, Double, Double, Double)

Find the coordinates where the line y=mx+b intersects the edges of the environment.
Declaration
public ISet<double[]> IntersectionPoints(double sourceX, double sourceY, double targetX, double targetY)
Parameters
Type Name Description
System.Double sourceX The x coordinate of the source for the intersection ray.
System.Double sourceY The y coordinate of the source for the intersection ray.
System.Double targetX The x coordinate of the target for the intersection ray.
System.Double targetY The y coordinate of the target for the intersection ray.
Returns
Type Description
System.Collections.Generic.ISet<System.Double[]> Returns a set of intersection points between the source and target
| Improve this Doc View Source

IntersectionPoints(Double[], Double[])

Find the coordinates where the line y=mx+b intersects the edges of the environment.
Declaration
public ISet<double[]> IntersectionPoints(double[] source, double[] target)
Parameters
Type Name Description
System.Double[] source Source point of the ray
System.Double[] target Target point of the ray
Returns
Type Description
System.Collections.Generic.ISet<System.Double[]> the points of intersection
| Improve this Doc View Source

MoveTo(TEntity, Position, Double, Func<Double[], Boolean>)

Moves an entity to the destination of type Position along an optimal ray path with minimal costs. Note that his method does not guarantee to reach the destination.
Declaration
public Position MoveTo(TEntity entity, Position position, double travellingDistance = 0, Func<double[], bool> predicate = null)
Parameters
Type Name Description
TEntity entity The entity to move.
Position position The target destination coordinate.
System.Double travellingDistance The distance to move
System.Func<System.Double[], System.Boolean> predicate The predicate along the movement which need to be valid or null
Returns
Type Description
Position Returns the new position of the entity> or null if no positioning happened.
| Improve this Doc View Source

MoveTo(TEntity, Double, Double, Double, Func<Double[], Boolean>)

Moves an entity to the destination along an optimal ray path with minimal costs. Note that his method does not guarantee to reach the destination.
Declaration
public Position MoveTo(TEntity entity, double x, double y, double travellingDistance = 0, Func<double[], bool> predicate = null)
Parameters
Type Name Description
TEntity entity The entity to move
System.Double x The x coordinate of the destination.
System.Double y The y coordinate of the destination.
System.Double travellingDistance The distance to move
System.Func<System.Double[], System.Boolean> predicate The predicate along the movement which need to be valid or null
Returns
Type Description
Position Returns the new position of the entity> or null if no positioning happened.
| Improve this Doc View Source

MoveTo(TEntity, Double[], Double, Func<Double[], Boolean>)

Moves an entity to destination along an optimal path with minimal costs. Note that his method does not guarantee to reach the destination.
Declaration
public Position MoveTo(TEntity entity, double[] position = null, double travellingDistance = 0, Func<double[], bool> predicate = null)
Parameters
Type Name Description
TEntity entity
System.Double[] position The discrete position target
System.Double travellingDistance The distance to move
System.Func<System.Double[], System.Boolean> predicate The predicate along the movement which need to be valid or null
Returns
Type Description
Position Returns the new position of the entity> or null if no positioning happened.
| Improve this Doc View Source

MoveTowards(TEntity, DirectionType, Double)

Moves an entity the travelling distance distanceToPass towards the direction with a fixed bearing.
Declaration
public Position MoveTowards(TEntity entity, DirectionType direction, double distanceToPass = 1)
Parameters
Type Name Description
TEntity entity The entity to move
DirectionType direction One of the eight direction on a 2D plane, including diagonal
System.Double distanceToPass The distance units to pass.
Returns
Type Description
Position Returns the new position of the entity or null if no positioning happened.
| Improve this Doc View Source

MoveTowards(TEntity, Double, Double)

Moves an entity the travelling distance distanceToPass towards the bearing direction.
Declaration
public Position MoveTowards(TEntity entity, double bearing, double distanceToPass = 0)
Parameters
Type Name Description
TEntity entity The entity to move
System.Double bearing The bearing in degree in value range 0-360
System.Double distanceToPass The distance units to pass.
Returns
Type Description
Position Returns the new position of the entity> or null if no positioning happened.
| Improve this Doc View Source

PosAt(TEntity, Double, Double)

Moves an entity to the desired destination.
Declaration
public Position PosAt(TEntity entity, double x, double y)
Parameters
Type Name Description
TEntity entity the object to move
System.Double x The x coordinate of the destination.
System.Double y The y coordinate of the destination.
Returns
Type Description
Position Returns the new position of the entity> or null if no positioning happened.
| Improve this Doc View Source

PosAt(TEntity, Double[])

Set the entity exactly at the desired position without any movement actions.
Declaration
public Position PosAt(TEntity entity, double[] position)
Parameters
Type Name Description
TEntity entity the object to move
System.Double[] position The coordinates of the position to position to
Returns
Type Description
Position Returns the new position of the entity> or null if no positioning happened.
| Improve this Doc View Source

Remove(TEntity)

Removes the entity item from the environment at the defined Position over the IPositionable implementation of entity.
Declaration
public bool Remove(TEntity entity)
Parameters
Type Name Description
TEntity entity The entity and position to remove
Returns
Type Description
System.Boolean Returns True if the entity was successfully removed
| Improve this Doc View Source

Reset()

Clear the whole environment and each environment related information.
Declaration
public void Reset()

Implements

IEnvironment<TEntity>
IEnvironment
IModelObject
System.IDisposable

Extension Methods

Serializer.Save<T>(T, out Byte[], SerializerCompression)
Serializer.Save<T>(T, Stream, SerializerCompression)
Serializer.Save<T>(T, BinaryFormatter, Stream, SerializerCompression)
Serializer.Save<T>(T, String, SerializerCompression)
Serializer.Save<T>(T, String)
Matrix.Concatenate<T>(T, T[])
Matrix.Replace<T>(T, Object, Object)
DomainDataImporter.Import(Object, InputConfiguration)
ObjectSerialize.Serialize(Object)
Matrix.IsEqual(Object, Object, Decimal, Decimal)
  • Improve this Doc
  • View Source
In This Article
Back to top Copyright © MARS GROUP. HAW Hamburg