added smaller version of directo for something in between tiny and full tests of...
authorjjenista <jjenista>
Sun, 22 Mar 2009 19:28:01 +0000 (19:28 +0000)
committerjjenista <jjenista>
Sun, 22 Mar 2009 19:28:01 +0000 (19:28 +0000)
28 files changed:
Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/Aircraft.java [new file with mode: 0644]
Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/AircraftList.java [new file with mode: 0644]
Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/Algorithm.java [new file with mode: 0644]
Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/Conflict.java [new file with mode: 0644]
Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/ConflictList.java [new file with mode: 0644]
Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/D2.java [new file with mode: 0644]
Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/Fix.java [new file with mode: 0644]
Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/FixList.java [new file with mode: 0644]
Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/Flight.java [new file with mode: 0644]
Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/FlightList.java [new file with mode: 0644]
Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/FlightPlan.java [new file with mode: 0644]
Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/Message.java [new file with mode: 0644]
Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/MessageList.java [new file with mode: 0644]
Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/Point2d.java [new file with mode: 0644]
Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/Point4d.java [new file with mode: 0644]
Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/ReadWrite.java [new file with mode: 0644]
Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/Route.java [new file with mode: 0644]
Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/Static.java [new file with mode: 0644]
Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/Track.java [new file with mode: 0644]
Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/Trajectory.java [new file with mode: 0644]
Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/TrajectorySynthesizer.java [new file with mode: 0644]
Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/Velocity.java [new file with mode: 0644]
Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/dynamic.txt [new file with mode: 0644]
Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/files.txt [new file with mode: 0644]
Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/input.txt [new file with mode: 0644]
Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/input3.txt [new file with mode: 0644]
Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/input4.txt [new file with mode: 0644]
Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/makefile [new file with mode: 0644]

