();
+
+ private ActivityContext pickupContext;
/**
+ * Returns the existing route where the .getJob() needs to be inserted in.
+ *
* @return the route
*/
public VehicleRoute getRoute() {
@@ -37,6 +88,8 @@ public class JobInsertionContext {
}
/**
+ * Returns the job that needs to be inserted.
+ *
* @return the job
*/
public Job getJob() {
@@ -44,6 +97,8 @@ public class JobInsertionContext {
}
/**
+ * Returns the vehicle that should operate the new route, i.e. route this.getRoute() + new job this.getJob().
+ *
* @return the newVehicle
*/
public Vehicle getNewVehicle() {
@@ -51,6 +106,10 @@ public class JobInsertionContext {
}
/**
+ * Returns the driver that should operate the new route, i.e. route this.getRoute() + new job this.getJob().
+ *
+ * Currently the driver is just a mock, it has no functions
+ *
* @return the newDriver
*/
public Driver getNewDriver() {
@@ -58,14 +117,24 @@ public class JobInsertionContext {
}
/**
+ * Returns the new departure time at the new vehicle's start location.
+ *
* @return the newDepTime
*/
public double getNewDepTime() {
return newDepTime;
}
- public JobInsertionContext(VehicleRoute route, Job job, Vehicle newVehicle,
- Driver newDriver, double newDepTime) {
+ /**
+ * Constructs the context.
+ *
+ * @param route the existing route where the job needs to be inserted in
+ * @param job the job to be inserted
+ * @param newVehicle the new vehicle that should operate the new route
+ * @param newDriver the new driver that should operate the new route
+ * @param newDepTime the new departure time at the new vehicle's start location
+ */
+ public JobInsertionContext(VehicleRoute route, Job job, Vehicle newVehicle, Driver newDriver, double newDepTime) {
super();
this.route = route;
this.job = job;
@@ -73,7 +142,26 @@ public class JobInsertionContext {
this.newDriver = newDriver;
this.newDepTime = newDepTime;
}
-
-
+ public List getAssociatedActivities() {
+ return associatedActivities;
+ }
+
+ /**
+ * Sets pickup context.
+ *
+ * @param pickupContext pickup context
+ */
+ public void setRelatedActivityContext(ActivityContext pickupContext){
+ this.pickupContext = pickupContext;
+ }
+
+ /**
+ * Returns pickup context. If no context available, returns null.
+ *
+ * @return pickup context
+ */
+ public ActivityContext getRelatedActivityContext(){
+ return this.pickupContext;
+ }
}
diff --git a/jsprit-core/src/test/java/jsprit/core/problem/misc/JobInsertionContextTest.java b/jsprit-core/src/test/java/jsprit/core/problem/misc/JobInsertionContextTest.java
new file mode 100644
index 00000000..91b04b6e
--- /dev/null
+++ b/jsprit-core/src/test/java/jsprit/core/problem/misc/JobInsertionContextTest.java
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (C) 2014 Stefan Schroeder
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3.0 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see .
+ ******************************************************************************/
+
+package jsprit.core.problem.misc;
+
+
+import jsprit.core.problem.driver.Driver;
+import jsprit.core.problem.job.Job;
+import jsprit.core.problem.solution.route.VehicleRoute;
+import jsprit.core.problem.solution.route.activity.TourActivity;
+import jsprit.core.problem.vehicle.Vehicle;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Mockito.mock;
+
+public class JobInsertionContextTest {
+
+ VehicleRoute route;
+
+ Job job;
+
+ Vehicle vehicle;
+
+ Driver driver;
+
+ double depTime;
+
+ JobInsertionContext context;
+
+ @Before
+ public void doBefore(){
+ route = mock(VehicleRoute.class);
+ job = mock(Job.class);
+ vehicle = mock(Vehicle.class);
+ driver = mock(Driver.class);
+ depTime = 0.;
+ context = new JobInsertionContext(route,job,vehicle,driver,depTime);
+ }
+
+ @Test
+ public void routeShouldBeAssigned(){
+ assertEquals(route,context.getRoute());
+ }
+
+ @Test
+ public void jobShouldBeAssigned(){
+ assertEquals(job,context.getJob());
+ }
+
+ @Test
+ public void vehicleShouldBeAssigned(){
+ assertEquals(vehicle,context.getNewVehicle());
+ }
+
+ @Test
+ public void driverShouldBeAssigned(){
+ assertEquals(driver,context.getNewDriver());
+ }
+
+ @Test
+ public void depTimeShouldBeAssigned(){
+ assertEquals(0.,context.getNewDepTime(),0.001);
+ }
+
+ @Test
+ public void relatedActivitiesShouldBeAssigned(){
+ context.getAssociatedActivities().add(mock(TourActivity.class));
+ context.getAssociatedActivities().add(mock(TourActivity.class));
+ assertEquals(2,context.getAssociatedActivities().size());
+ }
+
+ @Test
+ public void relatedActivityContextShouldBeAssigned(){
+ context.setRelatedActivityContext(mock(JobInsertionContext.ActivityContext.class));
+ assertNotNull(context.getRelatedActivityContext());
+ }
+
+}