• Documentation
  • 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>
      • SpatialNode
    • 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
      • AbstractDataLayer
      • AbstractLayer
      • AgentSchedulerLayer<TAgent, TLayer>
      • BoundDataSet
      • DisposeBase
      • MatrixRaster
      • QuerySourceLoader
      • Raster
      • Raster<TValue>
      • 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
    • 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
      • IBoundedDataLayer
      • IChangingLayer
      • IDataContainer
      • IDataLayer
      • IDataSet
      • ILayer
      • IMarsDslLayer
      • IModalChoiceConsumer
      • InitSimulationStep
      • INotifyChangedSource<T>
      • IRaster
      • 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 SimulationContext

    Represents a simulation context object keeping all relevant information's about the simulation execution itself.
    Inheritance
    System.Object
    SimulationContext
    Implements
    ISimulationContext
    ISimulationState
    IDisposable
    Namespace: Mars.Interfaces
    Assembly: Mars.Interfaces.dll
    Syntax
    public class SimulationContext : object, ISimulationContext, ISimulationState, IDisposable
    Remarks
    The context provides the current simulation tick, step and realtime if set as well as delegates which are invoked to provide an (in tick) initialize process with thread-specific information's (StepExecutionContext.

    Constructors

    SimulationContext(Int64)

    Create a simple simulation context, which is not realtime related.
    Declaration
    public SimulationContext(long startStep = null)
    Parameters
    Type Name Description
    System.Int64 startStep

    SimulationContext(TimeSpan, DateTime, Nullable<DateTime>)

    Create a simulation context with realtime settings
    Declaration
    public SimulationContext(TimeSpan oneTickTimeSpan, DateTime startTimePoint = null, DateTime? endTimePoint = null)
    Parameters
    Type Name Description
    TimeSpan oneTickTimeSpan
    DateTime startTimePoint
    System.Nullable<DateTime> endTimePoint

    Fields

    Id

    The identifier of this state
    Declaration
    public readonly Guid Id
    Field Value
    Type Description
    Guid

    RestartAt

    State where to restart the simulation lifecycle or null if no restart is requested
    Declaration
    public long? RestartAt
    Field Value
    Type Description
    System.Nullable<System.Int64>

    Properties

    Active

    Indicates the active or inactive state of the simulation workflow loop
    Declaration
    public bool Active { get; set; }
    Property Value
    Type Description
    System.Boolean

    CurrentStep

    Currently logical simulation step that is used
    Declaration
    public long CurrentStep { get; set; }
    Property Value
    Type Description
    System.Int64

    CurrentTick

    Currently simulation system tick of the workflow
    Declaration
    public long CurrentTick { get; set; }
    Property Value
    Type Description
    System.Int64

    CurrentTimePoint

    Realtime time point of the currently executed step
    Declaration
    public DateTime? CurrentTimePoint { get; set; }
    Property Value
    Type Description
    System.Nullable<DateTime>

    EndTimePoint

    Gets the ending realtime for the last executed simulation tick.
    Declaration
    public DateTime? EndTimePoint { get; }
    Property Value
    Type Description
    System.Nullable<DateTime>

    InputWatch

    Gets the stopwatch, used to measure the duration of the initialization phase, for each agent, entity and layer together.
    Declaration
    public Stopwatch InputWatch { get; }
    Property Value
    Type Description
    Stopwatch

    IsAborted

    Indicates whether the simulation was aborted
    Declaration
    public bool IsAborted { get; set; }
    Property Value
    Type Description
    System.Boolean

    IsFinished

    Indicates whether the simulation run is finished
    Declaration
    public bool IsFinished { get; set; }
    Property Value
    Type Description
    System.Boolean

    IsInitialized

    Indicates whether the simulation run was prepared for the first step
    Declaration
    public bool IsInitialized { get; set; }
    Property Value
    Type Description
    System.Boolean

    IsPaused

    Indicates whether the simulation was paused
    Declaration
    public bool IsPaused { get; set; }
    Property Value
    Type Description
    System.Boolean

    IsPausedCompleted

    Indicates whether the paused simulation state is already finished.
    Declaration
    public bool IsPausedCompleted { get; set; }
    Property Value
    Type Description
    System.Boolean

    IsPrepared

    Indicates whether the simulation was prepared and the initial tick=0 was persisted.
    Declaration
    public bool IsPrepared { get; set; }
    Property Value
    Type Description
    System.Boolean

    IsTimeReferenced

    Determines whether the simulation is executed with a reference to time or not
    Declaration
    public bool IsTimeReferenced { get; }
    Property Value
    Type Description
    System.Boolean

    Iterations

    The count of successful executed steps
    Declaration
    public long Iterations { get; set; }
    Property Value
    Type Description
    System.Int64

    LastDateTime

    The last successfully executed model time point
    Declaration
    public DateTime? LastDateTime { get; set; }
    Property Value
    Type Description
    System.Nullable<DateTime>

    LastPauseDateTime

    The time point for realtime execution where the a pause of the loop was received or null if no pause was ever received
    Declaration
    public DateTime? LastPauseDateTime { get; set; }
    Property Value
    Type Description
    System.Nullable<DateTime>

    LastPauseStep

    The real simulation step where the pause command was received or null if no pause was ever received
    Declaration
    public long? LastPauseStep { get; set; }
    Property Value
    Type Description
    System.Nullable<System.Int64>

    LastPauseTick

    The simulation system tick where the pause command was received or null if no pause was ever received
    Declaration
    public long? LastPauseTick { get; set; }
    Property Value
    Type Description
    System.Nullable<System.Int64>

    LastStep

    The successfully executed model step or null if no step was executed
    Declaration
    public long? LastStep { get; set; }
    Property Value
    Type Description
    System.Nullable<System.Int64>

    LastTick

    The successfully executed system tick beginning at 0 or null if no system tick was executed
    Declaration
    public long? LastTick { get; set; }
    Property Value
    Type Description
    System.Nullable<System.Int64>

    MaxTicks

    Gets or sets the maximum amount of ticks, when a simulation time-range is specified.
    Declaration
    public long MaxTicks { get; set; }
    Property Value
    Type Description
    System.Int64

    Meanwhile

    Gets the global accessible realtime timespan of this scenario, describing how long the simulation world lasted so far.
    Declaration
    public TimeSpan? Meanwhile { get; }
    Property Value
    Type Description
    System.Nullable<TimeSpan>

    OneTickTimeSpan

    Gets the global accessible time delta interval for realtime scenarios.
    Declaration
    public TimeSpan? OneTickTimeSpan { get; }
    Property Value
    Type Description
    System.Nullable<TimeSpan>

    OutputWatch

    Gets the stopwatch, used to measure the duration when processing or checking for simulation output.
    Declaration
    public Stopwatch OutputWatch { get; }
    Property Value
    Type Description
    Stopwatch

    ProgressInPercentage

    Gets the current percentage progress of the simulation execution comparing with MaxTicks.
    Declaration
    public double ProgressInPercentage { get; }
    Property Value
    Type Description
    System.Double

    RestartFlag

    Indicates a restart of the simulation workflow, the workflow itself is active furthermore
    Declaration
    public bool RestartFlag { get; set; }
    Property Value
    Type Description
    System.Boolean

    ResumeFlag

    Indicates that the simulation shall be resumed from the last paused simulation step
    Declaration
    public bool ResumeFlag { get; set; }
    Property Value
    Type Description
    System.Boolean

    Start2020InSeconds

    Generates a simulation context that start on 01-01-2020 and has a delta t of 1 second
    Declaration
    public static SimulationContext Start2020InSeconds { get; }
    Property Value
    Type Description
    SimulationContext

    StartStep

    Gets or sets the optional start step for step-based execution.
    Declaration
    public long StartStep { get; set; }
    Property Value
    Type Description
    System.Int64

    StartTimePoint

    Gets the initializing realtime for simulation tick 0.
    Declaration
    public DateTime? StartTimePoint { get; }
    Property Value
    Type Description
    System.Nullable<DateTime>

    State

    Declaration
    public SimulationContext.WorkflowStateType State { get; set; }
    Property Value
    Type Description
    SimulationContext.WorkflowStateType

    StepFlag

    Indicates whether a simulation step shall be calculated
    Declaration
    public bool StepFlag { get; set; }
    Property Value
    Type Description
    System.Boolean

    TickWatch

    Gets the stopwatch, used to measure the duration of each pre-, main- and post-tick and thus the raw simulation computing time.
    Declaration
    public Stopwatch TickWatch { get; }
    Property Value
    Type Description
    Stopwatch

    Methods

    Dispose()

    Declaration
    public void Dispose()

    Equals(Object)

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    System.Object obj
    Returns
    Type Description
    System.Boolean

    SetTick(Int32, Int32)

    Sets the current step context to the specified one.
    Declaration
    public void SetTick(int tick, int delta = 1)
    Parameters
    Type Name Description
    System.Int32 tick The ticks to set for.
    System.Int32 delta The delta timespan of the logical time.

    UpdateStep(Int32, Int32)

    Updates the clock with the system execution tick by 1, the simulation step by deltaT and the current realtime point by OneTickTimeSpan by one simulation tick.
    Declaration
    public void UpdateStep(int delta = 1, int steps = 1)
    Parameters
    Type Name Description
    System.Int32 delta The logical delta step for move forward in time.
    System.Int32 steps The amount of steps to update for.

    Implements

    ISimulationContext
    ISimulationState
    IDisposable
    Back to top © 2022 MARS GROUP