diff --git a/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/Aircraft.java b/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/Aircraft.java
new file mode 100644 (file)
index 0000000..79ce05b
--- /dev/null
@@ -0,0 +1,20 @@
+// class that implements types of aircrafts
+
+public class Aircraft {    
+  String type;
+  double maxLift, maxThrust;
+
+  public Aircraft(String t, double maxL, double maxT) {
+    type=t;
+    maxLift=maxL;
+    maxThrust=maxT;
+  }
+
+  boolean hasType(String type0) {
+    return (type.compareTo(type0)==0);
+  }
+
+  public String toString() {
+    return new String("Airplane: "+type+" "+maxLift+" "+maxThrust);
+  }
+}
diff --git a/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/AircraftList.java b/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/AircraftList.java
new file mode 100644 (file)
index 0000000..90e5a74
--- /dev/null
@@ -0,0 +1,62 @@
+// This class memorizes all the existing aircrafts
+
+//import java.util.*;
+
+public class AircraftList {
+  public int noAircrafts;
+  private Vector aircrafts;
+
+  public AircraftList() {
+    noAircrafts=0; // the number of aircrafts
+    aircrafts=new Vector(100); // the aircrafts
+  }
+
+  // sets the parameters of the aircraft number "pos": its name, its lift and its thrust
+  public void setAircraft(String name,double lift,double thrust) {
+    aircrafts.addElement(new Aircraft(name,lift,thrust));
+  }
+
+  public Aircraft getAircraft(String name) {
+    for( int i = 0; i < aircrafts.size(); ++i ) {
+      Aircraft aAux=(Aircraft) aircrafts.elementAt(i);
+      if (aAux.hasType(name))
+       return aAux;
+    }
+
+    System.out.println("Aircraft not found - "+name);
+    System.exit(-1);
+    return null;
+  }
+
+  public int getAircraftIndex(String name) {
+    for( int i = 0; i < aircrafts.size(); ++i ) {
+      Aircraft aAux=(Aircraft) aircrafts.elementAt(i);
+      if (aAux.hasType(name))
+       return i;
+    }
+
+    System.out.println("Aircraft not found - "+name);
+    System.exit(-1);
+    return 0;
+  }
+
+  public void printInfo() {
+    System.out.println("\n\nThe number of aircrafts:"+noAircrafts);
+    System.out.println("The aircrafts are:");
+    for( int i = 0; i < aircrafts.size(); ++i ) {
+      Aircraft aAux=(Aircraft) aircrafts.elementAt(i);
+      System.out.println(aAux);
+    }
+  }
+
+  public void addAircraft(StringTokenizer parameters) {
+    setAircraft(parameters.nextToken(), Integer.parseInt(parameters.nextToken()), Integer.parseInt(parameters.nextToken()));
+    noAircrafts++;
+  }
+    
+  public void removeAircraft(StringTokenizer parameters) {
+    noAircrafts--;
+    int aAuxIndex=getAircraftIndex(parameters.nextToken());
+    aircrafts.removeElementAt(aAuxIndex);
+  }
+}
diff --git a/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/Algorithm.java b/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/Algorithm.java
new file mode 100644 (file)
index 0000000..32e712b
--- /dev/null
@@ -0,0 +1,107 @@
+//import java.util.*;
+//import java.io.*;
+
+public class Algorithm {
+  public double initialTime,time;
+  public double currIteration;
+  public ConflictList cList;
+
+  public Algorithm() {
+    cList=new ConflictList();    
+  }
+  
+  public /*static*/ void setInitialTime(double time) {
+    initialTime=time;
+    currIteration=0;
+  }
+  
+  public /*static*/ boolean isConflict(D2 d2, Point4d p1, Point4d p2) {
+    Point2d pAux1=new Point2d(p1.x,p1.y);
+    Point2d pAux2=new Point2d(p2.x,p2.y);
+    if ( (Point2d.squaredDistance(pAux1,pAux2) <= 
+         Math.pow(d2.getStatic().radius(),2))
+        
+        && Math.abs(p1.z-p2.z) <= d2.getStatic().distance()
+        )
+      return true;
+
+    return false;
+  }
+
+    public /*static*/ Point4d findConflict(D2 d2, Flight a, Flight b) {
+    Point4d conflictPoint=new Point4d(Point4d.outOfRangeTime(),0,0,0);
+    if (a.flightID!=b.flightID) {
+      Vector p1=a.traject.p;
+      Vector p2=b.traject.p;
+      
+      int pos=0;
+      boolean found=false;
+      
+      while ( (pos<p1.size()) && (pos<p2.size()) && (!found) ) {
+       Point4d point1=(Point4d) p1.elementAt(pos);
+       Point4d point2=(Point4d) p2.elementAt(pos);
+       if (isConflict(d2, point1,point2)) {          
+         System.out.println(point1+" "+point2);
+         found=true;
+         conflictPoint=point1;
+       }
+       pos++;
+      }
+    }
+    return conflictPoint;
+  }
+    
+  public /*static*/ ConflictList getConflictsWith(D2 d2, double time, Flight flight) {
+    ConflictList conflicts=new ConflictList();
+
+    Vector flights=d2.getFlightList().f;
+    int n,i,j;
+    n=d2.getFlightList().noFlights;
+
+    d2.getTrajectorySynthesizer().updateTrajectory(d2, time, flight);
+    for (i=0; i<n; i++) {
+      Flight aAux=(Flight) flights.elementAt(i);
+      d2.getTrajectorySynthesizer().updateTrajectory(d2, time, aAux);
+    }
+
+    Flight aux1=flight;
+    for (i=0; i<n; i++) {
+      Flight aux2=(Flight) flights.elementAt(i);
+      Point4d conflictPoint=findConflict(d2, aux1,aux2);
+      if (!(conflictPoint.outOfRange())) {
+       conflicts.newConflict(conflictPoint,aux1,aux2);
+      }
+    }
+    return conflicts;
+  }
+
+  public /*static*/ void doIteration(D2 d2) {
+    time=initialTime+currIteration*d2.getStatic().iterationStep();
+    currIteration++;
+    System.out.println("In doIteration!");
+    System.out.println("Time:"+time);
+    
+    cList.clear();
+    
+    Vector flights=d2.getFlightList().f;
+    int n=d2.getFlightList().noFlights;
+    int i,j;
+
+    for (i=0;i<n;i++) {        
+      Flight aAux=(Flight) flights.elementAt(i);
+      d2.getTrajectorySynthesizer().updateTrajectory(d2, time,aAux);
+    }
+    
+    System.out.println("Does it get here? (after the trajectory update)");
+
+    for (i=0;i<n;i++)
+      for (j=i+1;j<n;j++) {
+       Flight aux1=(Flight) flights.elementAt(i);
+       Flight aux2=(Flight) flights.elementAt(j);
+       Point4d conflictPoint=findConflict(d2, aux1,aux2);
+       if (!(conflictPoint.outOfRange())) {
+         cList.newConflict(conflictPoint,aux1,aux2);
+       }
+      }
+  }
+}
diff --git a/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/Conflict.java b/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/Conflict.java
new file mode 100644 (file)
index 0000000..e257db6
--- /dev/null
@@ -0,0 +1,24 @@
+// This class memorizes a conflict
+
+public class Conflict {
+  public Point4d coordinates; // its position
+  public Flight flight1, flight2; // the two flights involved in the conflict
+
+  public Conflict(Point4d coord, Flight f1, Flight f2) {
+    coordinates=coord;
+    flight1=f1;
+    flight2=f2;
+  }
+
+  public boolean hasFlights(Flight f1, Flight f2) {
+    if ( ((flight1.flightID==f1.flightID)&&(flight2.flightID==f2.flightID))||
+        ((flight1.flightID==f2.flightID)&&(flight2.flightID==f1.flightID)) )
+      return true;    
+    return false;
+  }
+
+  public String toString() {
+    return ("Conflict at time "+coordinates.time+" position "+coordinates+" between "+
+           flight1.flightID+" and "+flight2.flightID+".");
+  }    
+}
diff --git a/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/ConflictList.java b/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/ConflictList.java
new file mode 100644 (file)
index 0000000..9a8ec7d
--- /dev/null
@@ -0,0 +1,68 @@
+// This class keeps a list of conflicts.
+// The conflicts are updated at every moment of time 
+// We detect only the first conflict between every pair of flights
+
+//import java.util.*;
+
+public class ConflictList 
+{   
+  public int noConflicts; // the number of conflicts
+  private Vector conflicts; // the conflicts
+       
+  public ConflictList() {
+    noConflicts=0;
+    conflicts=new Vector(100);
+  }
+    
+  public void clear() {                
+    noConflicts=0;
+    conflicts.clear();
+  }
+
+  public Conflict conflictAt(int index) {
+    return (Conflict) conflicts.elementAt(index);
+  }
+    
+  public String printInfo() {
+    String st;
+    if (noConflicts==0)
+      st="No conflicts!";
+    else {
+      st=""+noConflicts+" conflicts\n";
+      for( int i = 0; i < conflicts.size(); ++i ) {
+       Conflict cAux=(Conflict) conflicts.elementAt(i);
+       st=st+"\n"+cAux;
+      }
+    }
+    return st;
+  }
+  
+  public void newConflict(Point4d coord, Flight f1, Flight f2) {
+    noConflicts++;
+    conflicts.addElement(new Conflict(coord,f1,f2));
+  }
+  
+  public Conflict findConflict(Flight f1, Flight f2) { 
+    for( int i = 0; i < conflicts.size(); ++i ) {
+      Conflict cAux=(Conflict) conflicts.elementAt(i);
+      if (cAux.hasFlights(f1,f2))
+       return cAux;
+    }
+    return null;
+  }
+
+  public int findConflictIndex(Flight f1, Flight f2) { 
+    for( int i = 0; i < conflicts.size(); ++i ) {
+      Conflict cAux=(Conflict) conflicts.elementAt(i);
+      if (cAux.hasFlights(f1,f2))
+       return i;
+    }
+    return -1;
+  }
+  
+  public void removeConflict(Flight f1, Flight f2) {
+    noConflicts--;
+    int cAuxIndex=findConflictIndex(f1,f2);
+    conflicts.removeElementAt(cAuxIndex);
+  }
+}
diff --git a/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/D2.java b/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/D2.java
new file mode 100644 (file)
index 0000000..874a1d1
--- /dev/null
@@ -0,0 +1,58 @@
+// This class contains the the main method of this project. 
+// All it does is to initialize the input and output threads
+// and kick off the algorithm
+
+//import java.io.*;
+
+public class D2 {
+  public ReadWrite rw;
+
+  private Static                singletonStatic               ; public Static                getStatic               () { return singletonStatic               ; }
+  private AircraftList         singletonAircraftList         ; public AircraftList          getAircraftList         () { return singletonAircraftList         ; }   
+  private Algorithm            singletonAlgorithm            ; public Algorithm             getAlgorithm            () { return singletonAlgorithm            ; }
+  private FixList              singletonFixList              ; public FixList               getFixList              () { return singletonFixList              ; }
+  private Flight               singletonFlight               ; public Flight                getFlight               () { return singletonFlight               ; }
+  private FlightList           singletonFlightList           ; public FlightList            getFlightList           () { return singletonFlightList           ; }
+  private MessageList          singletonMessageList          ; public MessageList           getMessageList          () { return singletonMessageList          ; }
+  private TrajectorySynthesizer singletonTrajectorySynthesizer; public TrajectorySynthesizer getTrajectorySynthesizer() { return singletonTrajectorySynthesizer; }
+
+  public D2() {
+    singletonStatic                = new Static               ();
+    singletonAircraftList         = new AircraftList         ();
+    singletonFixList              = new FixList              ();
+    singletonAlgorithm            = new Algorithm            ();
+    singletonFlight                = new Flight               ( "" );
+    singletonFlightList                   = new FlightList           (); 
+    singletonMessageList          = new MessageList          ();
+    singletonTrajectorySynthesizer = new TrajectorySynthesizer();
+  }
+
+  public static void main(String arg[]) {
+    System.out.println("D2 - Application started");
+
+    D2 d2 = new D2();
+
+    
+    d2.rw=new ReadWrite();
+    d2.rw.read(d2);
+    
+
+    d2.getMessageList().executeAll(d2);
+    
+    int count = 0;
+    while( d2.getFlightList().anyPlanesAlive() ) {
+      d2.getAlgorithm().doIteration(d2);
+      
+      count++;
+      if( count % 10000 == 0 ) {
+       //System.out.println( "iteration "+count );
+      }
+
+      if( count == 1000 ) {
+       break;
+      }
+    }
+
+    d2.rw.write(d2);
+  }
+}
diff --git a/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/Fix.java b/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/Fix.java
new file mode 100644 (file)
index 0000000..f5533e1
--- /dev/null
@@ -0,0 +1,27 @@
+// this class stores the properties of a fix
+
+public class Fix {
+  private String name;
+  private Point2d p;
+
+  public Fix(String name0,Point2d p0) {
+    name=name0;
+    p=p0;
+  }
+
+  public Point2d getFixCoord() {
+    return p;
+  }
+
+  public String getName() {
+    return name;
+  }
+
+  boolean hasName(String name0) {
+    return (name.compareTo(name0)==0);
+  }
+
+  public String toString() {
+    return new String("Fix: "+name+" "+p);
+  }
+}
diff --git a/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/FixList.java b/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/FixList.java
new file mode 100644 (file)
index 0000000..b2b3e73
--- /dev/null
@@ -0,0 +1,78 @@
+// This class memorizes all the fixes in the area.
+// There are methods for setting the properties of a fix and 
+// for getting a fix by a given name
+
+//import java.util.*;
+
+public class FixList {
+  
+  public /*static*/ int noFixes() { return _noFixes; }
+  public /*static*/ Vector fixes() { return _fixes; }
+
+  private int _noFixes;
+  private Vector _fixes;
+
+  public FixList() {
+    _noFixes=0;
+    _fixes=new Vector(100);
+  }
+  
+  // sets the parameters of the fix number "pos": its name 
+  // and its coordinates
+  public /*static*/ void setFix(String name,float x,float y)
+  {
+    _fixes.addElement(new Fix(name,(Point2d) new Point2d(x,y)));
+  }
+
+  public /*static*/ String getFix(int index)
+  {
+    Fix fAux=(Fix) _fixes.elementAt(index);
+    return (String) fAux.getName();
+  }  
+
+  public /*static*/ int getIndex(String name) {
+    for( int i = 0; i < _fixes.size(); ++i ) {
+      Fix fAux=(Fix) _fixes.elementAt( i );
+      if (fAux.hasName(name))
+       return i;      
+    }
+    System.out.println("Fix not found - "+name);
+    System.exit(-1);
+    return 0;
+  }
+
+  public /*static*/ Fix getFix(String name) {
+    for( int i = 0; i < _fixes.size(); ++i ) {
+      Fix fAux=(Fix) _fixes.elementAt( i );
+      if (fAux.hasName(name))
+       return fAux;      
+    }
+    System.out.println("Fix not found - "+name);
+    System.exit(-1);
+    return null;
+  }
+
+  public /*static*/ void printInfo() {
+    System.out.println("\n\nThe number of fixes:"+_noFixes);
+    System.out.println("The fixes are:");
+    for( int i = 0; i < _fixes.size(); ++i ) {
+      Fix bAux=(Fix) _fixes.elementAt( i );
+      System.out.println(bAux);
+    }
+  }
+
+  public /*static*/ void addFix(StringTokenizer parameters)
+  {
+    setFix(parameters.nextToken(), Integer.parseInt(parameters.nextToken()), Integer.parseInt(parameters.nextToken()));
+    _noFixes++;
+  }
+    
+  public /*static*/ void removeFix(StringTokenizer parameters)
+  {
+    _noFixes--;
+    //Fix fAux=getFix(parameters.nextToken());
+    int fixIndex=getIndex(parameters.nextToken());
+    //_fixes.remove(fAux);
+    _fixes.removeElementAt(fixIndex);
+  }
+}
diff --git a/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/Flight.java b/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/Flight.java
new file mode 100644 (file)
index 0000000..b5bae9c
--- /dev/null
@@ -0,0 +1,69 @@
+// the class that describes a flight
+
+public class Flight /*implements Cloneable*/ {
+
+  public String flightID;  // the flight id
+  public int trialStatus; // 
+  public Aircraft aircraftType; // the type of aircraft
+  public Track track; // data from radar
+  public Trajectory traject; // the estimated trajectory
+  public FlightPlan fPlan; // the associated flight plan
+  public String flightType; // the type of flight
+  private float horizAcc, vertAcc; // data used for estimating trajectory
+
+  public static int realFlightStatus(){ return -1;}
+  public static int trialFlightStatus(){ return 1;}  
+
+  public Flight(String id) {
+    this.flightID=id;
+    this.trialStatus=realFlightStatus();
+  }
+    
+  public void setAircraftType (Aircraft ac) {
+    this.aircraftType=ac;
+  }
+
+  public void setFlightType(String flightType) { 
+    this.flightType=flightType;
+  }
+  
+  public void setTrack(Track newTrack) {
+    this.track=newTrack;
+  }
+
+  public void setFlightPlan(FlightPlan fp) {
+    fPlan=fp;
+  }
+
+  public void updateTrajectory(D2 d2, double time) {
+    d2.getTrajectorySynthesizer().updateTrajectory(d2, time, this);
+  }
+
+  public boolean hasID (String id) {
+    return (flightID.compareTo(id)==0);
+  }
+
+  public boolean isFlying (String flType) {
+    return (flightType.compareTo(flType)==0);
+  }
+
+  public static Flight copyOf(Flight f) {
+    Flight fNew       = disjoint flightCopy new Flight(f.flightID);
+    fNew.trialStatus  = f.trialStatus;
+    fNew.aircraftType = f.aircraftType;
+    fNew.track        = f.track;
+    fNew.traject      = f.traject; 
+    fNew.fPlan        = f.fPlan;
+    fNew.flightType   = f.flightType; 
+    fNew.horizAcc     = f.horizAcc;
+    fNew.vertAcc      = f.vertAcc;
+    return fNew;
+  }
+       
+  public String toString() {
+    return new String("Flight "+flightID+"  Aircraft:"+aircraftType.type+
+                     "  Flight type:"+flightType+
+                     "  Cruise Altitude:"+fPlan.cruiseAlt+
+                     "  Cruise Speed:"+fPlan.cruiseSpeed+"\n"+fPlan.r);
+  }
+}
diff --git a/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/FlightList.java b/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/FlightList.java
new file mode 100644 (file)
index 0000000..d0cd5dc
--- /dev/null
@@ -0,0 +1,129 @@
+// This is the class that manages all the flights
+
+//import java.util.*;
+
+public class FlightList {
+  public  int noFlights;
+  public  Vector f;
+
+  public FlightList() {
+    noFlights=0;
+    f=new Vector(100);
+  }
+
+  /*
+  public void addFlight(int index, Flight flight) {
+    f.addElement(index,flight);
+  }
+  */
+
+  public  void addFlightPlan(D2 d2, int time, StringTokenizer st) { 
+    Flight newFlight=disjoint flightAdd new Flight(st.nextToken());
+    noFlights++;
+    f.addElement(newFlight);
+
+    FlightPlan fAux=new FlightPlan();
+    Aircraft aAux=d2.getAircraftList().getAircraft(st.nextToken());      
+    newFlight.setAircraftType(aAux);
+  
+    newFlight.setFlightType(st.nextToken());
+    Route rAux=new Route(Integer.parseInt(st.nextToken()));
+    for (int i=0;i<rAux.noFixes;i++)
+      rAux.addFix(d2,i,st.nextToken());           
+    fAux.setRoute(rAux);
+    fAux.setCruiseParam(Double.parseDouble(st.nextToken()), Double.parseDouble(st.nextToken()));
+    newFlight.setFlightPlan(fAux);
+  }
+
+  public  String getFlightName(int index) {
+    Flight fAux=(Flight) f.elementAt(index);
+    return fAux.flightID;
+  }
+
+  public  void amendFlightPlan(D2 d2, int time, StringTokenizer st) {
+    Flight fAux=getFlight(st.nextToken());
+    Route rAux=new Route(Integer.parseInt(st.nextToken()));    
+    for (int i=0;i<rAux.noFixes;i++)
+      rAux.addFix(d2,i,st.nextToken());      
+    fAux.fPlan.setRoute(rAux);
+    fAux.fPlan.setCruiseParam(Double.parseDouble(st.nextToken()), Double.parseDouble(st.nextToken()));
+  }
+
+    public  void amendFlightInfo(D2 d2, int time, StringTokenizer st) {
+    Flight fAux=getFlight(st.nextToken());
+    Aircraft aAux=d2.getAircraftList().getAircraft(st.nextToken());      
+    fAux.setAircraftType(aAux);
+    fAux.setFlightType(st.nextToken());
+  }
+
+    public  void sendingAircraft(D2 d2, int time, StringTokenizer st) {
+    int noF=Integer.parseInt(st.nextToken());
+    String id;
+    Point4d pos;
+    Velocity vel;
+    Track t;
+    String nameFix;
+    Flight fAux;
+    for (int counter=0; counter<noF; counter++) {
+      id=st.nextToken();
+      pos=new Point4d(time,
+                     Double.valueOf(st.nextToken()).doubleValue(),
+                     Double.valueOf(st.nextToken()).doubleValue(),
+                     Double.valueOf(st.nextToken()).doubleValue());
+      vel=new Velocity(Double.valueOf(st.nextToken()).doubleValue(),
+                      Double.valueOf(st.nextToken()).doubleValue(),
+                      Double.valueOf(st.nextToken()).doubleValue());
+      t=new Track(pos, vel);
+      nameFix=st.nextToken();
+      fAux=getFlight(id);
+      System.out.println(id+" Flight id: "+fAux.flightID);
+      fAux.setTrack(t);
+      System.out.println("Setting current fix ...");
+      fAux.fPlan.setCurrentFix(nameFix);
+      System.out.println("Sent flight "+
+                        fAux.flightID+
+                        "; position: "+
+                        fAux.track.pos);
+      d2.getTrajectorySynthesizer().updateTrajectory(d2, time, fAux);
+      fAux.traject.printInfo();      
+    }
+  }  
+
+  public  void removeFlightPlan(int time, StringTokenizer st) {
+    String id=st.nextToken();
+    int i=0;
+    while ((i<noFlights) && (((Flight) f.elementAt(i)).hasID(id))) i++;
+    if (i<noFlights) f.removeElementAt(i);
+  }
+
+  public  Flight getFlight(String id) {
+    for( int i = 0; i < f.size(); ++i ) {
+      Flight fAux=(Flight) f.elementAt(i);
+      if (fAux.hasID(id))
+       return fAux;
+    }
+    System.out.println("Flight not found - "+id);
+    System.exit(-1);
+    return null;
+  }
+
+  public  boolean anyPlanesAlive() {
+    for( int i = 0; i < f.size(); ++i ) {
+      Flight aAux=(Flight) f.elementAt(i);
+      Vector p1=aAux.traject.p;
+      Point4d pAux= (Point4d) p1.elementAt(0);
+      if (!pAux.outOfRange())
+       return true;
+    }
+    return false;
+  }
+
+  public  void printInfo() {
+    System.out.println("\n\nThe number of flights:"+noFlights);
+    System.out.println("The flights are:");
+    for( int i = 0; i < f.size(); ++i ) {
+      Flight fAux=(Flight) f.elementAt(i);
+      System.out.println(fAux);
+    }
+  }
+}
diff --git a/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/FlightPlan.java b/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/FlightPlan.java
new file mode 100644 (file)
index 0000000..6a3ce01
--- /dev/null
@@ -0,0 +1,31 @@
+// this class implements a flight plan
+
+public class FlightPlan {
+  public double cruiseAlt, cruiseSpeed; // cruising altitude and speed
+
+  public Route r; // the route (given by fixes)
+  
+  public FlightPlan() {
+    cruiseAlt=0;
+    cruiseSpeed=0;
+  }
+
+  public FlightPlan (FlightPlan fp) {
+    cruiseAlt=fp.cruiseAlt;
+    cruiseSpeed=fp.cruiseSpeed;
+  }
+
+  public void setCruiseParam(double crAlt, double crSp) {
+    cruiseAlt=crAlt;cruiseSpeed=crSp;    
+  }
+
+  public void setRoute(Route route) {
+    this.r=route;
+  }
+
+  public void setCurrentFix(String nameFix) {
+    int i=r.getIndexOf(nameFix);
+    System.out.println("name of the fix: "+nameFix+" index:"+i);
+    r.setCurrent(i);
+  }    
+}
diff --git a/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/Message.java b/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/Message.java
new file mode 100644 (file)
index 0000000..6d49a2d
--- /dev/null
@@ -0,0 +1,85 @@
+//import java.util.*;
+
+public class Message {
+  int time;
+  String type;
+  StringTokenizer parameters;
+
+  public Message(int time, String type, StringTokenizer parameters) {
+    this.time=time;
+    this.type=type;
+    this.parameters=parameters;
+  }
+
+  public Message(Message m) {
+    this.time=m.time;
+    this.type=m.type;
+    this.parameters=m.parameters;
+  }
+
+  public void executeMessage(D2 d2) {
+    System.out.println("Executing message of type "+type);
+
+    /*
+    //static messages
+    if (type.compareTo("SET_MAP_SIZE")==0) {
+      System.out.println("Setting the map size...");
+      d2.getStatic().setMapSize(parameters);
+    }
+    else if (type.compareTo("SET_ITERATION_STEP")==0) {
+      System.out.println("Setting the iteration step...");
+      d2.getStatic().setIterationStep(parameters);             
+    }
+    else if (type.compareTo("SET_NO_OF_ITERATIONS")==0) {
+      System.out.println("Setting the no. of iterations...");
+      d2.getStatic().setNumberOfIterations(parameters);                
+    }
+    else if (type.compareTo("SET_CYLINDER")==0) {
+      System.out.println("Setting the cylinder of safety/unsafety...");
+      d2.getStatic().setCylinder(parameters);          
+    }
+    else if (type.compareTo("ADD_FIX")==0) {
+      System.out.println("Adding a new fix...");
+      d2.getFixList().addFix(parameters);
+    }
+    else if (type.compareTo("REMOVE_FIX")==0) {
+      System.out.println("Removing a fix...");
+      d2.getFixList().removeFix(parameters);
+    }
+    else*/ if (type.compareTo("ADD_AIRCRAFT")==0) {
+      System.out.println("Adding an aircraft...");
+      d2.getAircraftList().addAircraft(parameters);
+    }
+    /*
+    else if (type.compareTo("REMOVE_AIRCRAFT")==0) {
+      System.out.println("Removing an aircraft...");
+      d2.getAircraftList().removeAircraft(parameters);
+    }
+    //dynamic messages
+    if (type.compareTo("DO_WORK")==0)
+      d2.getAlgorithm().setInitialTime(time);
+    */
+    if (type.compareTo("ADD_FLIGHT_PLAN")==0) {
+      System.out.println("Adding flight plan...");
+      d2.getFlightList().addFlightPlan(d2,time,parameters);
+    }
+    /*
+    else if (type.compareTo("REMOVE_FLIGHT_PLAN")==0) {
+      System.out.println("Removing flight plan...");
+      d2.getFlightList().removeFlightPlan(time,parameters);            
+    }
+    else if (type.compareTo("AMEND_FLIGHT_INFO")==0) {
+      System.out.println("Amending flight info...");
+      d2.getFlightList().amendFlightInfo(d2, time,parameters);
+    }              
+    else if (type.compareTo("AMEND_FLIGHT_PLAN")==0) {
+      System.out.println("Amending flight plan...");
+      d2.getFlightList().amendFlightPlan(d2, time,parameters);        
+    }
+    else if (type.compareTo("SENDING_AIRCRAFT")==0) {
+      System.out.println("Sending aircraft data...");
+      d2.getFlightList().sendingAircraft(d2, time,parameters);
+    }
+    */
+  }
+}
diff --git a/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/MessageList.java b/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/MessageList.java
new file mode 100644 (file)
index 0000000..c91db3b
--- /dev/null
@@ -0,0 +1,58 @@
+//import java.io.*;
+//import java.util.*;
+
+public class MessageList {
+  private Vector messages;
+    
+  public MessageList() { 
+    messages=new Vector();
+  }
+
+  public Message data() {
+    Message m = (Message) messages.elementAt(0);
+    messages.removeElementAt(0);
+    return m;
+  }
+    
+  public Message next() {
+    return data();
+  }
+
+  public boolean hasNext() {
+    return messages.size() != 0;
+  }
+
+  //is true for DO_WORK
+  public boolean setMessage(String line) {     
+    if (line.equals(""))
+      return false;
+
+    System.out.println("I'm reading line "+line);       
+
+    // treating comments
+    if ((line.charAt(0)=='/')&&(line.charAt(1)=='/'))
+      return false;
+
+    StringTokenizer st=new StringTokenizer(line);
+    int time=Integer.parseInt(st.nextToken());
+    String type=st.nextToken();        
+    Message newMessage=disjoint msgs new Message(time,type,st);
+    messages.addElement(newMessage);
+    if (type.equals("DO_WORK"))
+      return true;
+    
+    return false;
+  }
+  
+  public void executeAll(D2 d2) {
+    System.out.println("executeAll: we have "+messages.size()+" messages.");
+    while(hasNext())
+      next().executeMessage(d2);     
+
+    d2.getStatic().printInfo();
+    d2.getFixList().printInfo();
+    d2.getAircraftList().printInfo();  
+    d2.getFlightList().printInfo();
+    System.out.println("Messages executed\n\n\n\n\n");
+  }
+}
diff --git a/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/Point2d.java b/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/Point2d.java
new file mode 100644 (file)
index 0000000..ec6765a
--- /dev/null
@@ -0,0 +1,27 @@
+// a 2d point - used for fixes
+
+public class Point2d {
+  public double x,y;
+
+  public Point2d () {
+    x=0;
+    y=0;
+  }
+
+  public Point2d (double xcoord , double ycoord) {
+    this.x=xcoord;
+    this.y=ycoord;
+  }
+  
+  public static double horizDistance(Point2d p1, Point2d p2) {
+    return (Math.sqrt(squaredDistance(p1,p2)));
+  }
+
+  public static double squaredDistance(Point2d p1, Point2d p2) {
+    return (Math.pow(p1.x-p2.x,2)+Math.pow(p1.y-p2.y,2));
+  }
+
+  public String toString() {
+    return new String("("+x+","+y+")");
+  }
+}
diff --git a/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/Point4d.java b/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/Point4d.java
new file mode 100644 (file)
index 0000000..003bda5
--- /dev/null
@@ -0,0 +1,97 @@
+// point with 3 space coordinates and time label
+
+//import java.text.*;
+
+public class Point4d extends Point2d {
+  public double x,y,z,time;
+
+  public static int outOfRangeTime() { return -1; }
+
+  public Point4d () {
+    x=0;y=0;z=0;
+    time=0;
+  }
+
+  public Point4d(Point2d p) {
+    x=p.x;
+    y=p.y;     
+    time=z=0;
+  }
+
+  public Point4d (double t, double xcoord, double ycoord, double zcoord) {
+    x=xcoord; y=ycoord; z=zcoord;
+    time=t;
+  }
+
+  public Point4d (double xcoord, double ycoord, double zcoord) {
+    x=xcoord; y=ycoord; z=zcoord;
+    time=0;
+  }
+
+  public Point4d (Point4d p) {
+    x=p.x;
+    y=p.y;
+    z=p.z;
+    time=p.time;
+  }
+
+  public void setTime (double t) {
+    time=t;
+  }
+
+  public static double squaredDistance(Point4d p1,Point4d p2) {
+    return (Math.pow(p1.x-p2.x,2)+Math.pow(p1.y-p2.y,2)+Math.pow(p1.z-p2.z,2));
+  }
+
+  public static double horizDistance(Point4d p1, Point4d p2) {
+    return (Math.sqrt(Math.pow(p1.x-p2.x,2)+Math.pow(p1.y-p2.y,2)));
+  }
+    
+  public int compareX(Point4d p) {
+    if (this.x==p.x)
+      return 0;
+    else 
+      if (this.x<p.x)
+       return -1;
+      else return 1;
+  }
+
+  public int compareY(Point4d p) {
+    if (this.y==p.y)
+      return 0;
+    else 
+      if (this.y<p.y)
+       return -1;
+      else return 1;
+  }
+
+  public int compareZ(Point4d p) {
+    if (this.z==p.z)
+      return 0;
+    else 
+      if (this.z<p.z)
+       return -1;
+      else return 1;
+  }
+
+  public boolean outOfRange() {
+    return (this.time<0);
+  }
+
+  public Point2d toPoint2d() {
+    return (new Point2d(this.x, this.y));
+  }
+
+  /*
+  static public String decimalFormat(double n) {
+    NumberFormat nf=NumberFormat.getNumberInstance();
+    nf.setMaximumFractionDigits(2);    
+    return nf.format(n);
+  }
+  */
+  
+  public String toString() {
+    String st="("+/*decimalFormat*/(x)+";"+/*decimalFormat*/(y)+";"+/*decimalFormat*/(z)+")";
+    return st;
+  }
+}
diff --git a/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/ReadWrite.java b/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/ReadWrite.java
new file mode 100644 (file)
index 0000000..f9129aa
--- /dev/null
@@ -0,0 +1,34 @@
+// This class is the connection between the input and the output threads, 
+// synchronizing the two threads
+
+//import java.io.*;
+//import java.util.*;
+
+public class ReadWrite {
+
+  public ReadWrite() {}
+
+  public void read(D2 d2) {
+    FileInputStream in = new FileInputStream( "input4.txt" );
+
+    while(true) {
+      String line=in.readLine();
+      
+      if(line==null)
+       System.exit(0);             
+      
+      if(d2.getMessageList().setMessage(line))
+       break;
+    }
+
+    System.out.println("Input data read.");
+    System.out.println("Data set read");
+  }   
+
+  public void write(D2 d2) {
+    d2.getStatic().printInfo();
+    d2.getFixList().printInfo();
+    d2.getAircraftList().printInfo();  
+    d2.getFlightList().printInfo();
+  }
+}
diff --git a/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/Route.java b/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/Route.java
new file mode 100644 (file)
index 0000000..10484c4
--- /dev/null
@@ -0,0 +1,92 @@
+// describes a route - number of beacons, the current position on the 
+// route, and the beacons.
+
+//import java.util.*;
+
+public class Route {
+
+  public int noFixes,current;
+  public Vector fixes;
+
+  Route(int no) {
+    noFixes=no;
+    current=0;
+    fixes=new Vector(noFixes);
+  }
+
+  Route(int no, int cur) {
+    noFixes=no;
+    current=cur;
+    fixes=new Vector(noFixes);
+  }
+  
+  public void addFix (int pos, Fix f) {
+    fixes.insertElementAt(f, pos);
+  }
+
+  public void addFix (D2 d2, int pos, String name) {
+    addFix(pos, (Fix) d2.getFixList().getFix(name) );
+  }
+
+  public Fix getFixAt(int pos) {
+    if ((pos>-1) && (pos<noFixes)) {
+      return (Fix) fixes.elementAt(pos);
+    }  
+    return null;
+  }
+    
+  public void setCurrent(int c) {
+    current=c;
+  }
+
+  public Fix getCurrent() {
+    return (Fix) fixes.elementAt(current);
+  }
+
+  public Point2d getCoordsOf (int i) {
+    if ((i>-1) && (i<noFixes)) {
+      Fix tmpFix=(Fix) fixes.elementAt(i);
+      return (tmpFix.getFixCoord());
+    }
+    return null;
+  }
+
+  public int getIndexOf (String nameFix) {
+    int index=-1;
+    for (int i=0 ; i<noFixes ; i++) {      
+      if (((Fix) fixes.elementAt(i)).hasName(nameFix)) {
+       index=i;
+       i=noFixes;
+      }
+    }
+    return index;
+  }
+
+  public int getIndexOf (Fix f) {
+    Fix tmp;
+    int index=-1;
+    for (int i=0 ; i<noFixes ; i++) {      
+      tmp=(Fix) fixes.elementAt(i);
+      if (tmp==f) {
+       index=i;
+       break;
+      }
+    }
+    return index;
+  }
+       
+  public boolean hasFix (Fix f) {
+    int index=-1;
+    for (int i=0 ; i<noFixes; i++) {
+      if (((Fix) fixes.elementAt(i))==f) {
+       index=i;
+       break;
+      }
+    }
+    return (index>-1);
+  }
+
+  public String toString() {
+    return new String("No. Fixes:"+noFixes+":  "+fixes);
+  }
+}
diff --git a/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/Static.java b/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/Static.java
new file mode 100644 (file)
index 0000000..ad37624
--- /dev/null
@@ -0,0 +1,46 @@
+// This class memorizes the static data (besides fixes)
+
+//import java.util.*;
+
+public class Static {
+
+  public /*static*/ double _width, _height; // the dimensions of the given area 
+  public /*static*/ double _iterationStep, _noIterations;    
+  public /*static*/ double _radius, _distance;
+
+  public double width()        { return _width; }
+  public double height()       { return _height; }
+  public double iterationStep(){ return _iterationStep; }
+  public double noIterations() { return _noIterations; }
+  public double radius()       { return _radius; }
+  public double distance()     { return _distance; }
+
+  public Static() {}
+
+  public /*static*/ void setMapSize(StringTokenizer st) {
+    _width=Double.parseDouble(st.nextToken());
+    _height=Double.parseDouble(st.nextToken());
+  }
+
+  public /*static*/ void setCylinder(StringTokenizer st) {
+    _radius=Double.parseDouble(st.nextToken());
+    _distance=Double.parseDouble(st.nextToken());
+  }    
+
+  public /*static*/ void setIterationStep(StringTokenizer st) {
+    _iterationStep=Double.parseDouble(st.nextToken());
+  }
+
+  public /*static*/ void setNumberOfIterations(StringTokenizer st) {
+    _noIterations=Integer.parseInt(st.nextToken());
+  }
+
+  // this is a test procedure
+  public /*static*/ void printInfo() {
+    System.out.println("\n\nStatic Data:");
+    System.out.println("Width:"+_width+"        Height:"+_height);
+    System.out.println("Radius of safety/unsafety:"+_radius);
+    System.out.println("Distance of safety/unsafety:"+_distance);
+    System.out.println("Iteration step:"+_iterationStep+"     No. of Iterations:"+_noIterations);                        
+  }  
+}
diff --git a/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/Track.java b/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/Track.java
new file mode 100644 (file)
index 0000000..73b3d8e
--- /dev/null
@@ -0,0 +1,23 @@
+// the data about a plane - current position and velocity
+
+public class Track {
+  Point4d pos;
+  Velocity vel;
+
+  public Track(Point4d p, Velocity v) {
+    pos=p;
+    vel=v;
+  }
+
+  public void setPosition (Point4d p) {
+    pos=p;
+  }
+
+  public void setVelocity (Velocity v) {
+    vel=v;
+  }
+  
+  public void printInfo() {
+    System.out.println("track: "+pos+"||"+vel);
+  }
+}
diff --git a/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/Trajectory.java b/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/Trajectory.java
new file mode 100644 (file)
index 0000000..a8fd469
--- /dev/null
@@ -0,0 +1,60 @@
+// class that implements the trajectory and some methods of access
+
+//import java.util.*;
+
+public class Trajectory {
+
+  public int noPoints;  // the number of points in the trajectory
+  private int current;
+  public double distToDest, timeToDest; // estimated time&distance to end fix
+  public int nextFixIndex; // index of the next fix in the trajectory of the flight;
+  public Fix nextFix; // the next fix in the trajectory of the flight
+  public Velocity startVelocity; // velocity at the first point in the trajectory;
+  public Vector p; // the points in the trajectory
+
+  public Trajectory(int np) {
+    noPoints=np;
+    p=new Vector(noPoints);
+    current=0;
+  }
+
+  // adds a point to the trajectory at the position "pos"
+  public void setPoint (int pos, Point4d point) {
+    p.insertElementAt((Point4d) point, pos);
+  }
+  
+  public void setNoPoints (int noP) {
+    noPoints=noP;
+  }
+
+  public Point4d getCurrent () {
+    return (Point4d) p.elementAt(current);
+  }
+  
+  public Point4d getPointAt (int index) {
+    return (Point4d) p.elementAt(index);
+  }
+
+  public double distanceToDestination() {
+       return distToDest;
+  }
+  
+  public double timeToDestination(double time) {
+    return (timeToDest-time);
+  }
+
+  public double timeToDestination(int time) {
+    return (timeToDest-time);
+  }
+
+  public Velocity getVelocity() {
+    return startVelocity;
+  }
+
+  public void printInfo() {
+    System.out.println("New trajectory: ");
+    for (int i=0 ; i<noPoints ; i++) {
+      System.out.println(getPointAt(i));
+    }    
+  }  
+}
diff --git a/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/TrajectorySynthesizer.java b/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/TrajectorySynthesizer.java
new file mode 100644 (file)
index 0000000..bec9ff8
--- /dev/null
@@ -0,0 +1,190 @@
+/* 
+  The class that estimates the trajectory of a plane, given its 
+  current position, velocity and flight plan
+*/
+
+//import java.util.*;
+//import java.lang.*;
+
+public class TrajectorySynthesizer {
+  
+  private /*static*/ double horizTotalDist, currentDist;
+  private /*static*/ Velocity currentVelocity;
+  private /*static*/ Point4d currentPos;
+  private /*static*/ int nextFix, noFixes;
+  private /*static*/ int iterations;
+  private /*static*/ double thrust, lift, targetSpeed, targetAlt, timeF; 
+  /*static*/ Trajectory traject;
+
+  private /*static*/ double bigUglyConstant() { return 1000000; }
+  private /*static*/ int limit() { return 200; }
+
+
+  public TrajectorySynthesizer() {
+    timeF=0;
+  }
+
+  public /*static*/ Trajectory updateTrajectory (D2 d2, int time, Flight flight) {
+    Integer nTime=new Integer(time);
+    return updateTrajectory (d2, nTime.doubleValue(), flight);
+  }
+
+    public /*static*/ Trajectory updateTrajectory (D2 d2, double time, Flight flight) {
+    System.out.println("Updating trajectory for "+flight.flightID);
+    int i;
+    setInitialParameters(flight);
+    System.out.println("Starting position: "+currentPos);
+    if (currentPos.outOfRange()) {
+      traject.setNoPoints(1);
+      traject.setPoint(0, currentPos);
+      traject.distToDest=0;
+      traject.timeToDest=0;
+
+    } else {
+      for (i=0 ; (!currentPos.outOfRange()) && (i<limit()) ; i++) {
+       getTrajectoryPoint(flight, time+i*d2.getStatic().iterationStep());
+       if (i==0) {
+         System.out.println("current position: "+currentPos);
+         traject.distToDest=horizTotalDist;
+         traject.nextFixIndex=nextFix;
+         traject.nextFix=(currentPos.outOfRange())? null : flight.fPlan.r.getFixAt(nextFix);
+       }
+       if (i==1) {
+         traject.startVelocity=new Velocity(currentVelocity);          
+       }
+       traject.setPoint(i, (Point4d) currentPos);
+      }
+      traject.setNoPoints(--i);
+      System.out.println(traject.noPoints);
+      traject.timeToDest=(i>0)? traject.getPointAt(i-1).time+timeF:time+timeF;
+    }
+
+    flight.traject=traject;
+    System.out.println("Finished updating trajectory ...");
+    return traject;
+  }
+
+  private /*static*/ void setInitialParameters(Flight flight) {
+    int i;
+    Point2d p1, p2;
+
+    traject=new Trajectory(10);
+    currentPos=new Point4d(flight.track.pos.time, flight.track.pos.x,
+                          flight.track.pos.y, flight.track.pos.z);
+    currentVelocity=new Velocity(flight.track.vel);
+    horizTotalDist=0;
+    p1=new Point2d(currentPos.x, currentPos.y);
+    for (i=flight.fPlan.r.current; i<flight.fPlan.r.noFixes; i++) {
+      p2=flight.fPlan.r.getCoordsOf (i);
+      horizTotalDist+=Point2d.horizDistance(p1,p2);
+      p1=p2;
+    }
+    nextFix=flight.fPlan.r.current;
+    noFixes=flight.fPlan.r.noFixes;
+    thrust=flight.aircraftType.maxThrust;
+    lift=flight.aircraftType.maxLift;
+    targetSpeed=flight.fPlan.cruiseSpeed;
+    targetAlt=flight.fPlan.cruiseAlt;
+  }
+
+  private /*static*/ void getTrajectoryPoint(Flight flight, double time) {
+    if (currentPos.time<time) {
+      double z=newVerticalCoord(flight, time);
+      Point2d pXY=newHorizCoords (flight, time);
+      if (pXY.x<bigUglyConstant()-1) {
+       currentPos=new Point4d(time, pXY.x, pXY.y, z);
+      } else { 
+       currentPos=new Point4d (Point4d.outOfRangeTime(),0,0,0); 
+      }
+    }
+  }
+
+  private /*static*/ double newVerticalCoord (Flight flight, double time) {
+    double newZ;
+    double acc;
+
+    if (currentPos.z>=targetAlt) {
+      newZ=currentPos.z;
+      currentVelocity.vector.z=0;
+    } else {
+      acc=neededAcceleration(currentPos.z, targetAlt, lift);
+      newZ=currentPos.z+currentVelocity.vector.z*(time-currentPos.time)+
+       acc*Math.pow(time-currentPos.time,2)/2;
+      newZ=(newZ>=targetAlt)? targetAlt:newZ;
+      currentVelocity.vector.z=(newZ>=targetAlt)?
+       0:(currentVelocity.vector.z+acc*(time-currentPos.time));
+    }
+    return newZ;
+  }
+
+  private /*static*/ double neededAcceleration(double speed, double nSpeed,
+                                          double thrust) {
+    double accel=(speed<nSpeed)? thrust: (speed>nSpeed)? -thrust:0;
+    return accel;
+  }
+
+  private /*static*/ Point2d decompose (double scalar,
+                                   Point2d p1, Point2d p2) {
+    double angle;
+    if (p1.x==p2.x) {
+      angle=(p1.y<p2.y)? Math.PI()/2.0 : -Math.PI()/2.0;
+    } else {
+      angle=(p1.x<p2.x)?
+       Math.atan((p1.y-p2.y)/(p1.x-p2.x)):
+       Math.PI()+Math.atan((p1.y-p2.y)/(p1.x-p2.x));
+    }
+    return (new Point2d (scalar*Math.cos(angle),
+                        scalar*Math.sin(angle)));
+  }
+    
+  private /*static*/ Point2d newHorizCoords (Flight flight, double time) {
+    double dt=time-currentPos.time;
+    double hSpeed=currentVelocity.horizSpeed();
+    double accel=neededAcceleration(hSpeed, targetSpeed, thrust);
+    double accelTime=(accel==0)? 0:(targetSpeed-hSpeed)/accel;
+    double distance, speed;
+    Point2d current, temp, temp2;
+
+    if (accelTime<dt) {
+      speed=targetSpeed;
+      distance=hSpeed*accelTime+accel*Math.pow(accelTime,2)/2+
+       speed*(dt-accelTime);
+    } else {
+      speed=hSpeed+accel*dt;
+      distance=hSpeed*dt+accel*Math.pow(dt,2)/2;
+    }
+
+    if ((distance>horizTotalDist)&&(horizTotalDist>0)) {
+      timeF=(accel<=0)?(horizTotalDist/hSpeed):
+       (-hSpeed+Math.sqrt(hSpeed*hSpeed+2*accel*horizTotalDist))/accel;
+      System.out.println("TIMEF= "+timeF);
+    }
+
+    horizTotalDist-=distance;
+
+    for (current=currentPos.toPoint2d();
+        (nextFix<noFixes) &&
+          (distance>Point2d.horizDistance(current,
+                                          flight.fPlan.r.getCoordsOf(nextFix)));
+        nextFix++) {
+      distance-=Point2d.horizDistance(current,
+                                     flight.fPlan.r.getCoordsOf(nextFix));
+      current=flight.fPlan.r.getCoordsOf(nextFix);
+    }
+
+    if (nextFix<noFixes) {
+      temp2=decompose(distance,
+                     current, flight.fPlan.r.getCoordsOf(nextFix));
+      temp=decompose(speed,
+                    current, flight.fPlan.r.getCoordsOf(nextFix));
+
+      current=new Point2d(temp2.x+current.x, temp2.y+current.y);
+
+      currentVelocity.vector.x=temp.x;
+      currentVelocity.vector.y=temp.y;
+    } else {
+      current=new Point2d(bigUglyConstant(),bigUglyConstant());
+    }
+    return current;
+  }
+}
diff --git a/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/Velocity.java b/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/Velocity.java
new file mode 100644 (file)
index 0000000..c4513c0
--- /dev/null
@@ -0,0 +1,35 @@
+// the class that describes coordinates the velocity of a plane
+
+//import java.lang.*;
+
+public class Velocity {
+
+  public Point4d vector;
+  public double speed;
+
+  Velocity() {
+    Velocity(0,0,0);
+  }
+  
+  Velocity(double newX, double newY, double newZ) {
+    this.vector=new Point4d(newX, newY, newZ);
+    this.speed=this.horizSpeed();
+  } 
+
+  public static Velocity copyOf(Velocity v) {    
+    return new Velocity( v );
+  }
+  
+  Velocity (Velocity v) {
+    this.vector=new Point4d (v.vector);
+    this.speed=this.horizSpeed();
+  }
+
+  public double horizSpeed() {
+    return Math.sqrt(Math.pow(vector.x,2.0)+Math.pow(vector.y,2.0));
+  }
+  
+  public String toString() {
+    return vector.toString();
+  }
+}
diff --git a/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/dynamic.txt b/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/dynamic.txt
new file mode 100644 (file)
index 0000000..ae3af8b
--- /dev/null
@@ -0,0 +1,5 @@
+10 ADD_PLANE Boeing 747
+20 ADD_PLANE AirBus 300
+30 AMEND_ROUTE Boeing 0 0 0     1  1 0   1 B   B   1   0
+30 AMEND_ROUTE AirBus 10 10 0  -1 -1 0   1 A   A   1   0
+30 DO_WORK
\ No newline at end of file
diff --git a/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/files.txt b/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/files.txt
new file mode 100644 (file)
index 0000000..0c8e2e7
--- /dev/null
@@ -0,0 +1,31 @@
+Aircraft.java
+AircraftList.java
+Algorithm.java
+CanvasImage.java
+CanvasMap.java
+Conflict.java
+ConflictList.java
+D2.java
+Fix.java
+FixList.java
+Flight.java
+FlightList.java
+FlightPlan.java
+Graphic.java
+Message.java
+MessageList.java
+Perform.java
+Point2d.java
+Point4d.java
+Read.java
+ReadMessages.java
+ReadWrite.java
+Route.java
+Static.java
+Track.java
+Trajectory.java
+TrajectorySynthesizer.java
+TrialFlight.java
+TrialPlanning.java
+Velocity.java
+Write.java
diff --git a/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/input.txt b/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/input.txt
new file mode 100644 (file)
index 0000000..1870ac7
--- /dev/null
@@ -0,0 +1,69 @@
+0 SET_ITERATION_STEP 1
+0 SET_NO_OF_ITERATIONS 50
+0 SET_CYLINDER 20 501
+0 SET_MAP_SIZE 600 400
+
+0 ADD_FIX A 50  50
+0 ADD_FIX B 50  150 
+0 ADD_FIX C 100 200
+0 ADD_FIX D 150 100
+0 ADD_FIX E 250 0 
+0 ADD_FIX F 200 200
+0 ADD_FIX G 200 50 
+0 ADD_FIX H 150 300
+0 ADD_FIX I 300 150
+0 ADD_FIX J 350 50 
+0 ADD_FIX K 300 350
+0 ADD_FIX L 350 250
+0 ADD_FIX M 400 200
+0 ADD_FIX N 450 100
+0 ADD_FIX O 100 250
+0 ADD_FIX P 500 300
+0 ADD_FIX Q 250 250
+0 ADD_FIX R 300 100
+0 ADD_FIX S 100 0
+0 ADD_FIX T 450 0  
+0 ADD_FIX U 0   300
+0 ADD_FIX V 200 350
+0 ADD_FIX W 500 150
+
+0 ADD_AIRCRAFT Boeing737 60 5
+0 ADD_AIRCRAFT AirBus310 70 5
+0 ADD_AIRCRAFT DC80      80 6
+0 ADD_AIRCRAFT Boeing747 75 4
+
+20 ADD_FLIGHT_PLAN RO0001 Boeing737 OVER  6 O Q L M N T  10000 5
+20 ADD_FLIGHT_PLAN LH3473 AirBus310 OVER  4 K F G E      10000 5
+20 ADD_FLIGHT_PLAN AF2809 Boeing747 OVER  5 B D R J T    10500 5
+
+
+30 ADD_FLIGHT_PLAN DL8201 DC80      OVER  1 A           9800 7
+30 ADD_FLIGHT_PLAN RO1313 Boeing737 OVER  5 S G I L K   9900 6
+
+35 ADD_FLIGHT_PLAN UA0802 DC80      OVER  4 H Q M T     10000 5 
+
+// changing route
+50 AMEND_FLIGHT_PLAN DL8201               5 P M R G A    9800 7
+
+
+// sending positions
+55 SENDING_AIRCRAFT 1  LH3473 300 360 10500  0 -5 0  K
+62 SENDING_AIRCRAFT 1  RO0001  50 300 9000  2 0 0  O   
+65 SENDING_AIRCRAFT 1  AF2809   0 150 8000     3 0 100  B
+65 SENDING_AIRCRAFT 1  DL8201   500 320 0        0 -2 400  P
+65 SENDING_AIRCRAFT 1  RO1313   90 0 9000      1 1 0    S 
+70 SENDING_AIRCRAFT 1  UA0802   120 330 9800   1.7 0 -200 H
+
+// 70 DO_WORK
+
+
+200 ADD_FLIGHT_PLAN AA3323 DC80      OVER  6 U B D R J T    10000 10
+200 ADD_FLIGHT_PLAN BA1234 Boeing747 OVER  6 S G R I L P    10000 12
+200 ADD_FLIGHT_PLAN RO0023 Boeing737 OVER  6 S A C O H V    9800  10
+200 ADD_FLIGHT_PLAN LH9898 AirBus310 OVER  5 K Q F G E      10100 12
+
+
+220 SENDING_AIRCRAFT 2 AA3323 0 310 0  0 -2 300 U   LH9898 380 350 10000  -1 0 0 K
+225 SENDING_AIRCRAFT 2 RO0023 110 0 10000 -2 0 0 S   BA1234 150 20 9000  2 2 0 G 
+
+225 DO_WORK
diff --git a/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/input3.txt b/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/input3.txt
new file mode 100644 (file)
index 0000000..d4663cf
--- /dev/null
@@ -0,0 +1,57 @@
+0 SET_ITERATION_STEP 1
+0 SET_NO_OF_ITERATIONS 50
+0 SET_CYLINDER 20 501
+0 SET_MAP_SIZE 600 400
+
+0 ADD_FIX A 50 50
+0 ADD_FIX B 50 150 
+0 ADD_FIX C 100 200
+0 ADD_FIX D 150 100
+0 ADD_FIX E 250 0 
+0 ADD_FIX F 200 200
+0 ADD_FIX G 200 50 
+0 ADD_FIX H 150 300
+0 ADD_FIX I 300 150
+0 ADD_FIX J 350 50 
+0 ADD_FIX K 300 350
+0 ADD_FIX L 350 250
+0 ADD_FIX M 400 200
+0 ADD_FIX N 450 100
+0 ADD_FIX O 100 250
+0 ADD_FIX P 500 300
+0 ADD_FIX Q 250 250
+0 ADD_FIX R 300 100
+0 ADD_FIX S 100 0
+0 ADD_FIX T 450 0  
+
+
+0 ADD_AIRCRAFT Boeing737 60 5
+0 ADD_AIRCRAFT AirBus310 70 5
+0 ADD_AIRCRAFT DC80      80 6
+0 ADD_AIRCRAFT Boeing747 75 6
+
+20 ADD_FLIGHT_PLAN Ro0001 Boeing737 OVER  6 O Q L M N T  10000 5
+20 ADD_FLIGHT_PLAN LH3473 AirBus310 OVER  4 K F G E      10000 5
+20 ADD_FLIGHT_PLAN af280  Boeing747 OVER  5 B D R J T    10500 5
+
+
+30 ADD_FLIGHT_PLAN DL8201 DC80      OVER  1 A           9800 7
+30 ADD_FLIGHT_PLAN RO1313 Boeing737 OVER  5 S G I L K   9900 6
+
+35 ADD_FLIGHT_PLAN UA0802 DC80      OVER  4 H Q M T     10000 5 
+
+// changing route
+50 AMEND_FLIGHT_PLAN DL8201               5 P M R G A    9800 7
+
+
+// sending positions
+55 SENDING_AIRCRAFT 1  LH3473 300 360 10500  0 -5 0  K
+62 SENDING_AIRCRAFT 1  Ro0001  50 300 9000  2 0 0  O   
+65 SENDING_AIRCRAFT 1  af280    0 150 8000     3 0 100  B
+65 SENDING_AIRCRAFT 1  DL8201   500 320 0        0 -2 400  P
+65 SENDING_AIRCRAFT 1  RO1313   90 0 9000      1 1 0    S 
+70 SENDING_AIRCRAFT 1  UA0802   120 330 9800   1.7 0 -200 H
+
+70 DO_WORK
+
+
diff --git a/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/input4.txt b/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/input4.txt
new file mode 100644 (file)
index 0000000..1870ac7
--- /dev/null
@@ -0,0 +1,69 @@
+0 SET_ITERATION_STEP 1
+0 SET_NO_OF_ITERATIONS 50
+0 SET_CYLINDER 20 501
+0 SET_MAP_SIZE 600 400
+
+0 ADD_FIX A 50  50
+0 ADD_FIX B 50  150 
+0 ADD_FIX C 100 200
+0 ADD_FIX D 150 100
+0 ADD_FIX E 250 0 
+0 ADD_FIX F 200 200
+0 ADD_FIX G 200 50 
+0 ADD_FIX H 150 300
+0 ADD_FIX I 300 150
+0 ADD_FIX J 350 50 
+0 ADD_FIX K 300 350
+0 ADD_FIX L 350 250
+0 ADD_FIX M 400 200
+0 ADD_FIX N 450 100
+0 ADD_FIX O 100 250
+0 ADD_FIX P 500 300
+0 ADD_FIX Q 250 250
+0 ADD_FIX R 300 100
+0 ADD_FIX S 100 0
+0 ADD_FIX T 450 0  
+0 ADD_FIX U 0   300
+0 ADD_FIX V 200 350
+0 ADD_FIX W 500 150
+
+0 ADD_AIRCRAFT Boeing737 60 5
+0 ADD_AIRCRAFT AirBus310 70 5
+0 ADD_AIRCRAFT DC80      80 6
+0 ADD_AIRCRAFT Boeing747 75 4
+
+20 ADD_FLIGHT_PLAN RO0001 Boeing737 OVER  6 O Q L M N T  10000 5
+20 ADD_FLIGHT_PLAN LH3473 AirBus310 OVER  4 K F G E      10000 5
+20 ADD_FLIGHT_PLAN AF2809 Boeing747 OVER  5 B D R J T    10500 5
+
+
+30 ADD_FLIGHT_PLAN DL8201 DC80      OVER  1 A           9800 7
+30 ADD_FLIGHT_PLAN RO1313 Boeing737 OVER  5 S G I L K   9900 6
+
+35 ADD_FLIGHT_PLAN UA0802 DC80      OVER  4 H Q M T     10000 5 
+
+// changing route
+50 AMEND_FLIGHT_PLAN DL8201               5 P M R G A    9800 7
+
+
+// sending positions
+55 SENDING_AIRCRAFT 1  LH3473 300 360 10500  0 -5 0  K
+62 SENDING_AIRCRAFT 1  RO0001  50 300 9000  2 0 0  O   
+65 SENDING_AIRCRAFT 1  AF2809   0 150 8000     3 0 100  B
+65 SENDING_AIRCRAFT 1  DL8201   500 320 0        0 -2 400  P
+65 SENDING_AIRCRAFT 1  RO1313   90 0 9000      1 1 0    S 
+70 SENDING_AIRCRAFT 1  UA0802   120 330 9800   1.7 0 -200 H
+
+// 70 DO_WORK
+
+
+200 ADD_FLIGHT_PLAN AA3323 DC80      OVER  6 U B D R J T    10000 10
+200 ADD_FLIGHT_PLAN BA1234 Boeing747 OVER  6 S G R I L P    10000 12
+200 ADD_FLIGHT_PLAN RO0023 Boeing737 OVER  6 S A C O H V    9800  10
+200 ADD_FLIGHT_PLAN LH9898 AirBus310 OVER  5 K Q F G E      10100 12
+
+
+220 SENDING_AIRCRAFT 2 AA3323 0 310 0  0 -2 300 U   LH9898 380 350 10000  -1 0 0 K
+225 SENDING_AIRCRAFT 2 RO0023 110 0 10000 -2 0 0 S   BA1234 150 20 9000  2 2 0 G 
+
+225 DO_WORK
diff --git a/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/makefile b/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/makefile
new file mode 100644 (file)
index 0000000..6892efc
--- /dev/null
@@ -0,0 +1,30 @@
+MAIN_CLASS=D2 #smalltest
+
+PROGRAM=test
+SOURCE_FILES=D2.java #smalltest.java
+
+BUILDSCRIPT=~/research/Robust/src/buildscript
+BSFLAGS= -debug -nooptimize -mainclass $(MAIN_CLASS) -justanalyze -ownership -ownallocdepth 1 -ownwritedots final -ownaliasfile aliases.txt -enable-assertions
+
+all: $(PROGRAM).bin
+
+view: PNGs
+       eog *.png &
+
+PNGs: DOTs
+       d2p *COMPLETE*.dot
+
+DOTs: $(PROGRAM).bin
+
+$(PROGRAM).bin: $(SOURCE_FILES)
+       $(BUILDSCRIPT) $(BSFLAGS) -o $(PROGRAM) $(SOURCE_FILES)
+
+clean:
+       rm -f  $(PROGRAM).bin
+       rm -fr tmpbuilddirectory
+       rm -f  *~
+       rm -f  *.dot
+       rm -f  *.png
+       rm -f  aliases.txt
+       rm -f  output.txt
+