From: jjenista Date: Sun, 22 Mar 2009 19:28:01 +0000 (+0000) Subject: added smaller version of directo for something in between tiny and full tests of... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=8c9832f207d1c483b7b8b69c6ce09af2c6e56504;p=IRC.git added smaller version of directo for something in between tiny and full tests of analysis --- 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 index 00000000..79ce05be --- /dev/null +++ b/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/Aircraft.java @@ -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 index 00000000..90e5a742 --- /dev/null +++ b/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/AircraftList.java @@ -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 index 00000000..32e712b5 --- /dev/null +++ b/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/Algorithm.java @@ -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-1) && (pos-1) && (i-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 index 00000000..ad376244 --- /dev/null +++ b/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/Static.java @@ -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 index 00000000..73b3d8ea --- /dev/null +++ b/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/Track.java @@ -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 index 00000000..a8fd4698 --- /dev/null +++ b/Robust/src/Benchmarks/mlp/directto/mlp-small-for-testing/Trajectory.java @@ -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 ; 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 (nextFix