mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
set min ratio - related to #271
This commit is contained in:
parent
040f5d5c76
commit
2212f53b73
1 changed files with 6 additions and 6 deletions
|
|
@ -29,9 +29,11 @@ import java.util.Collection;
|
||||||
|
|
||||||
final class ConfigureFixCostCalculator implements InsertionStartsListener, JobInsertedListener {
|
final class ConfigureFixCostCalculator implements InsertionStartsListener, JobInsertedListener {
|
||||||
|
|
||||||
VehicleRoutingProblem vrp;
|
private final VehicleRoutingProblem vrp;
|
||||||
|
|
||||||
JobInsertionConsideringFixCostsCalculator calcConsideringFix;
|
private final JobInsertionConsideringFixCostsCalculator calcConsideringFix;
|
||||||
|
|
||||||
|
private final double minRatio = 0.5;
|
||||||
|
|
||||||
private int nuOfJobsToRecreate;
|
private int nuOfJobsToRecreate;
|
||||||
|
|
||||||
|
|
@ -50,15 +52,13 @@ final class ConfigureFixCostCalculator implements InsertionStartsListener, JobIn
|
||||||
public void informInsertionStarts(Collection<VehicleRoute> routes, Collection<Job> unassignedJobs) {
|
public void informInsertionStarts(Collection<VehicleRoute> routes, Collection<Job> unassignedJobs) {
|
||||||
this.nuOfJobsToRecreate = unassignedJobs.size();
|
this.nuOfJobsToRecreate = unassignedJobs.size();
|
||||||
double completenessRatio = (1 - ((double) nuOfJobsToRecreate / (double) vrp.getJobs().values().size()));
|
double completenessRatio = (1 - ((double) nuOfJobsToRecreate / (double) vrp.getJobs().values().size()));
|
||||||
calcConsideringFix.setSolutionCompletenessRatio(completenessRatio);
|
calcConsideringFix.setSolutionCompletenessRatio(Math.max(minRatio,completenessRatio));
|
||||||
// log.debug("initialise completenessRatio to " + completenessRatio);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void informJobInserted(Job job2insert, VehicleRoute inRoute, double additionalCosts, double additionalTime) {
|
public void informJobInserted(Job job2insert, VehicleRoute inRoute, double additionalCosts, double additionalTime) {
|
||||||
nuOfJobsToRecreate--;
|
nuOfJobsToRecreate--;
|
||||||
double completenessRatio = (1 - ((double) nuOfJobsToRecreate / (double) vrp.getJobs().values().size()));
|
double completenessRatio = (1 - ((double) nuOfJobsToRecreate / (double) vrp.getJobs().values().size()));
|
||||||
calcConsideringFix.setSolutionCompletenessRatio(completenessRatio);
|
calcConsideringFix.setSolutionCompletenessRatio(Math.max(minRatio,completenessRatio));
|
||||||
// log.debug("set completenessRatio to " + completenessRatio);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue