From d2b3193c5612e6ed27f3cf818ba20d8a662564f7 Mon Sep 17 00:00:00 2001 From: jjenista Date: Mon, 23 Feb 2009 23:18:41 +0000 Subject: [PATCH] new mlp benchmark --- .../mlp/directto/mlp-java/Aircraft.java | 20 ++ .../mlp/directto/mlp-java/AircraftList.java | 60 +++++ .../mlp/directto/mlp-java/Algorithm.java | 109 ++++++++ .../mlp/directto/mlp-java/Conflict.java | 24 ++ .../mlp/directto/mlp-java/ConflictList.java | 68 +++++ .../Benchmarks/mlp/directto/mlp-java/D2.java | 46 ++++ .../Benchmarks/mlp/directto/mlp-java/Fix.java | 27 ++ .../mlp/directto/mlp-java/FixList.java | 76 ++++++ .../mlp/directto/mlp-java/Flight.java | 72 ++++++ .../mlp/directto/mlp-java/FlightList.java | 129 +++++++++ .../mlp/directto/mlp-java/FlightPlan.java | 31 +++ .../mlp/directto/mlp-java/Message.java | 85 ++++++ .../mlp/directto/mlp-java/MessageList.java | 59 +++++ .../mlp/directto/mlp-java/Point2d.java | 27 ++ .../mlp/directto/mlp-java/Point4d.java | 97 +++++++ .../mlp/directto/mlp-java/ReadWrite.java | 36 +++ .../mlp/directto/mlp-java/Route.java | 95 +++++++ .../mlp/directto/mlp-java/Static.java | 48 ++++ .../mlp/directto/mlp-java/Track.java | 23 ++ .../mlp/directto/mlp-java/Trajectory.java | 60 +++++ .../mlp-java/TrajectorySynthesizer.java | 193 ++++++++++++++ .../mlp/directto/mlp-java/TrialFlight.java | 127 +++++++++ .../mlp/directto/mlp-java/Velocity.java | 35 +++ .../mlp/directto/mlp-java/dynamic.txt | 5 + .../mlp/directto/mlp-java/files.txt | 31 +++ .../mlp/directto/mlp-java/input.txt | 69 +++++ .../mlp/directto/mlp-java/input3.txt | 57 ++++ .../mlp/directto/mlp-java/input4.txt | 69 +++++ .../Benchmarks/mlp/directto/mlp-java/makefile | 28 ++ .../mlp/directto/original-java/Aircraft.java | 26 ++ .../directto/original-java/AircraftList.java | 65 +++++ .../mlp/directto/original-java/Algorithm.java | 123 +++++++++ .../mlp/directto/original-java/Conflict.java | 29 +++ .../directto/original-java/ConflictList.java | 91 +++++++ .../mlp/directto/original-java/D2.java | 37 +++ .../mlp/directto/original-java/Fix.java | 39 +++ .../mlp/directto/original-java/FixList.java | 92 +++++++ .../mlp/directto/original-java/Flight.java | 93 +++++++ .../directto/original-java/FlightList.java | 156 +++++++++++ .../directto/original-java/FlightPlan.java | 43 +++ .../mlp/directto/original-java/Message.java | 100 +++++++ .../directto/original-java/MessageList.java | 63 +++++ .../mlp/directto/original-java/Point2d.java | 44 ++++ .../mlp/directto/original-java/Point4d.java | 116 +++++++++ .../mlp/directto/original-java/Read.java | 44 ++++ .../mlp/directto/original-java/ReadWrite.java | 81 ++++++ .../mlp/directto/original-java/Route.java | 107 ++++++++ .../mlp/directto/original-java/Static.java | 52 ++++ .../mlp/directto/original-java/Track.java | 30 +++ .../directto/original-java/Trajectory.java | 77 ++++++ .../original-java/TrajectorySynthesizer.java | 244 ++++++++++++++++++ .../directto/original-java/TrialFlight.java | 159 ++++++++++++ .../mlp/directto/original-java/Velocity.java | 49 ++++ .../mlp/directto/original-java/Write.java | 27 ++ .../mlp/directto/original-java/dynamic.txt | 5 + .../mlp/directto/original-java/files.txt | 31 +++ .../mlp/directto/original-java/input.txt | 69 +++++ .../mlp/directto/original-java/input3.txt | 57 ++++ .../mlp/directto/original-java/input4.txt | 69 +++++ 59 files changed, 4024 insertions(+) create mode 100755 Robust/src/Benchmarks/mlp/directto/mlp-java/Aircraft.java create mode 100755 Robust/src/Benchmarks/mlp/directto/mlp-java/AircraftList.java create mode 100755 Robust/src/Benchmarks/mlp/directto/mlp-java/Algorithm.java create mode 100755 Robust/src/Benchmarks/mlp/directto/mlp-java/Conflict.java create mode 100755 Robust/src/Benchmarks/mlp/directto/mlp-java/ConflictList.java create mode 100755 Robust/src/Benchmarks/mlp/directto/mlp-java/D2.java create mode 100755 Robust/src/Benchmarks/mlp/directto/mlp-java/Fix.java create mode 100755 Robust/src/Benchmarks/mlp/directto/mlp-java/FixList.java create mode 100755 Robust/src/Benchmarks/mlp/directto/mlp-java/Flight.java create mode 100755 Robust/src/Benchmarks/mlp/directto/mlp-java/FlightList.java create mode 100755 Robust/src/Benchmarks/mlp/directto/mlp-java/FlightPlan.java create mode 100755 Robust/src/Benchmarks/mlp/directto/mlp-java/Message.java create mode 100755 Robust/src/Benchmarks/mlp/directto/mlp-java/MessageList.java create mode 100755 Robust/src/Benchmarks/mlp/directto/mlp-java/Point2d.java create mode 100755 Robust/src/Benchmarks/mlp/directto/mlp-java/Point4d.java create mode 100755 Robust/src/Benchmarks/mlp/directto/mlp-java/ReadWrite.java create mode 100755 Robust/src/Benchmarks/mlp/directto/mlp-java/Route.java create mode 100755 Robust/src/Benchmarks/mlp/directto/mlp-java/Static.java create mode 100755 Robust/src/Benchmarks/mlp/directto/mlp-java/Track.java create mode 100755 Robust/src/Benchmarks/mlp/directto/mlp-java/Trajectory.java create mode 100755 Robust/src/Benchmarks/mlp/directto/mlp-java/TrajectorySynthesizer.java create mode 100755 Robust/src/Benchmarks/mlp/directto/mlp-java/TrialFlight.java create mode 100755 Robust/src/Benchmarks/mlp/directto/mlp-java/Velocity.java create mode 100755 Robust/src/Benchmarks/mlp/directto/mlp-java/dynamic.txt create mode 100755 Robust/src/Benchmarks/mlp/directto/mlp-java/files.txt create mode 100755 Robust/src/Benchmarks/mlp/directto/mlp-java/input.txt create mode 100755 Robust/src/Benchmarks/mlp/directto/mlp-java/input3.txt create mode 100755 Robust/src/Benchmarks/mlp/directto/mlp-java/input4.txt create mode 100644 Robust/src/Benchmarks/mlp/directto/mlp-java/makefile create mode 100755 Robust/src/Benchmarks/mlp/directto/original-java/Aircraft.java create mode 100755 Robust/src/Benchmarks/mlp/directto/original-java/AircraftList.java create mode 100755 Robust/src/Benchmarks/mlp/directto/original-java/Algorithm.java create mode 100755 Robust/src/Benchmarks/mlp/directto/original-java/Conflict.java create mode 100755 Robust/src/Benchmarks/mlp/directto/original-java/ConflictList.java create mode 100755 Robust/src/Benchmarks/mlp/directto/original-java/D2.java create mode 100755 Robust/src/Benchmarks/mlp/directto/original-java/Fix.java create mode 100755 Robust/src/Benchmarks/mlp/directto/original-java/FixList.java create mode 100755 Robust/src/Benchmarks/mlp/directto/original-java/Flight.java create mode 100755 Robust/src/Benchmarks/mlp/directto/original-java/FlightList.java create mode 100755 Robust/src/Benchmarks/mlp/directto/original-java/FlightPlan.java create mode 100755 Robust/src/Benchmarks/mlp/directto/original-java/Message.java create mode 100755 Robust/src/Benchmarks/mlp/directto/original-java/MessageList.java create mode 100755 Robust/src/Benchmarks/mlp/directto/original-java/Point2d.java create mode 100755 Robust/src/Benchmarks/mlp/directto/original-java/Point4d.java create mode 100755 Robust/src/Benchmarks/mlp/directto/original-java/Read.java create mode 100755 Robust/src/Benchmarks/mlp/directto/original-java/ReadWrite.java create mode 100755 Robust/src/Benchmarks/mlp/directto/original-java/Route.java create mode 100755 Robust/src/Benchmarks/mlp/directto/original-java/Static.java create mode 100755 Robust/src/Benchmarks/mlp/directto/original-java/Track.java create mode 100755 Robust/src/Benchmarks/mlp/directto/original-java/Trajectory.java create mode 100755 Robust/src/Benchmarks/mlp/directto/original-java/TrajectorySynthesizer.java create mode 100755 Robust/src/Benchmarks/mlp/directto/original-java/TrialFlight.java create mode 100755 Robust/src/Benchmarks/mlp/directto/original-java/Velocity.java create mode 100755 Robust/src/Benchmarks/mlp/directto/original-java/Write.java create mode 100755 Robust/src/Benchmarks/mlp/directto/original-java/dynamic.txt create mode 100755 Robust/src/Benchmarks/mlp/directto/original-java/files.txt create mode 100755 Robust/src/Benchmarks/mlp/directto/original-java/input.txt create mode 100755 Robust/src/Benchmarks/mlp/directto/original-java/input3.txt create mode 100755 Robust/src/Benchmarks/mlp/directto/original-java/input4.txt diff --git a/Robust/src/Benchmarks/mlp/directto/mlp-java/Aircraft.java b/Robust/src/Benchmarks/mlp/directto/mlp-java/Aircraft.java new file mode 100755 index 00000000..66d15695 --- /dev/null +++ b/Robust/src/Benchmarks/mlp/directto/mlp-java/Aircraft.java @@ -0,0 +1,20 @@ +// class that implements types of aircrafts + +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-java/AircraftList.java b/Robust/src/Benchmarks/mlp/directto/mlp-java/AircraftList.java new file mode 100755 index 00000000..2a48ca8c --- /dev/null +++ b/Robust/src/Benchmarks/mlp/directto/mlp-java/AircraftList.java @@ -0,0 +1,60 @@ +// This class memorizes all the existing aircrafts + +//import java.util.*; + +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); + } + + 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); + } + + 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-java/Algorithm.java b/Robust/src/Benchmarks/mlp/directto/mlp-java/Algorithm.java new file mode 100755 index 00000000..e61d949e --- /dev/null +++ b/Robust/src/Benchmarks/mlp/directto/mlp-java/Algorithm.java @@ -0,0 +1,109 @@ +//import java.util.*; +//import java.io.*; + +class Algorithm { + private D2 d2; + + public /*static*/ double initialTime,time; + public /*static*/ double currIteration; + public /*static*/ ConflictList cList; + + public Algorithm( D2 d2 ) { + this.d2 = d2; + ConflictList cList=new ConflictList(); + } + + public /*static*/ void setInitialTime(double time) { + initialTime=time; + currIteration=0; + } + + public /*static*/ boolean isConflict(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(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-1) && (pos-1) && (i-1); + } + + public String toString() { + return new String("No. Fixes:"+noFixes+": "+fixes); + } +} diff --git a/Robust/src/Benchmarks/mlp/directto/mlp-java/Static.java b/Robust/src/Benchmarks/mlp/directto/mlp-java/Static.java new file mode 100755 index 00000000..e1f38eac --- /dev/null +++ b/Robust/src/Benchmarks/mlp/directto/mlp-java/Static.java @@ -0,0 +1,48 @@ + +// This class memorizes the static data (besides fixes) + + +//import java.util.*; + +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-java/Track.java b/Robust/src/Benchmarks/mlp/directto/mlp-java/Track.java new file mode 100755 index 00000000..04f9c16f --- /dev/null +++ b/Robust/src/Benchmarks/mlp/directto/mlp-java/Track.java @@ -0,0 +1,23 @@ +// the data about a plane - current position and velocity + +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-java/Trajectory.java b/Robust/src/Benchmarks/mlp/directto/mlp-java/Trajectory.java new file mode 100755 index 00000000..968e1ad5 --- /dev/null +++ b/Robust/src/Benchmarks/mlp/directto/mlp-java/Trajectory.java @@ -0,0 +1,60 @@ +// class that implements the trajectory and some methods of access + +//import java.util.*; + +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 ; i0)? 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=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=(speednSpeed)? -thrust:0; + return accel; + } + + private /*static*/ Point2d decompose (double scalar, + Point2d p1, Point2d p2) { + double angle; + if (p1.x==p2.x) { + angle=(p1.yhorizTotalDist)&&(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(); + (nextFixPoint2d.horizDistance(current, + flight.fPlan.r.getCoordsOf(nextFix))); + nextFix++) { + distance-=Point2d.horizDistance(current, + flight.fPlan.r.getCoordsOf(nextFix)); + current=flight.fPlan.r.getCoordsOf(nextFix); + } + + if (nextFixfixIndex2) { + aux=fixIndex1; + fixIndex1=fixIndex2; + fixIndex2=aux; + } + trialFlight=Flight.copyOf(d2, oldFlight); + trialFlight.trialStatus=Flight.trialFlightStatus(); + this.changeToTrialRoute(fixIndex1, fixIndex2); + } + + // constructor for a trial flight using the current position of a plane + public TrialFlight(D2 d2, Flight flight, String fixName) { + this.d2=d2; + oldFlight=flight; + } + + // constructor that uses an estimated position and a fix + public TrialFlight(D2 d2, Flight flight, Point4d position, Fix fix) { + this.d2=d2; + int aux; + oldFlight=flight; + fixIndex=oldFlight.fPlan.r.getIndexOf(fix); + trialFlight=Flight.copyOf(d2, oldFlight); + trialFlight.trialStatus=Flight.trialFlightStatus(); + oldFlight.updateTrajectory(position.time); + // assuming that the position given as parameter is the same as the first point in the trajectory + trialFlight.track=new Track(new Point4d(position), new Velocity(oldFlight.track.vel)); + trialFlight.fPlan=new FlightPlan(oldFlight.fPlan); + changeToTrialRoute(position, fixIndex); + trajectoryDiff(position.time); + conflictsDiff(position.time); + System.out.println("old route:"+oldFlight.fPlan.r); + System.out.println("new route:"+trialFlight.fPlan.r); + trialFlight.trialStatus=-1; + } + + public void trajectoryDiff (double time) { + trialFlight.updateTrajectory(time); + oldFlight.updateTrajectory(time); + System.out.println("Flight "+trialFlight.flightID+":"); + distDiff=oldFlight.traject.distanceToDestination()- + trialFlight.traject.distanceToDestination(); + timeDiff=oldFlight.traject.timeToDestination(time)- + trialFlight.traject.timeToDestination(time); + if (timeDiff<0) { timeDiff=0; } + System.out.println("Time difference: "+timeDiff); + System.out.println("Distance difference: "+distDiff); + } + + public void conflictsDiff(double time) { + int i, j; + oldConflicts=d2.getAlgorithm().getConflictsWith(time,oldFlight); + newConflicts=d2.getAlgorithm().getConflictsWith(time,trialFlight); + System.out.println("Flight "+trialFlight.flightID+":"); + System.out.println("Conflicts for the old flight:"); + System.out.println(oldConflicts); + System.out.println("Conflicts for the trial flight:"); + System.out.println(newConflicts); + noNew=0; + for (i=0 ; i-1) { + trialRoute=new Route(d2, oldFlight.fPlan.r.noFixes-index); + trialRoute.current=0; + for (i=index; i-1) && (index2>-1) && (index2-index1>1)) { + trialRoute=new Route(d2, oldFlight.fPlan.r.noFixes- + (index2-index1-1)); + trialRoute.current=index1+1; + for (i=0 ; i<=index1 ; i++) { + trialRoute.addFix(i, oldFlight.fPlan.r.getFixAt(i)); + if (oldFlight.fPlan.r.current==i) { + trialRoute.current=i; + } + } + + for (i=index2; i-1) && (pos-1) && (i-1); + } + + public String toString() + { + return new String("No. Fixes:"+noFixes+": "+fixes); + } + +} + + + diff --git a/Robust/src/Benchmarks/mlp/directto/original-java/Static.java b/Robust/src/Benchmarks/mlp/directto/original-java/Static.java new file mode 100755 index 00000000..8dc7432b --- /dev/null +++ b/Robust/src/Benchmarks/mlp/directto/original-java/Static.java @@ -0,0 +1,52 @@ + +// This class memorizes the static data (besides fixes) + + +import java.util.*; + +class Static +{ + public static double width, height; // the dimensions of the given area + public static double iterationStep, noIterations; + public static double radius, distance; + + 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()); + } + + public static void printInfo() + // this is a test procedure + { + 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/original-java/Track.java b/Robust/src/Benchmarks/mlp/directto/original-java/Track.java new file mode 100755 index 00000000..3d4c7748 --- /dev/null +++ b/Robust/src/Benchmarks/mlp/directto/original-java/Track.java @@ -0,0 +1,30 @@ +// the data about a plane - current position and velocity + +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/original-java/Trajectory.java b/Robust/src/Benchmarks/mlp/directto/original-java/Trajectory.java new file mode 100755 index 00000000..04ee80b5 --- /dev/null +++ b/Robust/src/Benchmarks/mlp/directto/original-java/Trajectory.java @@ -0,0 +1,77 @@ +// class that implements the trajectory and some methods of access + +import java.util.*; + +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; + ArrayList p; // the points in the trajectory + + public Trajectory(int np) + { + noPoints=np; + p=new ArrayList(noPoints); + current=0; + } + + public void setPoint (int pos, Point4d point) + // adds a point to the trajectory at the position "pos" + { + p.add(pos, (Point4d) point); + } + + public void setNoPoints (int noP) + { + noPoints=noP; + } + + public Point4d getCurrent () + { + return (Point4d) p.get(current); + } + + public Point4d getPointAt (int index) + { + return (Point4d) p.get(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 ; i0)? traject.getPointAt(i-1).time+timeF:time+timeF; + // System.out.println(currentVelocity+" "+traject.startVelocity); + } + flight.traject=traject; + System.out.println("Finished updating trajectory ..."); + return traject; + } + + private static void setInitialParameters(Flight flight) + /* + initialization & initial computation part + */ + { + // System.out.println("Initial parameters ..."); + int i; + Point2d p1, p2; + // Double temp=new Double(Static.noIterations); + // iterations=temp.intValue(); + 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=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; // to be completed + } + + private static double neededAcceleration(double speed, double nSpeed, + double thrust) + { + double accel=(speednSpeed)? -thrust:0; + return accel; + } + + private static Point2d decompose (double scalar, + Point2d p1, Point2d p2) + { + double angle; + if (p1.x==p2.x) { + angle=(p1.yhorizTotalDist)&&(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(); + (nextFixPoint2d.horizDistance(current, + flight.fPlan.r.getCoordsOf(nextFix))); + nextFix++) { + distance-=Point2d.horizDistance(current, + flight.fPlan.r.getCoordsOf(nextFix)); + current=flight.fPlan.r.getCoordsOf(nextFix); + } + // System.out.println("speed= "+speed+ " distance: "+distance+" fix: "+ + // flight.fPlan.r.getCoordsOf(nextFix)+ + // " current: "+current); + if (nextFixfixIndex2) { + aux=fixIndex1; + fixIndex1=fixIndex2; + fixIndex2=aux; + } + trialFlight=Flight.copyOf(oldFlight); + trialFlight.trialStatus=Flight.trialFlightStatus; + this.changeToTrialRoute(fixIndex1, fixIndex2); + } + + public TrialFlight(Flight flight, String fixName) + // constructor for a trial flight using the current position of a plane + { + oldFlight=flight; + + } + + public TrialFlight(Flight flight, Point4d position, Fix fix) + // constructor that uses an estimated position and a fix + { + int aux; + oldFlight=flight; + // fixIndex1=oldFlight.fPlan.r.getIndexOf(fixName1); + fixIndex=oldFlight.fPlan.r.getIndexOf(fix); + + // System.out.println(oldFlight); + trialFlight=Flight.copyOf(oldFlight); + + trialFlight.trialStatus=Flight.trialFlightStatus; + + oldFlight.updateTrajectory(position.time); + trialFlight.track=new Track(new Point4d(position), new Velocity(oldFlight.track.vel)); // assuming that the position given as parameter is the same as the first point in the trajectory + // trialFlight.track.vel=oldFlight.traject.getVelocity(); + trialFlight.fPlan=new FlightPlan(oldFlight.fPlan); + + // System.out.println("old route:"+oldFlight.fPlan.r); + // System.out.println("new route:"+trialFlight.fPlan.r); + + + + changeToTrialRoute(position, fixIndex); + + + // System.out.println("old route:"+oldFlight.fPlan.r); + // System.out.println("new route:"+trialFlight.fPlan.r); + + + + trajectoryDiff(position.time); + conflictsDiff(position.time); + System.out.println("old route:"+oldFlight.fPlan.r); + System.out.println("new route:"+trialFlight.fPlan.r); + // System.out.println("old: "+oldFlight.trialStatus); + trialFlight.trialStatus=-1; + // System.out.println("old: "+oldFlight.trialStatus); + } + + public void trajectoryDiff (double time) + { + trialFlight.updateTrajectory(time); + oldFlight.updateTrajectory(time); + + + System.out.println("Flight "+trialFlight.flightID+":"); + distDiff=oldFlight.traject.distanceToDestination()- + trialFlight.traject.distanceToDestination(); + timeDiff=oldFlight.traject.timeToDestination(time)- + trialFlight.traject.timeToDestination(time); + if (timeDiff<0) { timeDiff=0; } + System.out.println("Time difference: "+timeDiff); + System.out.println("Distance difference: "+distDiff); + } + + public void conflictsDiff(double time) + { + int i, j; + oldConflicts=Algorithm.getConflictsWith(time,oldFlight); + newConflicts=Algorithm.getConflictsWith(time,trialFlight); + System.out.println("Flight "+trialFlight.flightID+":"); + System.out.println("Conflicts for the old flight:"); + System.out.println(oldConflicts); + System.out.println("Conflicts for the trial flight:"); + System.out.println(newConflicts); + noNew=0; + for (i=0 ; i-1) { + trialRoute=new Route(oldFlight.fPlan.r.noFixes-index); + trialRoute.current=0; + for (i=index; i-1) && (index2>-1) && (index2-index1>1)) { + trialRoute=new Route(oldFlight.fPlan.r.noFixes- + (index2-index1-1)); + trialRoute.current=index1+1; + for (i=0 ; i<=index1 ; i++) { + trialRoute.addFix(i, oldFlight.fPlan.r.getFixAt(i)); + if (oldFlight.fPlan.r.current==i) { + trialRoute.current=i; + } + } + + for (i=index2; i