Archived
0

use long for time

This commit is contained in:
iMoHax
2015-08-18 13:03:46 +03:00
parent 5faba0aff6
commit b47c0d4464
4 changed files with 16 additions and 16 deletions

View File

@@ -14,7 +14,7 @@ public class Route implements Comparable<Route> {
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<Route> {
return refills;
}
public double getTime() {
public long getTime() {
return time;
}
@@ -133,7 +133,7 @@ public class Route implements Comparable<Route> {
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++) {

View File

@@ -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;
}

View File

@@ -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) {

View File

@@ -354,7 +354,7 @@ public class VendorsGraph extends ConnectibleGraph<Vendor> {
private TransitPath path;
private List<Order> orders;
private Double profitByTonne;
private Double time;
private Long time;
protected VendorsEdge(Vertex<Vendor> source, Vertex<Vendor> target, TransitPath path) {
super(source, target);
@@ -407,7 +407,7 @@ public class VendorsGraph extends ConnectibleGraph<Vendor> {
return profitByTonne;
}
public double getTime() {
public long getTime() {
if (time == null){
time = computeTime();
}
@@ -427,7 +427,7 @@ public class VendorsGraph extends ConnectibleGraph<Vendor> {
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){