diff --git a/core/src/main/java/ru/trader/analysis/Route.java b/core/src/main/java/ru/trader/analysis/Route.java index bedbfee..8dc704d 100644 --- a/core/src/main/java/ru/trader/analysis/Route.java +++ b/core/src/main/java/ru/trader/analysis/Route.java @@ -14,7 +14,7 @@ public class Route implements Comparable { private double balance = 0; private double distance = 0; private double fuel = 0; - private double time = 0; + private long time = 0; private int lands = 0; private int refills = 0; @@ -64,7 +64,7 @@ public class Route implements Comparable { return refills; } - public double getTime() { + public long getTime() { return time; } @@ -133,7 +133,7 @@ public class Route implements Comparable { void updateStats(){ LOG.trace("Update stats, old: profit={}, distance={}, lands={}, fuel={}, refills={}, time={}", profit, distance, lands, fuel, refills, time); - profit = 0; distance = 0; lands = 0; fuel = 0; refills = 0; + profit = 0; distance = 0; lands = 0; fuel = 0; refills = 0; time = 0; if (entries.isEmpty()) return; RouteEntry entry = entries.get(0); for (int i = 1; i < entries.size(); i++) { diff --git a/core/src/main/java/ru/trader/analysis/RouteEntry.java b/core/src/main/java/ru/trader/analysis/RouteEntry.java index 38eb994..36f0db8 100644 --- a/core/src/main/java/ru/trader/analysis/RouteEntry.java +++ b/core/src/main/java/ru/trader/analysis/RouteEntry.java @@ -14,8 +14,8 @@ public class RouteEntry { private boolean land; private double refill; private double profit; - private double time; - private double fulltime; + private long time; + private long fulltime; public RouteEntry(Vendor vendor, double refill, double fuel, double profit) { orders = new ArrayList<>(); @@ -57,19 +57,19 @@ public class RouteEntry { this.profit = profit; } - public double getTime() { + public long getTime() { return time; } - void setTime(double time) { + void setTime(long time) { this.time = time; } - public double getFullTime() { + public long getFullTime() { return fulltime; } - void setFullTime(double fullTime) { + void setFullTime(long fullTime) { this.fulltime = fullTime; } diff --git a/core/src/main/java/ru/trader/analysis/Scorer.java b/core/src/main/java/ru/trader/analysis/Scorer.java index a50cc17..e7b4a12 100644 --- a/core/src/main/java/ru/trader/analysis/Scorer.java +++ b/core/src/main/java/ru/trader/analysis/Scorer.java @@ -111,7 +111,7 @@ public class Scorer { return profit; } - public double getTime(RouteEntry entry, RouteEntry prev) { + public long getTime(RouteEntry entry, RouteEntry prev) { if (prev == null) return 0; int lands = entry.isLand() ? 1 : 0; int jumps = prev.getVendor().getPlace().equals(entry.getVendor().getPlace()) ? 0 : 1; @@ -119,10 +119,10 @@ public class Scorer { if (!prev.isLand()){ time = time - profile.getTakeoffTime() + profile.getRechargeTime(); } - return time; + return Math.round(time); } - public double getTime(double distance, int jumps, int lands){ + public long getTime(double distance, int jumps, int lands){ double time = profile.getTakeoffTime(); if (jumps > 0){ time += profile.getJumpTime() + (jumps-1) * (profile.getRechargeTime() + profile.getJumpTime()); @@ -130,7 +130,7 @@ public class Scorer { if (profile.getLandingTime() > 0 & lands > 0){ time += (lands-1)*(getTime(avgDistance) + profile.getLandingTime() + profile.getTakeoffTime()) + getTime(distance) + profile.getLandingTime(); } - return time; + return Math.round(time); } public double getScore(RouteEntry entry, RouteEntry prev) { diff --git a/core/src/main/java/ru/trader/analysis/VendorsGraph.java b/core/src/main/java/ru/trader/analysis/VendorsGraph.java index 74e3dfd..738f17a 100644 --- a/core/src/main/java/ru/trader/analysis/VendorsGraph.java +++ b/core/src/main/java/ru/trader/analysis/VendorsGraph.java @@ -354,7 +354,7 @@ public class VendorsGraph extends ConnectibleGraph { private TransitPath path; private List orders; private Double profitByTonne; - private Double time; + private Long time; protected VendorsEdge(Vertex source, Vertex target, TransitPath path) { super(source, target); @@ -407,7 +407,7 @@ public class VendorsGraph extends ConnectibleGraph { return profitByTonne; } - public double getTime() { + public long getTime() { if (time == null){ time = computeTime(); } @@ -427,7 +427,7 @@ public class VendorsGraph extends ConnectibleGraph { return scorer.getProfitByTonne(getProfit(), getFuelCost()); } - protected double computeTime(){ + protected long computeTime(){ int jumps = source.getEntry().getPlace().equals(target.getEntry().getPlace())? 0 : 1; int lands = 1; if (path != null){