edu.bonn.cs.iv.bonnmotion
Class Scenario

java.lang.Object
  extended by edu.bonn.cs.iv.bonnmotion.App
      extended by edu.bonn.cs.iv.bonnmotion.Scenario
All Implemented Interfaces:
Model, ScenarioLink
Direct Known Subclasses:
GaussMarkov, ManhattanGrid, OriginalGaussMarkov, RandomSpeedBase, Static

public class Scenario
extends App
implements Model, ScenarioLink

Base class for creating new scenarios.


Field Summary
protected  AttractorField aField
           
protected  double[] aFieldParams
           
protected  Building[] buildings
          Buildings
protected  boolean circular
           
protected  double duration
          Duration of scenario [s].
protected  double ignore
          Length of initial time span which is to be cut off after scenario generation [s].
protected  boolean isTransition
          if true generate() first must do transition
protected  java.lang.String modelName
          Name of the model
protected  MobileNode[] node
          Mobile nodes.
protected  Scenario predecessorScenario
           
protected  java.util.Random rand
           
protected  long randomSeed
          Random seed to initialise RNG.
protected  int transitionMode
           
protected  double x
          Area x length [m].
protected  double y
          Area y length [m].
 
Fields inherited from interface edu.bonn.cs.iv.bonnmotion.ScenarioLink
LINKMODE_FAST, LINKMODE_MOVE
 
Constructor Summary
Scenario()
           
Scenario(int nodes, double x, double y, double duration, double ignore, long randomSeed)
           
Scenario(java.lang.String basename)
           
Scenario(java.lang.String[] args, Scenario _pre, java.lang.Integer _transitionMode)
           
 
Method Summary
 void cut(double begin, double end)
          Extract a certain time span from the scenario.
 Building[] getBuilding()
           
 double getDuration()
           
 double getIgnore()
           
 java.lang.String getModelName()
           
 MobileNode[] getNode()
           
 MobileNode getNode(int n)
           
 long getRandomSeed()
           
 double getX()
           
 double getY()
           
 void go(java.lang.String[] _args)
          Main method from where all the magic starts ...
 int nodeCount()
           
 void paramFromFile(java.lang.String _fn)
          Does the same job as paramFronFile but w/o showing warnings.
 void paramFromFile(java.lang.String _fn, boolean _warn)
          Reads arguments from specific file.
protected  boolean parseArg(char key, java.lang.String val)
           
protected  boolean parseArg(java.lang.String key, java.lang.String val)
           
protected  void postGeneration()
          Called by subclasses after they generate node movements.
protected  void preGeneration()
          Called by subclasses before they generate node movements.
static void printHelp()
           
protected  double randomNextDouble()
          Returns random double form the RandomSeed.
protected  double randomNextGaussian()
          Returns random Gaussian form the RandomSeed
 Position randomNextPosition()
          Helper function for creating scenarios.
 Position randomNextPosition(double fx, double fy)
          Helper function for creating scenarios.
 void read(java.lang.String basename)
          Reads the base information of a scenario from a file.
 void setDuration(double _duration)
           
 void setModelName(java.lang.String _modelName)
           
 void setNode(MobileNode[] _node)
           
 Waypoint transition(Scenario _pre, int _mode, int _nn)
           
 Waypoint transitionWaypointFast(Waypoint _w)
           
 Waypoint transitionWaypointMove(Waypoint _w, int _nn)
           
 void write(java.lang.String _name)
           
 void write(java.lang.String basename, java.lang.String[] params)
          Writes the generated scenario and the scenario parameters to files.
 
Methods inherited from class edu.bonn.cs.iv.bonnmotion.App
exceptionHandler, openPrintWriter, parse, parseArg, parseDoubleArray, parseIntArray, parseStringArray, stringArrayConcat
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

node

protected MobileNode[] node
Mobile nodes.


x

protected double x
Area x length [m].


y

protected double y
Area y length [m].


duration

protected double duration
Duration of scenario [s].


ignore

protected double ignore
Length of initial time span which is to be cut off after scenario generation [s].


randomSeed

protected long randomSeed
Random seed to initialise RNG.


buildings

protected Building[] buildings
Buildings


rand

protected java.util.Random rand

modelName

protected java.lang.String modelName
Name of the model


circular

protected boolean circular

aFieldParams

protected double[] aFieldParams

aField

protected AttractorField aField

isTransition

protected boolean isTransition
if true generate() first must do transition


