+1 (972) 883-2091
ECSS 4.220, 800 W Campbell Rd, Richardson, TX 75083–0688, US

Implementing the “stimulus” package

1. Package Description

This package contains the definitions of an agent’s stimulus. We create seven classes inside the “stimulus” package that correspond to these stimuli.

  1. ChangeDesiredSpeedStimulus
  2. ChangeHeadingStimulus
  3. ChangePostureStimulus
  4. CloseDoorStimulus
  5. IdleStimulus
  6. MoveStimulus
  7. OpenDoorStimulus

These classes extend the class “AgentStimulus” defined inside the package “edu.utdallas.mvs.divas.core.sim.comon.stimulus”.

2. Implementing the “MoveStimulus” class

The “MoveStimulus” class describes the movement stimulus generated by a human agent to indicate its desire to move to a new location. It stores information about the vehicle’s intended new location. To implement this class:

  1. Create a new class inside the package “edu.utdallas.mvs.evacuation.simulation.sim.comon.stimulus” and name it “MoveStimulus”
  2. Write the following code to implement the “MoveStimulus” class:
package edu.utdallas.mavs.evacuation.simulation.sim.common.stimulus;

import com.jme3.math.Vector3f;

import edu.utdallas.mavs.divas.core.sim.common.stimulus.AgentStimulus;

/**
 * An agent move stimulus. The agent tells the environment where it wishes to move to from where it currently is.
 */
public class MoveStimulus extends AgentStimulus implements Comparable<MoveStimulus>
{
    private static final long serialVersionUID = 1L;
    private float             x;
    private float             y;
    private float             z;

    /**
     * Create a new move stimulus using agent ID and position vector.
     * 
     * @param id
     *        the agent's ID
     * @param position
     *        the agent's position
     */
    public MoveStimulus(int id, Vector3f position)
    {
        this(id, position.x, position.y, position.z);
    }

    /**
     * Create a new move stimulus using agent ID and position in floats.
     * 
     * @param id
     *        The agent's ID
     * @param x
     *        The agent's X position
     * @param y
     *        The agent's Y position
     * @param z
     *        The agent's Z position
     */
    public MoveStimulus(int id, float x, float y, float z)
    {
        super(id);

        this.x = x;
        this.y = y;
        this.z = z;
    }

    /**
     * Get the position where the agent wishes to move.
     * 
     * @return the position where the agent wishes to move
     */
    public Vector3f getPosition()
    {
        return new Vector3f(x, y, z);
    }

    @Override
    public int compareTo(MoveStimulus o)
    {
        if(this.id > o.id)
            return 1;
        else if(this.id < o.id)
            return -1;
        else
            return 0;
    }
}

3. Implementing the “ChangeHeadingStimulus” class

The “ChangeHeadingStimulus” class describes the stimulus generated by a agent to indicate its desire to change its heading. This class stores information about the new intended agent’s heading. To create this class:

  1. Create a new class inside the package “edu.utdallas.mvs.evacuation.simulation.sim.comon.stimulus” and name it “ChangeHeadingStimulus”
  2. Write the following code to implement the “ChangeHeadingStimulus” class:
package edu.utdallas.mavs.evacuation.simulation.sim.common.stimulus;

import com.jme3.math.Vector3f;

import edu.utdallas.mavs.divas.core.sim.common.stimulus.AgentStimulus;

/**
 * This class describes a stimulus for changing the heading direction of an agent.
 */
public class ChangeHeadingStimulus extends AgentStimulus
{
    private static final long serialVersionUID = 1L;
    private float             x;
    private float             y;
    private float             z;

    /**
     * Creates a new change heading stimulus
     * 
     * @param id the agent's ID
     * @param heading the agent's heading direction
     */
    public ChangeHeadingStimulus(int id, Vector3f heading)
    {
        this(id, heading.x, heading.y, heading.z);
    }

    /**
     * Creates a new change heading stimulus
     * 
     * @param id the agent's ID
     * @param x the x coordinate of the agent's heading direction
     * @param y the y coordinate of the agent's heading direction
     * @param z the z coordinate of the agent's heading direction
     */
    public ChangeHeadingStimulus(int id, float x, float y, float z)
    {
        super(id);
        this.x = x;
        this.y = y;
        this.z = z;
    }

    /**
     * Gets the x coordinate of the heading direction
     * 
     * @return the x coordinate of the heading direction
     */
    public float getX()
    {
        return x;
    }

    /**
     * Sets the x coordinate of the heading direction
     * 
     * @param x the x coordinate of the heading direction
     */
    public void setX(float x)
    {
        this.x = x;
    }

    /**
     * Gets the y coordinate of the heading direction
     * 
     * @return the y coordinate of the heading direction
     */
    public float getY()
    {
        return y;
    }

    /**
     * Sets the y coordinate of the heading direction
     * 
     * @param y the y coordinate of the heading direction
     */
    public void setY(float y)
    {
        this.y = y;
    }

    /**
     * Gets the z coordinate of the heading direction
     * 
     * @return the z coordinate of the heading direction
     */
    public float getZ()
    {
        return z;
    }

    /**
     * Sets the z coordinate of the heading direction
     * 
     * @param z the z coordinate of the heading direction
     */
    public void setZ(float z)
    {
        this.z = z;
    }
}

4. Implementing the “ChangeDesiredSpeedStimulus” class

