Compare commits
	
		
			2 Commits
		
	
	
		
			optimizati
			...
			master
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| e3e7bf5ccd | |||
| b386665e66 | 
							
								
								
									
										14
									
								
								package.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										14
									
								
								package.sh
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,14 @@ | |||||||
|  | #!/bin/bash | ||||||
|  | 
 | ||||||
|  | GIT=$(command -v git) | ||||||
|  | HEAD=$(command -v head) | ||||||
|  | CUT=$(command -v cut) | ||||||
|  | 
 | ||||||
|  | JAR_ARTIFACT="out/artifacts/Hajj_simulation_jar/Hajj-simulation.jar" | ||||||
|  | 
 | ||||||
|  | if [ -z $"GIT" ] || [ -z $"HEAD" ] || [ -z $"CUT" ]; then | ||||||
|  | 	echo "Tools missing" | ||||||
|  | 	exit 1 | ||||||
|  | else | ||||||
|  | 	tar -cvf Hajj-Simulation-$(git log | head -n1 | cut -d' ' -f2).tar.gz $JAR_ARTIFACT run.sh | ||||||
|  | fi | ||||||
							
								
								
									
										9
									
								
								run.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										9
									
								
								run.sh
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,9 @@ | |||||||
|  | #!/bin/bash | ||||||
|  | 
 | ||||||
|  | jav=$(command -v java) | ||||||
|  | 
 | ||||||
|  | if [ -z "$jav" ]; then | ||||||
|  | 	>&2 echo "Can't find java installation" | ||||||
|  | else | ||||||
|  | 	java -jar out/artifacts/Hajj_simulation_jar/Hajj-simulation.jar | ||||||
|  | fi | ||||||
							
								
								
									
										10
									
								
								src/Bus.java
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								src/Bus.java
									
									
									
									
									
								
							| @ -1,11 +1,11 @@ | |||||||
| 
 | 
 | ||||||
