Package modelarium

Class ModelElement

java.lang.Object
modelarium.ModelElement
All Implemented Interfaces:
DeepCopyable<ModelElement>
Direct Known Subclasses:
Agent, Environment

public abstract class ModelElement extends Object implements DeepCopyable<ModelElement>
Abstract base class for all model elements in the simulation.

Each model element represents either an Agent or the Environment and holds a unique name, a set of attributes, and a reference to its ModelElementAccessor.

  • Constructor Details

    • ModelElement

      public ModelElement(String name, AttributeSetCollection attributeSetCollection)
      Constructs a model element with the given name and attribute set collection.
      Parameters:
      name - the unique name of the element
      attributeSetCollection - the set of attributes to associate with this element
  • Method Details

    • getName

      public String getName()
      Returns:
      the name of this model element
    • getAttributeSetCollection

      public AttributeSetCollection getAttributeSetCollection()
      Returns:
      the attribute set collection for this model element
    • setModelElementAccessor

      public void setModelElementAccessor(ModelElementAccessor modelElementAccessor)
      Sets the model element accessor, which provides external access to model context, data, and messaging.

      This method is protected, as it should only be called during model setup.

      Parameters:
      modelElementAccessor - the accessor to associate with this element
    • getModelElementAccessor

      public ModelElementAccessor getModelElementAccessor()
      Returns:
      the accessor associated with this element, if initialised
    • setup

      public void setup()
      Initialises the attribute set for this element by calling its setup method. This should be called before the simulation begins.
    • run

      public abstract void run()
      Defines the logic to be executed on each simulation tick. Must be implemented by all concrete subclasses (agents and environment).