@@ -56,18 +56,30 @@ public LocalActivityInsertionCostsCalculator(VehicleRoutingTransportCosts routin
56
56
57
57
@ Override
58
58
public double getCosts (JobInsertionContext iFacts , TourActivity prevAct , TourActivity nextAct , TourActivity newAct , double depTimeAtPrevAct ) {
59
+ double coef = 1.0 ;
60
+ if (iFacts .getNewVehicle () != null )
61
+ coef = iFacts .getNewVehicle ().getCoefSetupTime ();
62
+ double setup_time_prevAct_newAct = 0.0 ;
63
+ if (!prevAct .getLocation ().equals (newAct .getLocation ()))
64
+ setup_time_prevAct_newAct = newAct .getSetupTime () * coef ;
65
+ double setup_cost_prevAct_newAct = setup_time_prevAct_newAct * iFacts .getNewVehicle ().getType ().getVehicleCostParams ().perTransportTimeUnit ;
66
+ double tp_costs_prevAct_newAct = setup_cost_prevAct_newAct + routingCosts .getTransportCost (prevAct .getLocation (), newAct .getLocation (), depTimeAtPrevAct , iFacts .getNewDriver (), iFacts .getNewVehicle ());
67
+ double tp_time_prevAct_newAct = setup_time_prevAct_newAct + routingCosts .getTransportTime (prevAct .getLocation (), newAct .getLocation (), depTimeAtPrevAct , iFacts .getNewDriver (), iFacts .getNewVehicle ());
59
68
60
- double tp_costs_prevAct_newAct = routingCosts .getTransportCost (prevAct .getLocation (), newAct .getLocation (), depTimeAtPrevAct , iFacts .getNewDriver (), iFacts .getNewVehicle ());
61
- double tp_time_prevAct_newAct = routingCosts .getTransportTime (prevAct .getLocation (), newAct .getLocation (), depTimeAtPrevAct , iFacts .getNewDriver (), iFacts .getNewVehicle ());
62
69
double newAct_arrTime = depTimeAtPrevAct + tp_time_prevAct_newAct ;
63
70
double newAct_endTime = Math .max (newAct_arrTime , newAct .getTheoreticalEarliestOperationStartTime ()) + activityCosts .getActivityDuration (newAct , newAct_arrTime , iFacts .getNewDriver (), iFacts .getNewVehicle ());
64
71
65
72
double act_costs_newAct = activityCosts .getActivityCost (newAct , newAct_arrTime , iFacts .getNewDriver (), iFacts .getNewVehicle ());
66
73
67
74
if (isEnd (nextAct ) && !toDepot (iFacts .getNewVehicle ())) return tp_costs_prevAct_newAct ;
68
75
69
- double tp_costs_newAct_nextAct = routingCosts .getTransportCost (newAct .getLocation (), nextAct .getLocation (), newAct_endTime , iFacts .getNewDriver (), iFacts .getNewVehicle ());
70
- double tp_time_newAct_nextAct = routingCosts .getTransportTime (newAct .getLocation (), nextAct .getLocation (), newAct_endTime , iFacts .getNewDriver (), iFacts .getNewVehicle ());
76
+ double setup_time_newAct_nextAct = 0.0 ;
77
+ if (!newAct .getLocation ().equals (nextAct .getLocation ()))
78
+ setup_time_newAct_nextAct = nextAct .getSetupTime () * coef ;
79
+ double setup_cost_newAct_nextAct = setup_time_newAct_nextAct * iFacts .getNewVehicle ().getType ().getVehicleCostParams ().perTransportTimeUnit ;
80
+ double tp_costs_newAct_nextAct = setup_cost_newAct_nextAct + routingCosts .getTransportCost (newAct .getLocation (), nextAct .getLocation (), newAct_endTime , iFacts .getNewDriver (), iFacts .getNewVehicle ());
81
+ double tp_time_newAct_nextAct = setup_time_newAct_nextAct + routingCosts .getTransportTime (newAct .getLocation (), nextAct .getLocation (), newAct_endTime , iFacts .getNewDriver (), iFacts .getNewVehicle ());
82
+
71
83
double nextAct_arrTime = newAct_endTime + tp_time_newAct_nextAct ;
72
84
double endTime_nextAct_new = Math .max (nextAct_arrTime , nextAct .getTheoreticalEarliestOperationStartTime ()) + activityCosts .getActivityDuration (nextAct , newAct_arrTime , iFacts .getNewDriver (), iFacts .getNewVehicle ());
73
85
double act_costs_nextAct = activityCosts .getActivityCost (nextAct , nextAct_arrTime , iFacts .getNewDriver (), iFacts .getNewVehicle ());
@@ -79,8 +91,14 @@ public double getCosts(JobInsertionContext iFacts, TourActivity prevAct, TourAct
79
91
double tp_costs_prevAct_nextAct = routingCosts .getTransportCost (prevAct .getLocation (), nextAct .getLocation (), depTimeAtPrevAct , iFacts .getNewDriver (), iFacts .getNewVehicle ());
80
92
oldCosts += tp_costs_prevAct_nextAct ;
81
93
} else {
82
- double tp_costs_prevAct_nextAct = routingCosts .getTransportCost (prevAct .getLocation (), nextAct .getLocation (), prevAct .getEndTime (), iFacts .getRoute ().getDriver (), iFacts .getRoute ().getVehicle ());
83
- double arrTime_nextAct = depTimeAtPrevAct + routingCosts .getTransportTime (prevAct .getLocation (), nextAct .getLocation (), prevAct .getEndTime (), iFacts .getRoute ().getDriver (), iFacts .getRoute ().getVehicle ());
94
+ double setup_time_prevAct_nextAct = 0.0 ;
95
+ if (!prevAct .getLocation ().equals (nextAct .getLocation ()))
96
+ setup_time_prevAct_nextAct = nextAct .getSetupTime () * coef ;
97
+ double setup_cost_prevAct_nextAct = setup_time_prevAct_nextAct * iFacts .getNewVehicle ().getType ().getVehicleCostParams ().perTransportTimeUnit ;
98
+ double tp_costs_prevAct_nextAct = setup_cost_prevAct_nextAct + routingCosts .getTransportCost (prevAct .getLocation (), nextAct .getLocation (), prevAct .getEndTime (), iFacts .getRoute ().getDriver (), iFacts .getRoute ().getVehicle ());
99
+ double tp_time_prevAct_nextAct = setup_time_prevAct_nextAct + routingCosts .getTransportTime (prevAct .getLocation (), nextAct .getLocation (), prevAct .getEndTime (), iFacts .getRoute ().getDriver (), iFacts .getRoute ().getVehicle ());
100
+
101
+ double arrTime_nextAct = depTimeAtPrevAct + tp_time_prevAct_nextAct ;
84
102
double endTime_nextAct_old = Math .max (arrTime_nextAct , nextAct .getTheoreticalEarliestOperationStartTime ()) + activityCosts .getActivityDuration (nextAct , nextAct_arrTime , iFacts .getRoute ().getDriver (),iFacts .getRoute ().getVehicle ());
85
103
double actCost_nextAct = activityCosts .getActivityCost (nextAct , arrTime_nextAct , iFacts .getRoute ().getDriver (), iFacts .getRoute ().getVehicle ());
86
104
0 commit comments