| public class Bus extends CivilVehicle { | public class Bus extends CivilVehicle { | ||||||
| 	 | 	 | ||||||
| 	private int UID; | 	private String UID; | ||||||
| 	private Campaign campaign; | 	private Campaign campaign; | ||||||
| 	private static int numeberOfBuses; | 	private static int numeberOfBuses; | ||||||
|     private final short TIME_TO_FIX = 20; //in minutes |     private final int TIME_TO_FIX = 20; //in minutes | ||||||
|     public static final short MAX_FORWARD = 900; //Meter/Min |     public static final int MAX_FORWARD = 900; //Meter/Min | ||||||
| 
 | 
 | ||||||
|     public static final double STD_BUS_SIZE = 10; |     public static final double STD_BUS_SIZE = 10; | ||||||
| 
 | 
 | ||||||
| @ -40,11 +40,11 @@ public class Bus extends CivilVehicle { | |||||||
| 
 | 
 | ||||||
|     private void generateUID() { |     private void generateUID() { | ||||||
|         numeberOfBuses++; |         numeberOfBuses++; | ||||||
|         this.UID = numeberOfBuses; |         this.UID = String.format("BUS%04d", numeberOfBuses); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public String getUID(){ |     public String getUID(){ | ||||||
|         return String.format("BUS%04d", UID); |         return this.UID; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public Campaign getCampaign() { |     public Campaign getCampaign() { | ||||||
|  | |||||||
| @ -467,6 +467,7 @@ public class GUI_History { | |||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	public String avgTimeOfTrip() { | 	public String avgTimeOfTrip() { | ||||||
|  | 		//TODO: does output diff value even after all have arrived. | ||||||
| 		Calendar now = new GregorianCalendar(); | 		Calendar now = new GregorianCalendar(); | ||||||
| 		now.setTime(currenttimeManager); | 		now.setTime(currenttimeManager); | ||||||
| 		Calendar from = (GregorianCalendar)now.clone(); | 		Calendar from = (GregorianCalendar)now.clone(); | ||||||
|  | |||||||
| @ -251,7 +251,7 @@ public class GUI_ViewStreet { | |||||||
| 		if (vehicles.isEmpty()) return; | 		if (vehicles.isEmpty()) return; | ||||||
| 		vehicleData = new Object[vehicles.size()][6]; | 		vehicleData = new Object[vehicles.size()][6]; | ||||||
| 		for (int i = 0; i < vehicles.size(); i++) { | 		for (int i = 0; i < vehicles.size(); i++) { | ||||||
| 			vehicleData[i][0] = vehicles.get(i).getUID(); | 			vehicleData[i][0] = vehicles.get(i).getUID();// TODO: There is an Exception error here; | ||||||
| 			if (vehicles.get(i) instanceof Bus) | 			if (vehicles.get(i) instanceof Bus) | ||||||
| 				vehicleData[i][1] = ((Bus)vehicles.get(i)).getCampaign().getHotelDistrict().name(); | 				vehicleData[i][1] = ((Bus)vehicles.get(i)).getCampaign().getHotelDistrict().name(); | ||||||
| 			else vehicleData[i][1] = "Local Vehicle"; | 			else vehicleData[i][1] = "Local Vehicle"; | ||||||
|  | |||||||
| @ -56,6 +56,7 @@ public class MakkahCity { | |||||||
| 
 | 
 | ||||||
| 	public static void main(String[] args) { | 	public static void main(String[] args) { | ||||||
| 
 | 
 | ||||||
|  | 		//TODO: fix state errors | ||||||
| 		t.start(); | 		t.start(); | ||||||
| 		//Gen Camp | 		//Gen Camp | ||||||
| 		campPerDistrict[District.ALMANSOOR.ordinal()] = new ArrayList<>(); | 		campPerDistrict[District.ALMANSOOR.ordinal()] = new ArrayList<>(); | ||||||
| @ -438,7 +439,7 @@ public class MakkahCity { | |||||||
| 			clearDoneCivilVehicles(); | 			clearDoneCivilVehicles(); | ||||||
| 			addCivilVehicleNoise(); | 			addCivilVehicleNoise(); | ||||||
| 			for (Vehicle vehicle : listOfVehicles) { | 			for (Vehicle vehicle : listOfVehicles) { | ||||||
| 				if (vehicle.getRoute() == null || vehicle.isArrivedToDest()) | 				if (vehicle.getRoute() == null) | ||||||
| 					continue; | 					continue; | ||||||
| 				Route route = vehicle.getRoute(); | 				Route route = vehicle.getRoute(); | ||||||
| 				double currentLocation = vehicle.getCurrentLocation(); | 				double currentLocation = vehicle.getCurrentLocation(); | ||||||
| @ -457,7 +458,10 @@ public class MakkahCity { | |||||||
| 					if (!vehicle.isArrivedToDest()) { | 					if (!vehicle.isArrivedToDest()) { | ||||||
| 						double factor = 1-(vehicle.getCurrentStreet().capcityPoint(vehicle.getCurrentLocation(), | 						double factor = 1-(vehicle.getCurrentStreet().capcityPoint(vehicle.getCurrentLocation(), | ||||||
| 										vehicle.getCurrentLocation()+1000,vehicle)) ; | 										vehicle.getCurrentLocation()+1000,vehicle)) ; | ||||||
| 						vehicle.move(vehicle.getMaxSpeed()*factor); | 						if (vehicle instanceof Bus) vehicle.move(Bus.MAX_FORWARD * factor ); | ||||||
|  | 						else if (vehicle instanceof Sedan) vehicle.move(Sedan.MAX_FORWARD * factor ); | ||||||
|  | 						else if (vehicle instanceof SUV) vehicle.move(SUV.MAX_FORWARD * factor ); | ||||||
|  | 						else if (vehicle instanceof Truck) vehicle.move(Bus.MAX_FORWARD * factor ); | ||||||
| 					} | 					} | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
| @ -499,7 +503,7 @@ public class MakkahCity { | |||||||
| 			clearDoneCivilVehicles(); | 			clearDoneCivilVehicles(); | ||||||
| 			addCivilVehicleNoise(); | 			addCivilVehicleNoise(); | ||||||
| 			for (Vehicle vehicle : listOfVehicles) { | 			for (Vehicle vehicle : listOfVehicles) { | ||||||
| 				if (vehicle.getRoute() == null || vehicle.isArrivedToDest()) | 				if (vehicle.getRoute() == null) | ||||||
| 					continue; | 					continue; | ||||||
| 				Route route = vehicle.getRoute(); | 				Route route = vehicle.getRoute(); | ||||||
| 				double currentLocation = vehicle.getCurrentLocation(); | 				double currentLocation = vehicle.getCurrentLocation(); | ||||||
| @ -517,7 +521,10 @@ public class MakkahCity { | |||||||
| 					if (!vehicle.isArrivedToDest()) { | 					if (!vehicle.isArrivedToDest()) { | ||||||
| 						double factor = 1-(vehicle.getCurrentStreet().capcityPoint(vehicle.getCurrentLocation(), | 						double factor = 1-(vehicle.getCurrentStreet().capcityPoint(vehicle.getCurrentLocation(), | ||||||
| 								vehicle.getCurrentLocation()+1000,vehicle)) ; | 								vehicle.getCurrentLocation()+1000,vehicle)) ; | ||||||
| 						vehicle.move(vehicle.getMaxSpeed()* factor); | 						if (vehicle instanceof Bus) vehicle.move(Bus.MAX_FORWARD * factor ); | ||||||
|  | 						else if (vehicle instanceof Sedan) vehicle.move(Sedan.MAX_FORWARD * factor ); | ||||||
|  | 						else if (vehicle instanceof SUV) vehicle.move(SUV.MAX_FORWARD * factor ); | ||||||
|  | 						else if (vehicle instanceof Truck) vehicle.move(Bus.MAX_FORWARD * factor ); | ||||||
| 					} | 					} | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
| @ -585,7 +592,7 @@ public class MakkahCity { | |||||||
| 						stdStreet[i].getPercentRemainingCapacity()); | 						stdStreet[i].getPercentRemainingCapacity()); | ||||||
| 			} | 			} | ||||||
| 			String input = in.next(); | 			String input = in.next(); | ||||||
| 			int index = Integer.parseInt(input); | 			int index = Integer.parseInt(input);//TODO: unhandled ex | ||||||
| 			showStreet(stdStreet[index]); | 			showStreet(stdStreet[index]); | ||||||
| 		} | 		} | ||||||
| 		if (choice.equals("4")){ | 		if (choice.equals("4")){ | ||||||
| @ -904,7 +911,7 @@ public class MakkahCity { | |||||||
| 			if (street.getName() == StreetNames.IBRAHIM_ALKHALIL2) numOfSedan = (int) (numOfSedan * 1.2); | 			if (street.getName() == StreetNames.IBRAHIM_ALKHALIL2) numOfSedan = (int) (numOfSedan * 1.2); | ||||||
| 			for (int x = 0; x < numOfSedan; x++) { | 			for (int x = 0; x < numOfSedan; x++) { | ||||||
| 				Sedan car = new Sedan(getRandom(4, 5)); | 				Sedan car = new Sedan(getRandom(4, 5)); | ||||||
| 				double pointOfEntry = getRandom(0, street.getLength()); | 				double pointOfEntry = getRandom(0, street.getLength());//TODO: consider getLength - x | ||||||
| 				if (street.capcityPoint(pointOfEntry, pointOfEntry+1500) < 1){ | 				if (street.capcityPoint(pointOfEntry, pointOfEntry+1500) < 1){ | ||||||
| 					listOfVehicles.add(car); | 					listOfVehicles.add(car); | ||||||
| 					car.setCurrentLocation(pointOfEntry); | 					car.setCurrentLocation(pointOfEntry); | ||||||
| @ -917,7 +924,7 @@ public class MakkahCity { | |||||||
| 			if (street.getName() == StreetNames.FOURTH_HIGHWAY1) numOfTruck = (int) (numOfTruck * 0.5); | 			if (street.getName() == StreetNames.FOURTH_HIGHWAY1) numOfTruck = (int) (numOfTruck * 0.5); | ||||||
| 			if (street.getName() == StreetNames.FOURTH_HIGHWAY2) numOfTruck = (int) (numOfTruck * 0.5); | 			if (street.getName() == StreetNames.FOURTH_HIGHWAY2) numOfTruck = (int) (numOfTruck * 0.5); | ||||||
| 			if (street.getName() == StreetNames.STREET3) numOfTruck = (int) (numOfTruck * 1.5); | 			if (street.getName() == StreetNames.STREET3) numOfTruck = (int) (numOfTruck * 1.5); | ||||||
| 			if (street.getName() == StreetNames.IBRAHIM_ALKHALIL2) numOfTruck = (int) (numOfTruck * 1.2); | 			if (street.getName() == StreetNames.IBRAHIM_ALKHALIL2) numOfSedan = (int) (numOfSedan * 1.2); | ||||||
| 			for (int x = 0; x < numOfTruck; x++) { | 			for (int x = 0; x < numOfTruck; x++) { | ||||||
| 				Truck car = new Truck(getRandom(4, 5)); | 				Truck car = new Truck(getRandom(4, 5)); | ||||||
| 				double pointOfEntry = getRandom(0, street.getLength()); | 				double pointOfEntry = getRandom(0, street.getLength()); | ||||||
| @ -932,7 +939,7 @@ public class MakkahCity { | |||||||
| 			if (street.getName() == StreetNames.FOURTH_HIGHWAY1) numOfSUV = (int) (numOfSUV * 0.5); | 			if (street.getName() == StreetNames.FOURTH_HIGHWAY1) numOfSUV = (int) (numOfSUV * 0.5); | ||||||
| 			if (street.getName() == StreetNames.FOURTH_HIGHWAY2) numOfSUV = (int) (numOfSUV * 0.5); | 			if (street.getName() == StreetNames.FOURTH_HIGHWAY2) numOfSUV = (int) (numOfSUV * 0.5); | ||||||
| 			if (street.getName() == StreetNames.STREET3) numOfSUV = (int) (numOfSUV * 1.5); | 			if (street.getName() == StreetNames.STREET3) numOfSUV = (int) (numOfSUV * 1.5); | ||||||
| 			if (street.getName() == StreetNames.IBRAHIM_ALKHALIL2) numOfSUV = (int) (numOfSUV * 1.2); | 			if (street.getName() == StreetNames.IBRAHIM_ALKHALIL2) numOfSUV = (int) (numOfSedan * 1.2); | ||||||
| 			for (int x = 0; x < numOfSUV; x++) { | 			for (int x = 0; x < numOfSUV; x++) { | ||||||
| 				SUV car = new SUV(getRandom(4, 5)); | 				SUV car = new SUV(getRandom(4, 5)); | ||||||
| 				double pointOfEntry = getRandom(0, street.getLength()); | 				double pointOfEntry = getRandom(0, street.getLength()); | ||||||
| @ -943,6 +950,7 @@ public class MakkahCity { | |||||||
| 					car.setCurrentStreet(street); | 					car.setCurrentStreet(street); | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
|  | 
 | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| @ -950,6 +958,12 @@ public class MakkahCity { | |||||||
| 		return currenttimeManager; | 		return currenttimeManager; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	/** | ||||||
|  | 	 * Find shortest path without respect to traffic | ||||||
|  | 	 * @param campaign | ||||||
|  | 	 * @return | ||||||
|  | 	 */ | ||||||
|  | 	 | ||||||
| 	private static Route getBestRoute(Campaign campaign , Mashier mashier) { | 	private static Route getBestRoute(Campaign campaign , Mashier mashier) { | ||||||
| 		//ArrayList<Route> routes = (ArrayList<Route>) Arrays.asList(getRoutesToDistrict(campaign.getHotelDistrict())); | 		//ArrayList<Route> routes = (ArrayList<Route>) Arrays.asList(getRoutesToDistrict(campaign.getHotelDistrict())); | ||||||
| 		Route[] routes = getRoutesToDistrict(campaign.getHotelDistrict()); | 		Route[] routes = getRoutesToDistrict(campaign.getHotelDistrict()); | ||||||
| @ -985,11 +999,6 @@ public class MakkahCity { | |||||||
| 		return sortingRoute; | 		return sortingRoute; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	/** |  | ||||||
| 	 * Find shortest path without respect to traffic |  | ||||||
| 	 * @param campaign |  | ||||||
| 	 * @return |  | ||||||
| 	 */ |  | ||||||
| 	public static Route getShortestRoute(Campaign campaign, Mashier mashier) { | 	public static Route getShortestRoute(Campaign campaign, Mashier mashier) { | ||||||
| 		Route[] routes = getRoutesToDistrict(campaign.getHotelDistrict()); | 		Route[] routes = getRoutesToDistrict(campaign.getHotelDistrict()); | ||||||
| 		Route route = null; | 		Route route = null; | ||||||
|  | |||||||
							
								
								
									
										13
									
								
								src/SUV.java
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								src/SUV.java
									
									
									
									
									
								
							| @ -1,9 +1,9 @@ | |||||||
| 
 | 
 | ||||||
| public class SUV extends CivilVehicle { | public class SUV extends CivilVehicle { | ||||||
| 	private short UID; | 	private String UID; | ||||||
| 	private static short numeberOfSUV; | 	private static int numeberOfSUV; | ||||||
|     private final short TIME_TO_FIX = 15; //in minutes |     private final int TIME_TO_FIX = 15; //in minutes | ||||||
|     public static final short MAX_FORWARD = 1300; |     public static final int MAX_FORWARD = 1300; | ||||||
| 
 | 
 | ||||||
|     public SUV(double vehicleSize){ |     public SUV(double vehicleSize){ | ||||||
|         super(vehicleSize); |         super(vehicleSize); | ||||||
| @ -21,11 +21,12 @@ public class SUV extends CivilVehicle { | |||||||
|      |      | ||||||
|     private void generateUID() { |     private void generateUID() { | ||||||
|     	numeberOfSUV++; |     	numeberOfSUV++; | ||||||
|     	this.UID = numeberOfSUV; |     	this.UID = String.format("SUV%04d", numeberOfSUV); | ||||||
|  |     	 | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     public String getUID(){ |     public String getUID(){ | ||||||
|         return String.format("SUV%04d", UID); |         return this.UID; | ||||||
|     } |     } | ||||||
|      |      | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,10 +1,10 @@ | |||||||
| 
 | 
 | ||||||
| public class Sedan extends CivilVehicle { | public class Sedan extends CivilVehicle { | ||||||
| 
 | 
 | ||||||
| 	private short UID; | 	private String UID; | ||||||
| 	private static short numeberOfSedan; | 	private static int numeberOfSedan; | ||||||
|     private final short TIME_TO_FIX = 15; //in minutes |     private final int TIME_TO_FIX = 15; //in minutes | ||||||
|     public static final short MAX_FORWARD = 1500; // Meter/Min |     public static final int MAX_FORWARD = 1500; // Meter/Min | ||||||
| 
 | 
 | ||||||
|     public Sedan(double vehicleSize){ |     public Sedan(double vehicleSize){ | ||||||
|         super(vehicleSize); |         super(vehicleSize); | ||||||
| @ -16,11 +16,12 @@ public class Sedan extends CivilVehicle { | |||||||
|      |      | ||||||
|     private void generateUID() { |     private void generateUID() { | ||||||
|     	numeberOfSedan++; |     	numeberOfSedan++; | ||||||
|     	this.UID = numeberOfSedan; |     	this.UID = String.format("Sedan%04d", numeberOfSedan); | ||||||
|  |     	 | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     public String getUID(){ |     public String getUID(){ | ||||||
|         return String.format("Sedan%04d", UID); |         return this.UID; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Override |     @Override | ||||||
|  | |||||||
| @ -1,8 +1,8 @@ | |||||||
| 
 | 
 | ||||||
| public class Truck extends CivilVehicle { | public class Truck extends CivilVehicle { | ||||||
| 	private short UID; | 	private String UID; | ||||||
| 	private static short numeberOfTruck; | 	private static int numeberOfTruck; | ||||||
|     private final short TIME_TO_FIX = 20; //in minutes |     private final int TIME_TO_FIX = 20; //in minutes | ||||||
| 
 | 
 | ||||||
|     @Override |     @Override | ||||||
|     public int getMaxSpeed() { |     public int getMaxSpeed() { | ||||||
| @ -19,13 +19,12 @@ public class Truck extends CivilVehicle { | |||||||
|     } |     } | ||||||
|     private void generateUID() { |     private void generateUID() { | ||||||
|     	numeberOfTruck++; |     	numeberOfTruck++; | ||||||
|     	this.UID = numeberOfTruck; |     	this.UID = String.format("Truck%04d", numeberOfTruck); | ||||||
|     } |     } | ||||||
|     		   |     		   | ||||||
|     	    public String getUID(){ |     	    public String getUID(){ | ||||||
|         return String.format("Truck%04d", UID); |     	        return this.UID; | ||||||
|     	    } |     	    } | ||||||
| 
 |  | ||||||
|     	} |     	} | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user