tijlleenders / ZinZen-scheduler

The calendar engine for the ZinZen web app.
https://github.com/tijlleenders/ZinZen
GNU Affero General Public License v3.0
10 stars 4 forks source link

Align with domain model #428

Closed tijlleenders closed 9 months ago

tijlleenders commented 11 months ago

Is your feature request related to a problem? Please describe. Docs need to be updated with new terms.

Describe the solution you'd like Code in #431 resolves the confusion about the domain model, in my opinion:

This still needs to be integrated into the docs - so leaving this open.

Describe alternatives you've considered

Additional context This was previously a slightly different issue - but updated the issue text to reflect new insights into the domain language that 'works'.

tijlleenders commented 10 months ago

@thinkrapido @kobe-reygel

429 mentions 'TimeSpan'. This seems like a new concept - not yet present in the code.

Is this new or a replacement for what you called 'Day' before?

Obviously, the ZinZen scheduler concepts are not intuitive, as each time a new person comes onboard we try to introduce new names for things that more or less already exist... We should solve this semantic ambiguity before moving on.

Inspired by #429 - and assuming this is the same concept as 'Day' and the legacy 'Timeline' - I've come up with yet another name proposal (yes, naming is hard).
Let's rename Day/Timeline/TimeSpan to TimeSpaces.

For the second part of this issue (renaming min_span to min_duration) I think @thinkrapido are already in agreement after the Budget discussion. Budgets and Goals extend the base Activity. For Goals, there is a total_duration and a remaining_duration - as wel as a min_block_size (min_span_size?) and max_block_size.

Curious to hear your thoughts!

tijlleenders commented 10 months ago

Another idea is to let the Calendar own the Seats/Hours/... (whatever the unit of measure of the Calendar is) - with status Free or Occupied for each unit - and each Activity having a CompatibleSeats collection with references to the Seats/Hours of the Calendar that fit the ActivityConstraints.

Each Activity will know its own Flexibility - that automatically excludes anything that doesn't fit the ActivityConstraints, as well as any reference to a unit that has status Occupied. The scheduler can request the Flexibility from each Activity to determine which Activity gets scheduled next.

During assignment of Seats/Hours to the Activity that gets selected by the scheduler, the scheduler can ask the Calendar for the number of Claims by other Activities for each (set of) Seat(s)/Hour(s) the Activity proposes as a suitable option. The claims are known using the Rc count of the Calendar Seat/Hour, making it easy for the scheduler to see which of the proposed (set of) Seat(s)/Hour(s) has the least conflicts with claims from other Activities.

Weak and strong Rcs could be used to auto-break the reference upon actual allocation/scheduling - or differentiate between scheduled/unscheduled status?

tijlleenders commented 10 months ago

@thinkrapido @kobe-reygel @Tushar-4781 I think I figured out how Rc works ... and how we can use it to keep track of hour-claims.

Here's a 300 LOC proof of concept with the scheduler-challenge testcase working. main.zip

I was a little lazy on the flex and scheduling loops; they just iterate over the whole calendar from start to finish...
I suspect this will not have any noticeable performance impact - but it does keep the loop simple to understand.

tijlleenders commented 9 months ago

@thinkrapido @kobe-reygel

Code in #431 resolves the confusion about the domain model, in my opinion:

This still needs to be integrated into the docs - so leaving this open.