Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change: use double to fix total cost #86

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@
* @author F.I.D.O.
*/
public interface PlanCostProvider {
public int calculatePlanCost(int planDiscomfort, int planDuration);
public double calculatePlanCost(int planDiscomfort, int planDuration);
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public double calculatePlanCost(VGAVehiclePlan plan) {
}

@Override
public int calculatePlanCost(int discomfort, int duration) {
return (int) (weight_parameter * discomfort + (1 - weight_parameter) * duration);
public double calculatePlanCost(int discomfort, int duration) {
return (weight_parameter * discomfort + (1 - weight_parameter) * duration);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -535,9 +535,9 @@ private DriverPlan insertIntoPlan(
}

// cost computation
double newPlanCost = planCostProvider.calculatePlanCost(newPlanDiscomfort, newPlanTravelTime / 1000);
double newPlanCost = planCostProvider.calculatePlanCost(newPlanDiscomfort, newPlanTravelTime);

return new DriverPlan(newPlanTasks, newPlanTravelTime / 1000, newPlanCost);
return new DriverPlan(newPlanTasks, newPlanTravelTime / 1000, newPlanCost / 1000);
}

private String readableTime(long nanoTime) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public Plan<V> computeOptimalVehiclePlanForGroup(V vehicle, LinkedHashSet<PlanCo

// best plan
PlanRequestAction[] bestPlan = null;
int bestPlanCost = Integer.MAX_VALUE;
double bestPlanCost = Integer.MAX_VALUE;
long bestPlanEndTime = 0;

// indexes
Expand Down Expand Up @@ -200,7 +200,7 @@ public Plan<V> computeOptimalVehiclePlanForGroup(V vehicle, LinkedHashSet<PlanCo
//TODO add onboard vehicles previous discomfort

int totalDuration = endTimeTemp - startTime;
int planCost = planCostComputation.calculatePlanCost(totalDiscomfort + discomfort,
double planCost = planCostComputation.calculatePlanCost(totalDiscomfort + discomfort,
totalDuration);

if(planCost < bestPlanCost){
Expand Down