quick fix to change logic (should be fine if not go back to previus version even if not fully correct)
This commit is contained in:
parent
28a07a76e6
commit
5ebf9d2b2b
@ -6,6 +6,7 @@ import dev.ksan.travelpathoptimizer.graphSimulation.PathResult;
|
||||
import dev.ksan.travelpathoptimizer.model.City;
|
||||
import dev.ksan.travelpathoptimizer.model.Departure;
|
||||
import dev.ksan.travelpathoptimizer.model.Location;
|
||||
import dev.ksan.travelpathoptimizer.model.TransportType;
|
||||
import dev.ksan.travelpathoptimizer.service.CityManager;
|
||||
import dev.ksan.travelpathoptimizer.util.JsonParser;
|
||||
import dev.ksan.travelpathoptimizer.util.TicketPrinter;
|
||||
@ -209,7 +210,7 @@ public class MainController {
|
||||
totalCost,
|
||||
currentTime,
|
||||
departures,
|
||||
categoryBox.getValue().toString());
|
||||
categoryBox.getValue().toString(), TransportType.NOT_ASSIGNED);
|
||||
|
||||
System.out.println(graphSimulation.getTopPaths().size());
|
||||
System.out.println(startCity.getName() + endCity.getName());
|
||||
|
@ -3,6 +3,7 @@ package dev.ksan.travelpathoptimizer.graphSimulation;
|
||||
import dev.ksan.travelpathoptimizer.model.City;
|
||||
import dev.ksan.travelpathoptimizer.model.Departure;
|
||||
import dev.ksan.travelpathoptimizer.model.Location;
|
||||
import dev.ksan.travelpathoptimizer.model.TransportType;
|
||||
import dev.ksan.travelpathoptimizer.service.CityManager;
|
||||
import dev.ksan.travelpathoptimizer.util.JsonParser;
|
||||
import java.time.Duration;
|
||||
@ -104,7 +105,8 @@ public class GraphSimulation {
|
||||
double totalCost,
|
||||
LocalTime currentTime,
|
||||
List<Integer> departures,
|
||||
String type) {
|
||||
String type,
|
||||
TransportType lastType) {
|
||||
|
||||
if (currentCity.getLocation().equals(endCity.getLocation())) {
|
||||
addToTopPaths(
|
||||
@ -130,9 +132,19 @@ public class GraphSimulation {
|
||||
Duration duration = Duration.between(currentTime, arrivalTime);
|
||||
duration = duration.abs();
|
||||
|
||||
|
||||
if (type.equals("time")) {
|
||||
cost += duration.toMinutes();
|
||||
cost += dep.getMinTransferTime();
|
||||
|
||||
if(lastType == TransportType.NOT_ASSIGNED){
|
||||
|
||||
cost += dep.getMinTransferTime();
|
||||
}else if(lastType != dep.getType()){
|
||||
|
||||
cost += dep.getMinTransferTime();
|
||||
}
|
||||
|
||||
//cost += dep.getMinTransferTime();
|
||||
} else if (type.equals("price")) {
|
||||
cost += dep.getPrice();
|
||||
} else if (type.equals("hops")) {
|
||||
@ -147,7 +159,8 @@ public class GraphSimulation {
|
||||
}
|
||||
path.add(nextCity);
|
||||
departures.add(dep.getIdCounter());
|
||||
calculateTopPaths(nextCity, endCity, path, totalCost + cost, arrivalTime, departures, type);
|
||||
|
||||
calculateTopPaths(nextCity, endCity, path, totalCost + cost, arrivalTime, departures, type, dep.getType());
|
||||
|
||||
departures.remove(departures.size() - 1);
|
||||
path.remove(path.size() - 1);
|
||||
|
Loading…
x
Reference in New Issue
Block a user