Zulip Chat Archive

Stream: Is there code for X?

Topic: optimal schedules


Frederick Pu (Dec 18 2024 at 22:07):

Is there any code related to optimal schedules written in lean. If not here's a brief write up:
We define an interval to be tuple of real number (start, end) where start <= end
Two intervals intersect iff the intersection of their underlying sets (fun (start, end) => Set.Ioo start, end) is nonempty. In particular intervals (0, 1) (1, 2) are not considered to be intersecting.

Given a list of intervals l : List (Real x Real), a schedule on l is a sublist of l such that for any two distinct intervals (intervals at different indexes in the list) they are not intersecting. An optimal schedule g on a list l : List (Real x Real) is the schedule on l with the maximal possible length (all other schedules on l will have at most length g.length). Note that there can be multiple optimal schedules but they will have the same length.

The main goal for optimal schedules would be to prove that following program always returns the optimal schedule

def optimalSchedule(intervals):
         intervals = intervals.sort()
         S = []
         f = -inf
         for i in range(n):
                  if start[i] >= f:
                             S.append([start[i], end[i]])
                             f = end[i]
         return S

Yaël Dillies (Dec 18 2024 at 22:11):

Some people were interested in this back in september, but I haven't heard back from them. So I would assume "No, there is no code on optimal scheduling" :smile:

Frederick Pu (Dec 18 2024 at 22:18):

i wrote an informal proof for it and it mainly boils down to a very nasty lemma:

Let GG be an optimal schedule on intervalsintervals and ff be inf-inf or a real number such that {[start,end]G,endf}\{[start, end] \in G, end \geq f \} is nonempty.
Define [startb,endb][start_b, end_b], to be an element in {[start,end]G,endfstartend}\{[start, end] \in G, end \geq f \wedge start \neq end \} with the smallest end point.
For any [start,end]intervals[start, end] \in intervals such that endendbend \leq end_b and startfstart \geq f,
defining GG' to be the list formed by replacing [startb,endb][start_b, end_b] with [start,end][start, end] in GG, GG' is an optimal schedule of intervals.

Frederick Pu (Dec 18 2024 at 22:21):

how do i format latex in zulip lol

Yaël Dillies (Dec 18 2024 at 22:23):

Two $$, not just one

Daniel Weber (Dec 23 2024 at 08:27):

It could be interesting to more generally formalize chordal graphs


Last updated: May 02 2025 at 03:31 UTC