mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
improve logging - #159
This commit is contained in:
parent
56243f924e
commit
a4dd1d9ac5
4 changed files with 66 additions and 28 deletions
|
|
@ -26,6 +26,8 @@ import jsprit.core.problem.job.Job;
|
|||
import jsprit.core.problem.solution.route.VehicleRoute;
|
||||
import jsprit.core.problem.vehicle.Vehicle;
|
||||
import jsprit.core.util.RandomNumberGeneration;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
|
@ -55,6 +57,8 @@ public abstract class AbstractInsertionStrategy implements InsertionStrategy{
|
|||
|
||||
}
|
||||
|
||||
private final static Logger logger = LogManager.getLogger();
|
||||
|
||||
protected Random random = RandomNumberGeneration.getRandom();
|
||||
|
||||
protected final static double NO_NEW_DEPARTURE_TIME_YET = -12345.12345;
|
||||
|
|
@ -106,6 +110,7 @@ public abstract class AbstractInsertionStrategy implements InsertionStrategy{
|
|||
}
|
||||
|
||||
protected void insertJob(Job unassignedJob, InsertionData iData, VehicleRoute inRoute){
|
||||
logger.trace("insert: [jobId=" + unassignedJob.getId() + "]" + iData );
|
||||
inserter.insertJob(unassignedJob, iData, inRoute);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ public class InsertionData {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[iCost="+insertionCost+"][iIndex="+deliveryInsertionIndex+"][depTime="+departureTime+"][vehicle="+selectedVehicle+"][driver="+selectedDriver+"]";
|
||||
return "[iCost="+insertionCost+"][pickupIndex="+pickupInsertionIndex+"][deliveryIndex="+deliveryInsertionIndex+"][depTime="+departureTime+"][vehicle="+selectedVehicle+"][driver="+selectedDriver+"]";
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -24,12 +24,16 @@ import jsprit.core.problem.VehicleRoutingProblem;
|
|||
import jsprit.core.problem.job.Job;
|
||||
import jsprit.core.problem.solution.route.VehicleRoute;
|
||||
import jsprit.core.util.RandomNumberGeneration;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Random;
|
||||
|
||||
public abstract class AbstractRuinStrategy implements RuinStrategy{
|
||||
|
||||
private final static Logger logger = LogManager.getLogger();
|
||||
|
||||
private RuinListeners ruinListeners;
|
||||
|
||||
protected Random random = RandomNumberGeneration.getRandom();
|
||||
|
|
@ -59,6 +63,7 @@ public abstract class AbstractRuinStrategy implements RuinStrategy{
|
|||
public Collection<Job> ruin(Collection<VehicleRoute> vehicleRoutes){
|
||||
ruinListeners.ruinStarts(vehicleRoutes);
|
||||
Collection<Job> unassigned = ruinRoutes(vehicleRoutes);
|
||||
logger.trace("ruin: " + "[ruined=" + unassigned.size() + "]");
|
||||
ruinListeners.ruinEnds(vehicleRoutes,unassigned);
|
||||
return unassigned;
|
||||
}
|
||||
|
|
@ -111,6 +116,7 @@ public abstract class AbstractRuinStrategy implements RuinStrategy{
|
|||
if(jobIsInitial(job)) return false;
|
||||
boolean removed = route.getTourActivities().removeJob(job);
|
||||
if (removed) {
|
||||
logger.trace("ruin: " + job.getId());
|
||||
ruinListeners.removed(job,route);
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,24 +2,9 @@
|
|||
<problem xmlns="http://www.w3schools.com"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3schools.com vrp_xml_schema.xsd">
|
||||
<problemType>
|
||||
<fleetSize>FINITE</fleetSize>
|
||||
<fleetSize>INFINITE</fleetSize>
|
||||
</problemType>
|
||||
<vehicles>
|
||||
<vehicle>
|
||||
<id>v2</id>
|
||||
<typeId>vehType2</typeId>
|
||||
<startLocation>
|
||||
<id>loc</id>
|
||||
</startLocation>
|
||||
<endLocation>
|
||||
<id>loc</id>
|
||||
</endLocation>
|
||||
<timeSchedule>
|
||||
<start>0.0</start>
|
||||
<end>1.7976931348623157E308</end>
|
||||
</timeSchedule>
|
||||
<returnToDepot>true</returnToDepot>
|
||||
</vehicle>
|
||||
<vehicle>
|
||||
<id>v1</id>
|
||||
<typeId>vehType</typeId>
|
||||
|
|
@ -48,16 +33,58 @@
|
|||
<time>0.0</time>
|
||||
</costs>
|
||||
</type>
|
||||
<type>
|
||||
<id>vehType2</id>
|
||||
<capacity-dimensions>
|
||||
<dimension index="0">200</dimension>
|
||||
</capacity-dimensions>
|
||||
<costs>
|
||||
<fixed>0.0</fixed>
|
||||
<distance>1.0</distance>
|
||||
<time>0.0</time>
|
||||
</costs>
|
||||
</type>
|
||||
</vehicleTypes>
|
||||
<services>
|
||||
<service id="1" type="service">
|
||||
<location>
|
||||
<id>loc</id>
|
||||
</location>
|
||||
<capacity-dimensions>
|
||||
<dimension index="0">1</dimension>
|
||||
</capacity-dimensions>
|
||||
<duration>2.0</duration>
|
||||
<timeWindows>
|
||||
<timeWindow>
|
||||
<start>0.0</start>
|
||||
<end>1.7976931348623157E308</end>
|
||||
</timeWindow>
|
||||
</timeWindows>
|
||||
</service>
|
||||
<service id="2" type="service">
|
||||
<location>
|
||||
<id>loc2</id>
|
||||
</location>
|
||||
<capacity-dimensions>
|
||||
<dimension index="0">1</dimension>
|
||||
</capacity-dimensions>
|
||||
<duration>4.0</duration>
|
||||
<timeWindows>
|
||||
<timeWindow>
|
||||
<start>0.0</start>
|
||||
<end>1.7976931348623157E308</end>
|
||||
</timeWindow>
|
||||
</timeWindows>
|
||||
</service>
|
||||
</services>
|
||||
<solutions>
|
||||
<solution>
|
||||
<cost>10.0</cost>
|
||||
<routes>
|
||||
<route>
|
||||
<driverId>noDriver</driverId>
|
||||
<vehicleId>v1</vehicleId>
|
||||
<start>0.0</start>
|
||||
<act type="service">
|
||||
<serviceId>1</serviceId>
|
||||
<arrTime>0.0</arrTime>
|
||||
<endTime>0.0</endTime>
|
||||
</act>
|
||||
<end>0.0</end>
|
||||
</route>
|
||||
</routes>
|
||||
<unassignedJobs>
|
||||
<job id="2"/>
|
||||
</unassignedJobs>
|
||||
</solution>
|
||||
</solutions>
|
||||
</problem>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue