• Documentation
  • Core API
  • SmartOpenHamburg API
  • Model Components API
  • Common API
Search Results for

    Show / Hide Table of Contents
    • MARS DSL Language
    • MARS Runtime System
      • Getting started with MARS
      • Basic Concepts
        • Multi-Agent-Simulation
        • Agents
        • Layers
        • Entities
        • Environments
          • SpatialHashEnvironment
          • GeoHashEnvironment
          • SpatialGraphEnvironment
          • CollisionEnvironment
        • Model Setup
      • Model Configuration
        • Agent and Entity Configuration
        • Layer Configuration
        • Output Filter
        • Simulation Configuration Options
        • Simulation Output Formats
      • Data Sources
        • Geospatial Data Sources
        • Geospatial Data Types
        • ASCII grid (.asc)
        • CSV
        • Time-series Data
      • Analysis and Visualization
        • Visualizing Agent Movement Trajectories
        • Simple Live Visualization
        • Analyzing Output Data
      • Tutorials
        • Creating a new MARS C# project
        • Creating a starting point for your model
        • Creating vector and raster layer files
        • Building your first model (wolf-sheep-grass)
        • Common problems and solutions
        • Acquire geo data for layers
        • Build and start your model in Kubernetes cluster
    • SmartOpenHamburg
      • Quick Start
      • Ready to use scenarios (boxes)
        • Ferry Transfer
        • Green4Bikes
        • Results
        • Result Schemas
      • Layer
        • Multimodal Layer
        • Modal Layer
        • Scheduling Layer
        • Vector Layer
      • Agents
        • Behaviour Model
        • Multimodal
        • Multi-Capable
        • Multi-Modality
        • Citizen
        • Traveler
      • Entities
        • Referencing
        • Street Vehicles
        • Bicycle Vehicles
        • Ferry

    Model Definition

    In order to use a model, entities, agents and layer types must be made known to the system.

    A so-called ModelDescription is defined in the project (for example in the entry point Main()) and all relevant types are registered.

    Registration

    First, the using import of the namespace must be added:

    using Mars.Core.Model.Entities;
    

    In the program code (for example the entry point Main() of the .NetCore application) a ModelDescription object must be defined. This object contains all types that occur in the model and that can be parameterized externally by a SimulationConfig.

    
    public static void Main() 
    {
        var description = new ModelDescription();
    
        description.AddLayer<MyLayer>();
        description.AddAgent<MyAgent,MyLayer>();
    
    }
    

    The types registered above include the self-defined agent type MyAgent and the corresponding agent layer MyLayer. If you want to use additional data in the model, you have to register the respective data layers additionally:

    description.AddLayer<MyVectorLayer>();
    description.AddLayer<MyRasterLayer>();
    

     MyLayer can also be used as a data layer like MyVectorLayer or MyRasterLayer. The layer implements the required contract (see here).

    Registration with Names

    By default, the defined class name (e.g. MyAgent) is used as the name within the model. Alternative names can be given during registration:

    description.AddAgent<MyAgent,MyLayer>("myAlternativeAgentName");
    

    This allows the types to be mapped using a different name within the configuration:

    {
      "agents": [
        {"name": "myAlternativeAgentName", "file": "anyInput.csv"}
      ]
    }
    
    In This Article
    Back to top © 2022 MARS GROUP