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

optimise-services-and-exceptions: analyse distribution of service dates -> truncate/expand time span #41

Open
derhuerst opened this issue Feb 28, 2022 · 1 comment
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@derhuerst
Copy link
Member

derhuerst commented Feb 28, 2022

As of [email protected], optimise-services-and-exceptions.js implements a very rudimental optimisation strategy:

  • it calculates all service dates (both "regular" & exception_type=1-based) of a service, and then
  • checks if there are more "regular" than exception-based dates (in this case, it sets the respective daw of the week (DoW) flag to 1), or vice versa.

There is a lot of potential in changing the time span (start_date/end_date) of the service, so that the number of exceptions necessary to express it is minimised. To do this, we must consider the distribution of the service's dates, so that rare outliers – e.g. Christmas with a service that only runs during summer & on Christmas – are expressed as exceptions, whereas the majority of the dates is express using DoW flags.

@derhuerst derhuerst added enhancement New feature or request help wanted Extra attention is needed labels Feb 28, 2022
@derhuerst
Copy link
Member Author

Consider this example:

service:
	2022-05-01 - 2022-05-31
	monday: 1
exceptions:
	ADDED	2022-05-03 tuesday
	ADDED	2022-05-10 tuesday
	ADDED	2022-05-17 tuesday
	ADDED	2022-05-31 tuesday
	ADDED	2022-05-18 wednesday
	ADDED	2022-05-07 saturday
	REMOVED	2022-05-09 monday
	REMOVED	2022-05-30 monday

By changing the service's time span to 20220501/20220523, we can reduce the number of expressions:

service:
	2022-05-01 - 2022-05-23
	monday: 1
	tuesday: 1
exceptions:
	ADDED	2022-05-31 tuesday
	ADDED	2022-05-18 wednesday
	ADDED	2022-05-07 saturday
	REMOVED	2022-05-09 monday
	REMOVED	2022-05-30 monday

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Development

No branches or pull requests

1 participant