0

I have a scheduling scenario in which every time period has a cost. I need to select the time periods which will give me the least cost over a period of 24 hours. See below for an example of the dataset.

Start time | End time | Cost

  • 00:00 | 01:00 | $30
  • 01:00 | 05:00 | $50
  • 02:00 | 08:00 | $70
  • 04:00 | 12:00 | $100
  • 08:00 | 11:00 | $60
  • 10:00 | 14:00 | $50
  • 13:00 | 17:00 | $90
  • 13:00 | 20:00 | $120
  • 16:00 | 23:00 | $80
  • 18:00 | 22:00 | $60
  • 19:00 | 20:00 | $50
  • 21:00 | 23:00 | $20

Is there any Python software or library which I can use to derive the set of time periods which gives the least cost, each time period must not overlap and they must all add up to 24 hours?

3
  • 1
    The example has no solution. The first choice has to be option 1, the second choice has to be option 2, and there's no option that starts when option 2 begins. Jun 12, 2020 at 13:55
  • Do they have to add up to 24 hours, or do they have to collectively cover a single unbroken 24-hour period?
    – BrenBarn
    Jun 14, 2020 at 2:15
  • They have to collectively cover a single unbroken 24-hour period. Gaps are allowed.
    – Xanlamin
    Jun 15, 2020 at 4:20

1 Answer 1

0

This sounds like a knapsack problem variant.

I'd expect that OptaPy is able to handle it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.