The “ChangeDesiredSpeedStimulus” class describes the stimulus generated by a vehicle agent to indicate its desire to change its desired speed. To create this class:

  1. Create a new class inside the package “edu.utdallas.mvs.evacuation.simulation.sim.comon.stimulus” and name it “ChangeDesiredSpeedStimulus”
  2. Write the following code to implement the “ChangeDesiredSpeedStimulus” class:
package edu.utdallas.mavs.evacuation.simulation.sim.common.stimulus;

import edu.utdallas.mavs.divas.core.sim.common.stimulus.AgentStimulus;

/**
 * This class describes a stimulus for changing the speed of an agent.
 */
public class ChangeDesiredSpeedStimulus extends AgentStimulus
{
    private static final long serialVersionUID = 1L;

    private float             desiredSpeed;

    /**
     * Creates a new change desired speed stimulus
     * 
     * @param id
     *        the agent's ID
     * @param desiredSpeed
     *        the agent's desired speed
     */
    public ChangeDesiredSpeedStimulus(int id, float desiredSpeed)
    {
        super(id);
        this.setdesiredSpeed(desiredSpeed);
    }

    /**
     * Sets the agent's desired speed
     * 
     * @param desiredSpeed
     *        the agent's desired speed
     */
    public void setdesiredSpeed(float desiredSpeed)
    {
        this.desiredSpeed = desiredSpeed;
    }

    /**
     * Gets the agent's desired speed
     * 
     * @return the agent's desired speed
     */
    public float getdesiredSpeed()
    {
        return desiredSpeed;
    }
}

5. Implementing the “ChangePostureStimulus” class

The “ChangePostureStimulus” class describes the stimulus generated by a agent to indicate its desire to change its posture. This class stores information about the new intended agent’s posture. To create this class:

  1. Create a new class inside the package “edu.utdallas.mvs.evacuation.simulation.sim.comon.stimulus” and name it “ChangePostureStimulus”
  2. Write the following code to implement the “ChangePostureStimulus” class:
package edu.utdallas.mavs.evacuation.simulation.sim.common.stimulus;

import edu.utdallas.mavs.divas.core.sim.common.stimulus.AgentStimulus;
import edu.utdallas.mavs.evacuation.simulation.sim.common.state.Posture;

/**
 * This class describes a stimulus for changing the posture of an agent.
 */
public class ChangePostureStimulus extends AgentStimulus
{
    private static final long serialVersionUID = 1L;

    private Posture           posture;

    /**
     * Creates a new change posture stimulus
     * 
     * @param id
     *        the agent's ID
     * @param posture
     *        the agent's posture
     */
    public ChangePostureStimulus(int id, Posture posture)
    {
        super(id);
        this.posture = posture;
    }

    /**
     * Gets the agent's posture
     * 
     * @return the agent's posture
     */
    public Posture getPosture()
    {
        return posture;
    }

    /**
     * Sets the agent's posture
     * 
     * @param posture
     *        the agent's posture
     */
    public void setPosture(Posture posture)
    {
        this.posture = posture;
    }
}

6. Implementing the “CloseDoorStimulus” class

The “CloseDoorStimulus” class describes the stimulus generated by door object to indicate its desire to change its close door. To create this class:

  1. Create a new class inside the package “edu.utdallas.mvs.evacuation.simulation.sim.comon.stimulus” and name it “CloseDoorStimulus”
  2. Write the following code to implement the “CloseDoorStimulus” class:
package edu.utdallas.mavs.evacuation.simulation.sim.common.stimulus;

import edu.utdallas.mavs.divas.core.sim.common.stimulus.AgentStimulus;

public class CloseDoorStimulus extends AgentStimulus
{
    private static final long serialVersionUID = 1L;
    private int               envObjID;

    public CloseDoorStimulus(int agentID, int envObjID)
    {
        super(agentID);

        this.envObjID = envObjID;
    }

    public int getEnvObjID()
    {
        return envObjID;
    }

    public void setEnvObjID(int envObjID)
    {
        this.envObjID = envObjID;
    }
}

7. Implementing the “IdleStimulus” class

The “IdleStimulus” class describes the stimulus generated by a agent to indicate its desire to change its idle. To create this class:

  1. Create a new class inside the package “edu.utdallas.mvs.evacuation.simulation.sim.comon.stimulus” and name it “IdleStimulus”
  2. Write the following code to implement the “IdleStimulus” class:
package edu.utdallas.mavs.evacuation.simulation.sim.common.stimulus;

import edu.utdallas.mavs.divas.core.sim.common.stimulus.AgentStimulus;

public class IdleStimulus extends AgentStimulus
{
    private static final long serialVersionUID = 1L;

    public IdleStimulus(int agentID)
    {
        super(agentID);
    }

}

8. Implementing the “OpenDoorStimulus” class

The “OpenDoorStimulus” class describes the stimulus generated by a agent to indicate its desire to change its open. To create this class:

  1. Create a new class inside the package “edu.utdallas.mvs.evacuation.simulation.sim.comon.stimulus” and name it “OpenDoorStimulus”
  2. Write the following code to implement the “OpenDoorStimulus” class:
package edu.utdallas.mavs.evacuation.simulation.sim.common.stimulus;

import edu.utdallas.mavs.divas.core.sim.common.stimulus.AgentStimulus;

public class OpenDoorStimulus extends AgentStimulus
{
    private static final long serialVersionUID = 1L;
    private int               envObjID;

    public OpenDoorStimulus(int agentID, int envObjID)
    {
        super(agentID);

        this.envObjID = envObjID;
    }

    public int getEnvObjID()
    {
        return envObjID;
    }

    public void setEnvObjID(int envObjID)
    {
        this.envObjID = envObjID;
    }
}