transitionMode

protected int transitionMode

predecessorScenario

protected Scenario predecessorScenario
Constructor Detail

Scenario

public Scenario()

Scenario

public Scenario(int nodes,
                double x,
                double y,
                double duration,
                double ignore,
                long randomSeed)

Scenario

public Scenario(java.lang.String basename)
         throws java.io.FileNotFoundException,
                java.io.IOException
Throws:
java.io.FileNotFoundException
java.io.IOException

Scenario

public Scenario(java.lang.String[] args,
                Scenario _pre,
                java.lang.Integer _transitionMode)
Method Detail

randomNextDouble

protected double randomNextDouble()
Returns random double form the RandomSeed.

Returns:
double

randomNextGaussian

protected double randomNextGaussian()
Returns random Gaussian form the RandomSeed

Returns:
double

parseArg

protected boolean parseArg(char key,
                           java.lang.String val)
Overrides:
parseArg in class App

parseArg

protected boolean parseArg(java.lang.String key,
                           java.lang.String val)

preGeneration

protected void preGeneration()
Called by subclasses before they generate node movements.


postGeneration

protected void postGeneration()
Called by subclasses after they generate node movements.


cut

public void cut(double begin,
                double end)
Extract a certain time span from the scenario.


go

public void go(java.lang.String[] _args)
Description copied from class: App
Main method from where all the magic starts ...

Specified by:
go in class App
See Also:
App.go(String[])

printHelp

public static void printHelp()

getModelName

public java.lang.String getModelName()
Specified by:
getModelName in interface Model

setModelName

public void setModelName(java.lang.String _modelName)

getDuration

public double getDuration()

getBuilding

public Building[] getBuilding()

getNode

public MobileNode[] getNode()

getNode

public MobileNode getNode(int n)

getX

public double getX()

getY

public double getY()

getIgnore

public double getIgnore()

getRandomSeed

public long getRandomSeed()

setNode

public void setNode(MobileNode[] _node)

nodeCount

public int nodeCount()

paramFromFile

public void paramFromFile(java.lang.String _fn)
                   throws java.io.FileNotFoundException,
                          java.io.IOException
Does the same job as paramFronFile but w/o showing warnings.

Parameters:
_fn - Filename
Throws:
java.io.FileNotFoundException
java.io.IOException
See Also:
paramFromFile(String _fn)

paramFromFile

public void paramFromFile(java.lang.String _fn,
                          boolean _warn)
                   throws java.io.FileNotFoundException,
                          java.io.IOException
Reads arguments from specific file. Then processes the command line arguments (overrides arguments from file).
This Method must be implemented in every subclass.

Parameters:
_fn - Filename
_warn - if warnings should be shown during parsing
Throws:
java.io.FileNotFoundException
java.io.IOException

read

public void read(java.lang.String basename)
          throws java.io.FileNotFoundException,
                 java.io.IOException
Reads the base information of a scenario from a file. It is typically invoked by application to re-read the processing scenario from a generated file.

Parameters:
basename - Basename of the scenario
Throws:
java.io.FileNotFoundException
java.io.IOException

setDuration

public void setDuration(double _duration)

write

public void write(java.lang.String _name)
           throws java.io.FileNotFoundException,
                  java.io.IOException
Specified by:
write in interface Model
Throws:
java.io.FileNotFoundException
java.io.IOException

write

public void write(java.lang.String basename,
                  java.lang.String[] params)
           throws java.io.FileNotFoundException,
                  java.io.IOException
Writes the generated scenario and the scenario parameters to files.

Parameters:
basename - Basename of the output files
Throws:
java.io.FileNotFoundException
java.io.IOException

randomNextPosition

public Position randomNextPosition()
Helper function for creating scenarios.


randomNextPosition

public Position randomNextPosition(double fx,
                                   double fy)
Helper function for creating scenarios.


transition

public Waypoint transition(Scenario _pre,
                           int _mode,
                           int _nn)
                    throws ScenarioLinkException
Specified by:
transition in interface ScenarioLink
Returns:
the last Waypoint of transition
Throws:
ScenarioLinkException

transitionWaypointFast

public Waypoint transitionWaypointFast(Waypoint _w)
Specified by:
transitionWaypointFast in interface ScenarioLink

transitionWaypointMove

public Waypoint transitionWaypointMove(Waypoint _w,
                                       int _nn)
Specified by:
transitionWaypointMove in interface ScenarioLink