@@ -39,10 +39,7 @@ impl ConstraintModule for TimingConstraintModule {
3939 |( loc, dep) , activity| {
4040 let mut a = activity. write ( ) . unwrap ( ) ;
4141
42- a. schedule . arrival = dep
43- + self
44- . transport
45- . duration ( actor. vehicle . profile , loc, a. place . location , dep) ;
42+ a. schedule . arrival = dep + self . transport . duration ( actor. vehicle . profile , loc, a. place . location , dep) ;
4643
4744 a. schedule . departure = a. schedule . arrival . max ( a. place . time . start )
4845 + self . activity . duration (
@@ -59,10 +56,7 @@ impl ConstraintModule for TimingConstraintModule {
5956 // update latest arrival and waiting states of non-terminate (jobs) activities
6057 let init = (
6158 actor. detail . time . end ,
62- actor
63- . detail
64- . end
65- . unwrap_or ( actor. detail . start . unwrap_or ( panic ! ( OP_START_MSG ) ) ) ,
59+ actor. detail . end . unwrap_or ( actor. detail . start . unwrap_or ( panic ! ( OP_START_MSG ) ) ) ,
6660 0f64 ,
6761 ) ;
6862 route. tour . all_activities ( ) . rev ( ) . fold ( init, |acc, activity| {
@@ -73,12 +67,8 @@ impl ConstraintModule for TimingConstraintModule {
7367
7468 let ( end_time, prev_loc, waiting) = acc;
7569 let potential_latest = end_time
76- - self
77- . transport
78- . duration ( actor. vehicle . profile , act. place . location , prev_loc, end_time)
79- - self
80- . activity
81- . duration ( actor. vehicle . as_ref ( ) , actor. driver . as_ref ( ) , act. deref ( ) , end_time) ;
70+ - self . transport . duration ( actor. vehicle . profile , act. place . location , prev_loc, end_time)
71+ - self . activity . duration ( actor. vehicle . as_ref ( ) , actor. driver . as_ref ( ) , act. deref ( ) , end_time) ;
8272
8373 let latest_arrival_time = act. place . time . end . min ( potential_latest) ;
8474 let future_waiting = waiting + ( act. place . time . start - act. schedule . arrival ) . max ( 0f64 ) ;
@@ -137,17 +127,11 @@ struct TimeHardActivityConstraint {
137127
138128impl TimeHardActivityConstraint {
139129 fn fail ( & self ) -> Option < ActivityConstraintViolation > {
140- Some ( ActivityConstraintViolation {
141- code : self . code ,
142- stopped : true ,
143- } )
130+ Some ( ActivityConstraintViolation { code : self . code , stopped : true } )
144131 }
145132
146133 fn stop ( & self ) -> Option < ActivityConstraintViolation > {
147- Some ( ActivityConstraintViolation {
148- code : self . code ,
149- stopped : false ,
150- } )
134+ Some ( ActivityConstraintViolation { code : self . code , stopped : false } )
151135 }
152136
153137 fn success ( & self ) -> Option < ActivityConstraintViolation > {
@@ -173,9 +157,7 @@ impl HardActivityConstraint for TimeHardActivityConstraint {
173157
174158 if actor. detail . time . end < prev. place . time . start
175159 || actor. detail . time . end < target. place . time . start
176- || next. map_or ( false , |next| {
177- actor. detail . time . end < next. read ( ) . unwrap ( ) . place . time . start
178- } )
160+ || next. map_or ( false , |next| actor. detail . time . end < next. read ( ) . unwrap ( ) . place . time . start )
179161 {
180162 return self . fail ( ) ;
181163 }
@@ -190,30 +172,24 @@ impl HardActivityConstraint for TimeHardActivityConstraint {
190172 }
191173 (
192174 n. place . location ,
193- * state
194- . get_activity_state ( LATEST_ARRIVAL_KEY , next. unwrap ( ) )
195- . unwrap_or ( & n. place . time . end ) ,
175+ * state. get_activity_state ( LATEST_ARRIVAL_KEY , next. unwrap ( ) ) . unwrap_or ( & n. place . time . end ) ,
196176 )
197177 } else {
198178 // open vrp
199179 ( target. place . location , target. place . time . end . min ( actor. detail . time . end ) )
200180 } ;
201181
202- let arr_time_at_next = departure
203- + self
204- . transport
205- . duration ( profile, prev. place . location , next_act_location, departure) ;
182+ let arr_time_at_next =
183+ departure + self . transport . duration ( profile, prev. place . location , next_act_location, departure) ;
206184 if arr_time_at_next > latest_arr_time_at_next_act {
207185 return self . fail ( ) ;
208186 }
209187 if target. place . time . start > latest_arr_time_at_next_act {
210188 return self . stop ( ) ;
211189 }
212190
213- let arr_time_at_target_act = departure
214- + self
215- . transport
216- . duration ( profile, prev. place . location , target. place . location , departure) ;
191+ let arr_time_at_target_act =
192+ departure + self . transport . duration ( profile, prev. place . location , target. place . location , departure) ;
217193
218194 let end_time_at_new_act = arr_time_at_target_act. max ( target. place . time . start )
219195 + self . activity . duration (
@@ -248,9 +224,7 @@ impl HardActivityConstraint for TimeHardActivityConstraint {
248224 }
249225
250226 let arr_time_at_next_act = end_time_at_new_act
251- + self
252- . transport
253- . duration ( profile, target. place . location , next_act_location, end_time_at_new_act) ;
227+ + self . transport . duration ( profile, target. place . location , next_act_location, end_time_at_new_act) ;
254228
255229 if arr_time_at_next_act > latest_arr_time_at_next_act {
256230 self . stop ( )
0 commit comments