From 4f42d1568a8a2bcd5ae54673e202217d26dcbeb0 Mon Sep 17 00:00:00 2001 From: jjenista Date: Mon, 9 Mar 2009 18:10:52 +0000 Subject: [PATCH] Pass around pointer to D2 as an argument to everything, rather than stash the pointer in almost every class in the benchmark. Also explicitly rewrote non-void methods with no return statement to have them --- .../mlp/directto/mlp-java/AircraftList.java | 2 + .../mlp/directto/mlp-java/Algorithm.java | 25 ++-- .../Benchmarks/mlp/directto/mlp-java/D2.java | 20 +-- .../mlp/directto/mlp-java/FixList.java | 2 + .../mlp/directto/mlp-java/Flight.java | 13 +- .../mlp/directto/mlp-java/FlightList.java | 26 ++-- .../mlp/directto/mlp-java/Message.java | 16 +-- .../mlp/directto/mlp-java/MessageList.java | 12 +- .../mlp/directto/mlp-java/ReadWrite.java | 9 +- .../mlp/directto/mlp-java/Route.java | 9 +- .../mlp-java/TrajectorySynthesizer.java | 11 +- .../mlp/directto/mlp-java/TrialFlight.java | 127 ------------------ .../Benchmarks/mlp/directto/mlp-java/makefile | 4 +- 13 files changed, 65 insertions(+), 211 deletions(-) delete mode 100755 Robust/src/Benchmarks/mlp/directto/mlp-java/TrialFlight.java diff --git a/Robust/src/Benchmarks/mlp/directto/mlp-java/AircraftList.java b/Robust/src/Benchmarks/mlp/directto/mlp-java/AircraftList.java index 3326ec95..90e5a742 100755 --- a/Robust/src/Benchmarks/mlp/directto/mlp-java/AircraftList.java +++ b/Robust/src/Benchmarks/mlp/directto/mlp-java/AircraftList.java @@ -25,6 +25,7 @@ public class AircraftList { System.out.println("Aircraft not found - "+name); System.exit(-1); + return null; } public int getAircraftIndex(String name) { @@ -36,6 +37,7 @@ public class AircraftList { System.out.println("Aircraft not found - "+name); System.exit(-1); + return 0; } public void printInfo() { diff --git a/Robust/src/Benchmarks/mlp/directto/mlp-java/Algorithm.java b/Robust/src/Benchmarks/mlp/directto/mlp-java/Algorithm.java index a969ad76..32e712b5 100755 --- a/Robust/src/Benchmarks/mlp/directto/mlp-java/Algorithm.java +++ b/Robust/src/Benchmarks/mlp/directto/mlp-java/Algorithm.java @@ -2,14 +2,11 @@ //import java.io.*; public class Algorithm { - private D2 d2; - public double initialTime,time; public double currIteration; public ConflictList cList; - public Algorithm( D2 d2 ) { - this.d2 = d2; + public Algorithm() { cList=new ConflictList(); } @@ -18,7 +15,7 @@ public class Algorithm { currIteration=0; } - public /*static*/ boolean isConflict(Point4d p1, Point4d p2) { + 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) <= @@ -31,7 +28,7 @@ public class Algorithm { return false; } - public /*static*/ Point4d findConflict(Flight a, Flight b) { + 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; @@ -43,7 +40,7 @@ public class Algorithm { while ( (posfixIndex2) { - 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