mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
modified activities to deal with multiple cap-dims
This commit is contained in:
parent
c1919649c7
commit
1b3af07e45
18 changed files with 211 additions and 3 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
package jsprit.core.problem.solution.route.activity;
|
package jsprit.core.problem.solution.route.activity;
|
||||||
|
|
||||||
|
import jsprit.core.problem.Capacity;
|
||||||
import jsprit.core.problem.job.Delivery;
|
import jsprit.core.problem.job.Delivery;
|
||||||
|
|
||||||
public final class DeliverService implements DeliveryActivity{
|
public final class DeliverService implements DeliveryActivity{
|
||||||
|
|
@ -85,4 +86,9 @@ public final class DeliverService implements DeliveryActivity{
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[act="+getName()+"][capDemand="+getCapacityDemand()+"][loc="+getLocationId()+"]";
|
return "[act="+getName()+"][capDemand="+getCapacityDemand()+"][loc="+getLocationId()+"]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Capacity getCapacity() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package jsprit.core.problem.solution.route.activity;
|
package jsprit.core.problem.solution.route.activity;
|
||||||
|
|
||||||
|
import jsprit.core.problem.Capacity;
|
||||||
import jsprit.core.problem.job.Job;
|
import jsprit.core.problem.job.Job;
|
||||||
import jsprit.core.problem.job.Shipment;
|
import jsprit.core.problem.job.Shipment;
|
||||||
|
|
||||||
|
|
@ -84,4 +85,9 @@ public final class DeliverShipment implements DeliveryActivity{
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[act="+getName()+"][loc="+getLocationId()+"]";
|
return "[act="+getName()+"][loc="+getLocationId()+"]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Capacity getCapacity() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package jsprit.core.problem.solution.route.activity;
|
package jsprit.core.problem.solution.route.activity;
|
||||||
|
|
||||||
|
import jsprit.core.problem.Capacity;
|
||||||
import jsprit.core.util.Coordinate;
|
import jsprit.core.util.Coordinate;
|
||||||
|
|
||||||
public final class End implements TourActivity {
|
public final class End implements TourActivity {
|
||||||
|
|
@ -147,4 +148,10 @@ public final class End implements TourActivity {
|
||||||
return new End(this);
|
return new End(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Capacity getCapacity() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package jsprit.core.problem.solution.route.activity;
|
package jsprit.core.problem.solution.route.activity;
|
||||||
|
|
||||||
|
import jsprit.core.problem.Capacity;
|
||||||
import jsprit.core.problem.job.Pickup;
|
import jsprit.core.problem.job.Pickup;
|
||||||
import jsprit.core.problem.job.Service;
|
import jsprit.core.problem.job.Service;
|
||||||
|
|
||||||
|
|
@ -91,4 +92,10 @@ public final class PickupService implements PickupActivity{
|
||||||
return "[act="+getName()+"][capDemand="+getCapacityDemand()+"][loc="+getLocationId()+"]";
|
return "[act="+getName()+"][capDemand="+getCapacityDemand()+"][loc="+getLocationId()+"]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Capacity getCapacity() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,15 @@
|
||||||
package jsprit.core.problem.solution.route.activity;
|
package jsprit.core.problem.solution.route.activity;
|
||||||
|
|
||||||
|
import jsprit.core.problem.Capacity;
|
||||||
import jsprit.core.problem.job.Job;
|
import jsprit.core.problem.job.Job;
|
||||||
import jsprit.core.problem.job.Shipment;
|
import jsprit.core.problem.job.Shipment;
|
||||||
|
|
||||||
public final class PickupShipment implements PickupActivity{
|
public final class PickupShipment implements PickupActivity{
|
||||||
|
|
||||||
private Shipment shipment;
|
private Shipment shipment;
|
||||||
|
|
||||||
private double endTime;
|
private double endTime;
|
||||||
|
|
||||||
private double arrTime;
|
private double arrTime;
|
||||||
|
|
||||||
public PickupShipment(Shipment shipment) {
|
public PickupShipment(Shipment shipment) {
|
||||||
|
|
@ -85,4 +88,11 @@ public final class PickupShipment implements PickupActivity{
|
||||||
return "[act="+getName()+"][loc="+getLocationId()+"]";
|
return "[act="+getName()+"][loc="+getLocationId()+"]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Capacity getCapacity() {
|
||||||
|
return shipment.getCapacity();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package jsprit.core.problem.solution.route.activity;
|
package jsprit.core.problem.solution.route.activity;
|
||||||
|
|
||||||
|
import jsprit.core.problem.Capacity;
|
||||||
import jsprit.core.problem.job.Service;
|
import jsprit.core.problem.job.Service;
|
||||||
import jsprit.core.problem.solution.route.activity.TourActivity.JobActivity;
|
import jsprit.core.problem.solution.route.activity.TourActivity.JobActivity;
|
||||||
|
|
||||||
|
|
@ -167,6 +168,12 @@ public class ServiceActivity implements JobActivity{
|
||||||
return new ServiceActivity(this);
|
return new ServiceActivity(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Capacity getCapacity() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package jsprit.core.problem.solution.route.activity;
|
package jsprit.core.problem.solution.route.activity;
|
||||||
|
|
||||||
|
import jsprit.core.problem.Capacity;
|
||||||
import jsprit.core.util.Coordinate;
|
import jsprit.core.util.Coordinate;
|
||||||
|
|
||||||
public final class Start implements TourActivity {
|
public final class Start implements TourActivity {
|
||||||
|
|
@ -153,6 +154,12 @@ public final class Start implements TourActivity {
|
||||||
return new Start(this);
|
return new Start(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Capacity getCapacity() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,37 +16,130 @@
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package jsprit.core.problem.solution.route.activity;
|
package jsprit.core.problem.solution.route.activity;
|
||||||
|
|
||||||
|
import jsprit.core.problem.Capacity;
|
||||||
import jsprit.core.problem.job.Job;
|
import jsprit.core.problem.job.Job;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Basic interface for tour-activities.
|
||||||
|
*
|
||||||
|
* <p>A tour activity is the basic element of a tour, which is consequently a sequence of tour-activities.
|
||||||
|
*
|
||||||
|
* @author schroeder
|
||||||
|
*
|
||||||
|
*/
|
||||||
public interface TourActivity {
|
public interface TourActivity {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Basic interface of job-activies.
|
||||||
|
*
|
||||||
|
* <p>A job activity is related to a {@link Job}.
|
||||||
|
*
|
||||||
|
* @author schroeder
|
||||||
|
*
|
||||||
|
*/
|
||||||
public interface JobActivity extends TourActivity {
|
public interface JobActivity extends TourActivity {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the job that is involved with this activity.
|
||||||
|
*
|
||||||
|
* @return job
|
||||||
|
*/
|
||||||
public Job getJob();
|
public Job getJob();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the capacity-demand of that activity, in terms of what needs to be loaded or unloaded at
|
||||||
|
* this activity.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
* @deprecated use <code>getCapacity()</code> instead
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public int getCapacityDemand();
|
public int getCapacityDemand();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the name of this activity.
|
||||||
|
*
|
||||||
|
* @return name
|
||||||
|
*/
|
||||||
public abstract String getName();
|
public abstract String getName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the activity's locationId.
|
||||||
|
*
|
||||||
|
* @return locationId
|
||||||
|
*/
|
||||||
public abstract String getLocationId();
|
public abstract String getLocationId();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the theoretical earliest operation start time, which is the time that is just allowed
|
||||||
|
* (not earlier) to start this activity, that is for example <code>service.getTimeWindow().getStart()</code>.
|
||||||
|
*
|
||||||
|
* @return earliest start time
|
||||||
|
*/
|
||||||
public abstract double getTheoreticalEarliestOperationStartTime();
|
public abstract double getTheoreticalEarliestOperationStartTime();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the theoretical latest operation start time, which is the time that is just allowed
|
||||||
|
* (not later) to start this activity, that is for example <code>service.getTimeWindow().getEnd()</code>.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return latest start time
|
||||||
|
*/
|
||||||
public abstract double getTheoreticalLatestOperationStartTime();
|
public abstract double getTheoreticalLatestOperationStartTime();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the operation-time this activity takes.
|
||||||
|
*
|
||||||
|
* <p>Note that this is not necessarily the duration of this activity, but the
|
||||||
|
* service time a pickup/delivery actually takes, that is for example <code>service.getServiceTime()</code>.
|
||||||
|
*
|
||||||
|
* @return operation time
|
||||||
|
*/
|
||||||
public abstract double getOperationTime();
|
public abstract double getOperationTime();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the arrival-time of this activity.
|
||||||
|
*
|
||||||
|
* @return arrival time
|
||||||
|
*/
|
||||||
public abstract double getArrTime();
|
public abstract double getArrTime();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns end-time of this activity.
|
||||||
|
*
|
||||||
|
* @return end time
|
||||||
|
*/
|
||||||
public abstract double getEndTime();
|
public abstract double getEndTime();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the arrival time of that activity.
|
||||||
|
*
|
||||||
|
* @param arrTime
|
||||||
|
*/
|
||||||
public abstract void setArrTime(double arrTime);
|
public abstract void setArrTime(double arrTime);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the end-time of this activity.
|
||||||
|
*
|
||||||
|
* @param endTime
|
||||||
|
*/
|
||||||
public abstract void setEndTime(double endTime);
|
public abstract void setEndTime(double endTime);
|
||||||
|
|
||||||
public TourActivity duplicate();
|
/**
|
||||||
|
* Returns the capacity-demand of that activity, in terms of what needs to be loaded or unloaded at
|
||||||
|
* this activity.
|
||||||
|
*
|
||||||
|
* @return capacity
|
||||||
|
*/
|
||||||
|
public abstract Capacity getCapacity();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Makes a deep copy of this activity.
|
||||||
|
*
|
||||||
|
* @return copied activity
|
||||||
|
*/
|
||||||
|
public abstract TourActivity duplicate();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
package jsprit.core.problem.solution.route.activity;
|
||||||
|
|
||||||
|
public class DefaultShipmentActivityFactoryTest {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
package jsprit.core.problem.solution.route.activity;
|
||||||
|
|
||||||
|
public class DefaultTourActivityTest {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
package jsprit.core.problem.solution.route.activity;
|
||||||
|
|
||||||
|
public class DeliverServiceTest {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
package jsprit.core.problem.solution.route.activity;
|
||||||
|
|
||||||
|
public class DeliverShipmentTest {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
package jsprit.core.problem.solution.route.activity;
|
||||||
|
|
||||||
|
public class EndTest {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
package jsprit.core.problem.solution.route.activity;
|
||||||
|
|
||||||
|
public class PickupServiceTest {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
package jsprit.core.problem.solution.route.activity;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
import jsprit.core.problem.job.Shipment;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class PickupShipmentTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenGettingCapacity_itShouldReturnItCorrectly(){
|
||||||
|
Shipment shipment = Shipment.Builder.newInstance("s").setPickupLocation("pickLoc").setDeliveryLocation("delLoc")
|
||||||
|
.addCapacityDimension(0, 10).addCapacityDimension(1, 100).build();
|
||||||
|
PickupShipment pick = new PickupShipment(shipment);
|
||||||
|
assertEquals(10,pick.getCapacity().get(0));
|
||||||
|
assertEquals(100,pick.getCapacity().get(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenCopyingAct_itShouldCopyItCorrectly(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -24,7 +24,7 @@ import jsprit.core.problem.solution.route.activity.ServiceActivity;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
|
||||||
public class ServiceActTest {
|
public class ServiceActivityTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenTwoDeliveriesHaveTheSameUnderlyingJob_theyAreEqual(){
|
public void whenTwoDeliveriesHaveTheSameUnderlyingJob_theyAreEqual(){
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
package jsprit.core.problem.solution.route.activity;
|
||||||
|
|
||||||
|
public class StartTest {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
package jsprit.core.problem.solution.route.activity;
|
||||||
|
|
||||||
|
public class TimeWindowTest {
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue