Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1: use function to reduce memory usage #71

Merged
merged 2 commits into from
Nov 9, 2020

Conversation

fonsecadeline
Copy link
Contributor

No description provided.

models/service.rb Outdated Show resolved Hide resolved
# TODO : need to uniformize generated relations whether mission has minimum AND maximum lapse or only one of them
return unless mission.visits_number > 1

if mission.minimum_lapse && mission.maximum_lapse
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you factorise the relation definition ? and give the specific mission_ids in a single place. It is a bit difficult to see the distinction between the cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now the goal was to group code that was identical for shipment and services.

I would indeed like to factorise but it is not that easy because of https://gitlab.com/mapotempo/optimizer-api/-/issues/339 . There can be an impact we need to test.

models/service.rb Outdated Show resolved Hide resolved
@@ -472,7 +472,7 @@ def build_costs(costs)

def check_services_compatible_days(vrp, vehicle, service)
if vrp.schedule_range_indices && (service.minimum_lapse || service.maximum_lapse)
(vehicle.global_day_index >= service[:first_possible_day] && vehicle.global_day_index <= service[:last_possible_day]) ? true : false
(vehicle.global_day_index >= service[:first_possible_days].first && vehicle.global_day_index <= service[:last_possible_days].first) ? true : false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition already returns true or false ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The content of the function could be replaced with:

!vrp.schedule_range_indices || (!service.minimum_lapse && !service.maximum_lapse) ||
  (vehicle.global_day_index >= service[:first_possible_days].first && vehicle.global_day_index <= service[:last_possible_days].first)

@fab-girard fab-girard merged commit 5eca3c3 into Mapotempo:dev Nov 9, 2020
@fonsecadeline fonsecadeline deleted the memory_usage_reduction branch January 21, 2021 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants