Skip to content

Commit

Permalink
Functions manage their extreme cases themselves
Browse files Browse the repository at this point in the history
  • Loading branch information
senhalil committed Jan 12, 2022
1 parent 9262b86 commit 3ab634a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions models/concerns/periodic_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ module PeriodicService
extend ActiveSupport::Concern

def can_affect_all_visits?(service)
return true unless self.schedule?

return true if service.visits_number == 1

self.vehicles.any?{ |vehicle|
Expand Down
4 changes: 2 additions & 2 deletions wrappers/wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,8 @@ def compute_vehicles_capacity(vrp)
end

def possible_days_are_consistent(vrp, service)
return true unless vrp.schedule?

return false if service.first_possible_days.any?{ |d| d > vrp.schedule_range_indices[:end] }

return false if service.last_possible_days.any?{ |d| d < vrp.schedule_range_indices[:start] }
Expand Down Expand Up @@ -747,8 +749,6 @@ def detect_unfeasible_services(vrp)
detect_inconsistent_relation_timewindows_od_service(vrp, unfeasible, service)

# Planning inconsistency
next if !vrp.schedule?

unless possible_days_are_consistent(vrp, service)
add_unassigned(unfeasible, vrp, service, 'Provided possible days do not allow service to be assigned')
end
Expand Down

0 comments on commit 3ab634a

Please sign in to comment.