use long for time
This commit is contained in:
@@ -14,7 +14,7 @@ public class Route implements Comparable<Route> {
|
|||||||
private double balance = 0;
|
private double balance = 0;
|
||||||
private double distance = 0;
|
private double distance = 0;
|
||||||
private double fuel = 0;
|
private double fuel = 0;
|
||||||
private double time = 0;
|
private long time = 0;
|
||||||
private int lands = 0;
|
private int lands = 0;
|
||||||
private int refills = 0;
|
private int refills = 0;
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ public class Route implements Comparable<Route> {
|
|||||||
return refills;
|
return refills;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getTime() {
|
public long getTime() {
|
||||||
return time;
|
return time;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,7 +133,7 @@ public class Route implements Comparable<Route> {
|
|||||||
|
|
||||||
void updateStats(){
|
void updateStats(){
|
||||||
LOG.trace("Update stats, old: profit={}, distance={}, lands={}, fuel={}, refills={}, time={}", profit, distance, lands, fuel, refills, time);
|
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;
|
if (entries.isEmpty()) return;
|
||||||
RouteEntry entry = entries.get(0);
|
RouteEntry entry = entries.get(0);
|
||||||
for (int i = 1; i < entries.size(); i++) {
|
for (int i = 1; i < entries.size(); i++) {
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ public class RouteEntry {
|
|||||||
private boolean land;
|
private boolean land;
|
||||||
private double refill;
|
private double refill;
|
||||||
private double profit;
|
private double profit;
|
||||||
private double time;
|
private long time;
|
||||||
private double fulltime;
|
private long fulltime;
|
||||||
|
|
||||||
public RouteEntry(Vendor vendor, double refill, double fuel, double profit) {
|
public RouteEntry(Vendor vendor, double refill, double fuel, double profit) {
|
||||||
orders = new ArrayList<>();
|
orders = new ArrayList<>();
|
||||||
@@ -57,19 +57,19 @@ public class RouteEntry {
|
|||||||
this.profit = profit;
|
this.profit = profit;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getTime() {
|
public long getTime() {
|
||||||
return time;
|
return time;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setTime(double time) {
|
void setTime(long time) {
|
||||||
this.time = time;
|
this.time = time;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getFullTime() {
|
public long getFullTime() {
|
||||||
return fulltime;
|
return fulltime;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setFullTime(double fullTime) {
|
void setFullTime(long fullTime) {
|
||||||
this.fulltime = fullTime;
|
this.fulltime = fullTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ public class Scorer {
|
|||||||
return profit;
|
return profit;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getTime(RouteEntry entry, RouteEntry prev) {
|
public long getTime(RouteEntry entry, RouteEntry prev) {
|
||||||
if (prev == null) return 0;
|
if (prev == null) return 0;
|
||||||
int lands = entry.isLand() ? 1 : 0;
|
int lands = entry.isLand() ? 1 : 0;
|
||||||
int jumps = prev.getVendor().getPlace().equals(entry.getVendor().getPlace()) ? 0 : 1;
|
int jumps = prev.getVendor().getPlace().equals(entry.getVendor().getPlace()) ? 0 : 1;
|
||||||
@@ -119,10 +119,10 @@ public class Scorer {
|
|||||||
if (!prev.isLand()){
|
if (!prev.isLand()){
|
||||||
time = time - profile.getTakeoffTime() + profile.getRechargeTime();
|
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();
|
double time = profile.getTakeoffTime();
|
||||||
if (jumps > 0){
|
if (jumps > 0){
|
||||||
time += profile.getJumpTime() + (jumps-1) * (profile.getRechargeTime() + profile.getJumpTime());
|
time += profile.getJumpTime() + (jumps-1) * (profile.getRechargeTime() + profile.getJumpTime());
|
||||||
@@ -130,7 +130,7 @@ public class Scorer {
|
|||||||
if (profile.getLandingTime() > 0 & lands > 0){
|
if (profile.getLandingTime() > 0 & lands > 0){
|
||||||
time += (lands-1)*(getTime(avgDistance) + profile.getLandingTime() + profile.getTakeoffTime()) + getTime(distance) + profile.getLandingTime();
|
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) {
|
public double getScore(RouteEntry entry, RouteEntry prev) {
|
||||||
|
|||||||
@@ -354,7 +354,7 @@ public class VendorsGraph extends ConnectibleGraph<Vendor> {
|
|||||||
private TransitPath path;
|
private TransitPath path;
|
||||||
private List<Order> orders;
|
private List<Order> orders;
|
||||||
private Double profitByTonne;
|
private Double profitByTonne;
|
||||||
private Double time;
|
private Long time;
|
||||||
|
|
||||||
protected VendorsEdge(Vertex<Vendor> source, Vertex<Vendor> target, TransitPath path) {
|
protected VendorsEdge(Vertex<Vendor> source, Vertex<Vendor> target, TransitPath path) {
|
||||||
super(source, target);
|
super(source, target);
|
||||||
@@ -407,7 +407,7 @@ public class VendorsGraph extends ConnectibleGraph<Vendor> {
|
|||||||
return profitByTonne;
|
return profitByTonne;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getTime() {
|
public long getTime() {
|
||||||
if (time == null){
|
if (time == null){
|
||||||
time = computeTime();
|
time = computeTime();
|
||||||
}
|
}
|
||||||
@@ -427,7 +427,7 @@ public class VendorsGraph extends ConnectibleGraph<Vendor> {
|
|||||||
return scorer.getProfitByTonne(getProfit(), getFuelCost());
|
return scorer.getProfitByTonne(getProfit(), getFuelCost());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected double computeTime(){
|
protected long computeTime(){
|
||||||
int jumps = source.getEntry().getPlace().equals(target.getEntry().getPlace())? 0 : 1;
|
int jumps = source.getEntry().getPlace().equals(target.getEntry().getPlace())? 0 : 1;
|
||||||
int lands = 1;
|
int lands = 1;
|
||||||
if (path != null){
|
if (path != null){
|
||||||
|
|||||||
Reference in New Issue
Block a user