libretime/legacy/application
dakriy 5b5c68c628
feat(legacy): implement subset sum solution to show scheduling (#3019)
### Description

When running a radio station it is generally a good idea to reduce dead
air time. The current algorithm for adding tracks to a block/show can
leave a lot of dead air time at the end as it doesn't use a very good
algorithm. Adding tracks to a show until it is full while making it as
full as possible is a well known problem in computer science. It is the
[Subset Sum Problem](https://en.wikipedia.org/wiki/Subset_sum_problem).
This PR implements a Randomized Greedy with Local Improvement (RGLI)
approximation solution for the Subset Sum Problem. The new algorithm is
only used when sort type is random and overflow is not enabled and there
is no limit on the number of tracks that can be used.

**This is a new feature**:

Improvement on an existing feature. 

**I have not updated the documentation to reflect these changes**:

I did not update the documentation because the current scheduling
algorithm is not currently documented and its existing features have not
changed.

### Testing Notes

**What I did:**

I first attempted a fully polynomial time approximation scheme solution,
however it is really bad at finding good solutions for high density
values and can kinda slow the more tracks/time you have. So I instead
implemented an RGLI which is O(nlogn) and has been giving much better
results.

I implemented the solution in a separate project and tested it and timed
the values with a normal distribution of 500 songs with a mean of 3
minutes and a standard deviation of 1 minute. With a show size of 1 hour
the algorithm took around 10-15 ms to run. When adjusting the block size
and track size the algorithm still was pretty quick to run. Am going to
be testing on an instance with lots of tracks later, will update PR when
I have done that.

**How you can replicate my testing:**

_How can the reviewer validate this PR?_

### **Links**

Closes #3018
2024-10-13 15:31:08 +02:00
..
auth/adapters fix(deps): update dependency friendsofphp/php-cs-fixer to <3.46.1 (main) (#2868) 2024-01-07 13:59:02 +01:00
common feat: add Norwegian Bokmål locale (#3073) 2024-09-06 14:43:40 +01:00
configs feat(playout): configure device for alsa and pulseaudio system outputs (#2654) 2023-12-29 15:22:43 +01:00
controllers feat(legacy): show filename and size on edit page and add filename datatable column (#3083) 2024-10-13 08:45:54 +01:00
forms feat(legacy): add filename block criteria (#3015) 2024-06-22 11:51:59 +02:00
layouts/scripts fix(legacy): add play button to stream player (#2190) 2022-09-27 08:14:53 +02:00
logging fix(deps): update dependency friendsofphp/php-cs-fixer to <3.53.1 (#2972) 2024-04-13 14:36:31 +02:00
models feat(legacy): implement subset sum solution to show scheduling (#3019) 2024-10-13 15:31:08 +02:00
modules/rest fix(deps): update dependency friendsofphp/php-cs-fixer to <3.53.1 (#2972) 2024-04-13 14:36:31 +02:00
services fix(deps): update dependency friendsofphp/php-cs-fixer to <3.43.2 (main) (#2848) 2023-12-29 15:28:57 +01:00
validate Format code using php-cs-fixer 2021-10-12 11:07:56 +02:00
views feat(legacy): show filename and size on edit page and add filename datatable column (#3083) 2024-10-13 08:45:54 +01:00
Bootstrap.php feat(legacy): move session store to database (#2523) 2023-05-30 22:25:50 +02:00
airtime-boot.php chore: remove cloud storage remainings (#1934) 2022-07-04 22:09:14 +02:00
assets.json feat(legacy): show filename and size on edit page and add filename datatable column (#3083) 2024-10-13 08:45:54 +01:00
check.php fix(deps): update dependency friendsofphp/php-cs-fixer to <3.46.1 (main) (#2868) 2024-01-07 13:59:02 +01:00
preload.php fix(legacy): log errors on connect check failure (#2317) 2022-12-16 19:38:33 +01:00