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

Co incidence and conflict - need to resolve #3

Open
kneerunjun opened this issue Jul 22, 2021 · 0 comments
Open

Co incidence and conflict - need to resolve #3

kneerunjun opened this issue Jul 22, 2021 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@kneerunjun
Copy link
Contributor

See the code documentation here

This section in the code needs a slight change in the conditional check. Coincidental schedules cannot be regarded as conflicting. Yes we may have to make changes to implementation of 2 schedules as well

scheduling/sched.go

Lines 137 to 161 in 5de802a

func overlapsWith(left, right Schedule) (bool, bool, bool) {
var outside, inside, overlap bool
// Midpoints are distance of the half time since midnight for any schedule
mdpt1, mdpt2 := left.Midpoint(), right.Midpoint()
// half duration of each schedule
hfdur1, hfdur2 := left.Duration()/2, right.Duration()/2
// getting the absolute of the midpoint distance
mdptdis := mdpt1 - mdpt2
if mdptdis < 0 {
mdptdis = -mdptdis
}
// Getting the larger of the 2 schedules
var min, max int
if hfdur1 <= hfdur2 {
min, max = hfdur1, hfdur2
} else {
min, max = hfdur2, hfdur1
}
if outside, inside = (mdptdis > (hfdur1 + hfdur2)), ((mdptdis + min) < max); outside || inside {
overlap = false
} else {
overlap = true
}
return outside, inside, overlap
}

@kneerunjun kneerunjun added the enhancement New feature or request label Jul 22, 2021
@kneerunjun kneerunjun self-assigned this Jul 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant