mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
add editorconfig - #174
This commit is contained in:
parent
b9c7dc3324
commit
25e5c096f2
43 changed files with 625 additions and 645 deletions
|
|
@ -33,14 +33,13 @@ import java.util.concurrent.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Insertion based on regret approach.
|
* Insertion based on regret approach.
|
||||||
*
|
* <p/>
|
||||||
* <p>Basically calculates the insertion cost of the firstBest and the secondBest alternative. The score is then calculated as difference
|
* <p>Basically calculates the insertion cost of the firstBest and the secondBest alternative. The score is then calculated as difference
|
||||||
* between secondBest and firstBest, plus additional scoring variables that can defined in this.ScoringFunction.
|
* between secondBest and firstBest, plus additional scoring variables that can defined in this.ScoringFunction.
|
||||||
* The idea is that if the cost of the secondBest alternative is way higher than the first best, it seems to be important to insert this
|
* The idea is that if the cost of the secondBest alternative is way higher than the first best, it seems to be important to insert this
|
||||||
* customer immediatedly. If difference is not that high, it might not impact solution if this customer is inserted later.
|
* customer immediatedly. If difference is not that high, it might not impact solution if this customer is inserted later.
|
||||||
*
|
*
|
||||||
* @author stefan schroeder
|
* @author stefan schroeder
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class RegretInsertionConcurrent extends AbstractInsertionStrategy {
|
public class RegretInsertionConcurrent extends AbstractInsertionStrategy {
|
||||||
|
|
||||||
|
|
@ -55,7 +54,7 @@ public class RegretInsertionConcurrent extends AbstractInsertionStrategy {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the scoring function.
|
* Sets the scoring function.
|
||||||
*
|
* <p/>
|
||||||
* <p>By default, the this.TimeWindowScorer is used.
|
* <p>By default, the this.TimeWindowScorer is used.
|
||||||
*
|
*
|
||||||
* @param scoringFunction to score
|
* @param scoringFunction to score
|
||||||
|
|
@ -81,11 +80,10 @@ public class RegretInsertionConcurrent extends AbstractInsertionStrategy {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs insertion.
|
* Runs insertion.
|
||||||
*
|
* <p/>
|
||||||
* <p>Before inserting a job, all unassigned jobs are scored according to its best- and secondBest-insertion plus additional scoring variables.
|
* <p>Before inserting a job, all unassigned jobs are scored according to its best- and secondBest-insertion plus additional scoring variables.
|
||||||
*
|
*
|
||||||
* @throws java.lang.RuntimeException if smth went wrong with thread execution
|
* @throws java.lang.RuntimeException if smth went wrong with thread execution
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Collection<Job> insertUnassignedJobs(Collection<VehicleRoute> routes, Collection<Job> unassignedJobs) {
|
public Collection<Job> insertUnassignedJobs(Collection<VehicleRoute> routes, Collection<Job> unassignedJobs) {
|
||||||
|
|
@ -135,16 +133,13 @@ public class RegretInsertionConcurrent extends AbstractInsertionStrategy {
|
||||||
}
|
}
|
||||||
if (bestScoredJob == null) {
|
if (bestScoredJob == null) {
|
||||||
bestScoredJob = sJob;
|
bestScoredJob = sJob;
|
||||||
}
|
} else if (sJob.getScore() > bestScoredJob.getScore()) {
|
||||||
else if(sJob.getScore() > bestScoredJob.getScore()){
|
|
||||||
bestScoredJob = sJob;
|
bestScoredJob = sJob;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} catch (InterruptedException e) {
|
||||||
catch(InterruptedException e){
|
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
}
|
} catch (ExecutionException e) {
|
||||||
catch (ExecutionException e) {
|
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -152,9 +147,4 @@ public class RegretInsertionConcurrent extends AbstractInsertionStrategy {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,6 @@ import java.util.*;
|
||||||
* customer are removed randomly from current solution.
|
* customer are removed randomly from current solution.
|
||||||
*
|
*
|
||||||
* @author stefan schroeder
|
* @author stefan schroeder
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public final class RuinClusters extends AbstractRuinStrategy implements IterationStartsListener {
|
public final class RuinClusters extends AbstractRuinStrategy implements IterationStartsListener {
|
||||||
|
|
@ -96,7 +95,7 @@ public final class RuinClusters extends AbstractRuinStrategy implements Iteratio
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a fraction of jobs from vehicleRoutes.
|
* Removes a fraction of jobs from vehicleRoutes.
|
||||||
*
|
* <p/>
|
||||||
* <p>The number of jobs is calculated as follows: Math.ceil(vrp.getJobs().values().size() * fractionOfAllNodes2beRuined).
|
* <p>The number of jobs is calculated as follows: Math.ceil(vrp.getJobs().values().size() * fractionOfAllNodes2beRuined).
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -130,8 +129,7 @@ public final class RuinClusters extends AbstractRuinStrategy implements Iteratio
|
||||||
if (lastRemoved.isEmpty()) {
|
if (lastRemoved.isEmpty()) {
|
||||||
target = RandomUtils.nextJob(vrp.getJobs().values(), random);
|
target = RandomUtils.nextJob(vrp.getJobs().values(), random);
|
||||||
targetRoute = mappedRoutes.get(target);
|
targetRoute = mappedRoutes.get(target);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
target = RandomUtils.nextJob(lastRemoved, random);
|
target = RandomUtils.nextJob(lastRemoved, random);
|
||||||
Iterator<Job> neighborIterator = jobNeighborhoods.getNearestNeighborsIterator(nOfJobs2BeRemoved, target);
|
Iterator<Job> neighborIterator = jobNeighborhoods.getNearestNeighborsIterator(nOfJobs2BeRemoved, target);
|
||||||
while (neighborIterator.hasNext()) {
|
while (neighborIterator.hasNext()) {
|
||||||
|
|
|
||||||
|
|
@ -25,12 +25,10 @@ import jsprit.core.problem.solution.route.state.RouteAndActivityStateGetter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ensures load constraint for inserting ServiceActivity.
|
* Ensures load constraint for inserting ServiceActivity.
|
||||||
*
|
* <p/>
|
||||||
* <p>When using this, you need to use<br>
|
* <p>When using this, you need to use<br>
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @author schroeder
|
* @author schroeder
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class ServiceLoadActivityLevelConstraint implements HardActivityConstraint {
|
public class ServiceLoadActivityLevelConstraint implements HardActivityConstraint {
|
||||||
|
|
||||||
|
|
@ -53,8 +51,7 @@ public class ServiceLoadActivityLevelConstraint implements HardActivityConstrain
|
||||||
if (futureMaxLoad == null) futureMaxLoad = defaultValue;
|
if (futureMaxLoad == null) futureMaxLoad = defaultValue;
|
||||||
prevMaxLoad = stateManager.getRouteState(iFacts.getRoute(), InternalStates.LOAD_AT_BEGINNING, Capacity.class);
|
prevMaxLoad = stateManager.getRouteState(iFacts.getRoute(), InternalStates.LOAD_AT_BEGINNING, Capacity.class);
|
||||||
if (prevMaxLoad == null) prevMaxLoad = defaultValue;
|
if (prevMaxLoad == null) prevMaxLoad = defaultValue;
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
futureMaxLoad = stateManager.getActivityState(prevAct, InternalStates.FUTURE_MAXLOAD, Capacity.class);
|
futureMaxLoad = stateManager.getActivityState(prevAct, InternalStates.FUTURE_MAXLOAD, Capacity.class);
|
||||||
if (futureMaxLoad == null) futureMaxLoad = defaultValue;
|
if (futureMaxLoad == null) futureMaxLoad = defaultValue;
|
||||||
prevMaxLoad = stateManager.getActivityState(prevAct, InternalStates.PAST_MAXLOAD, Capacity.class);
|
prevMaxLoad = stateManager.getActivityState(prevAct, InternalStates.PAST_MAXLOAD, Capacity.class);
|
||||||
|
|
|
||||||
|
|
@ -18,13 +18,6 @@
|
||||||
package jsprit.core.algorithm;
|
package jsprit.core.algorithm;
|
||||||
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertFalse;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import jsprit.core.algorithm.box.GreedySchrimpfFactory;
|
import jsprit.core.algorithm.box.GreedySchrimpfFactory;
|
||||||
import jsprit.core.algorithm.box.Jsprit;
|
import jsprit.core.algorithm.box.Jsprit;
|
||||||
import jsprit.core.algorithm.box.Jsprit.Builder;
|
import jsprit.core.algorithm.box.Jsprit.Builder;
|
||||||
|
|
@ -53,9 +46,13 @@ import jsprit.core.problem.vehicle.VehicleTypeImpl;
|
||||||
import jsprit.core.reporting.SolutionPrinter;
|
import jsprit.core.reporting.SolutionPrinter;
|
||||||
import jsprit.core.util.Coordinate;
|
import jsprit.core.util.Coordinate;
|
||||||
import jsprit.core.util.Solutions;
|
import jsprit.core.util.Solutions;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
public class InitialRoutesTest {
|
public class InitialRoutesTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<problem xmlns="http://www.w3schools.com"
|
<problem xmlns="http://www.w3schools.com"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3schools.com vrp_xml_schema.xsd">
|
||||||
xsi:schemaLocation="http://www.w3schools.com vrp_xml_schema.xsd">
|
|
||||||
<problemType>
|
<problemType>
|
||||||
<fleetSize>FINITE</fleetSize>
|
<fleetSize>FINITE</fleetSize>
|
||||||
</problemType>
|
</problemType>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<problem xmlns="http://www.w3schools.com"
|
<problem xmlns="http://www.w3schools.com"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3schools.com vrp_xml_schema.xsd">
|
||||||
xsi:schemaLocation="http://www.w3schools.com vrp_xml_schema.xsd">
|
|
||||||
<problemType>
|
<problemType>
|
||||||
<fleetSize>INFINITE</fleetSize>
|
<fleetSize>INFINITE</fleetSize>
|
||||||
</problemType>
|
</problemType>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue