libretime/legacy
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
..
application feat(legacy): implement subset sum solution to show scheduling (#3019) 2024-10-13 15:31:08 +02:00
build feat(legacy): move session store to database (#2523) 2023-05-30 22:25:50 +02:00
install feat: add container setup 2022-09-14 11:09:52 +02:00
locale chore(legacy): translations update from Hosted Weblate (#3077) 2024-09-11 21:37:19 +01:00
public feat(legacy): show filename and size on edit page and add filename datatable column (#3083) 2024-10-13 08:45:54 +01:00
tests fix(deps): update dependency friendsofphp/php-cs-fixer to <3.26.1 (main) (#2677) 2023-09-08 15:45:24 +02:00
tools chore(deps): update dependency friendsofphp/php-cs-fixer to <3.64.1 (#3058) 2024-09-07 21:14:32 +02:00
.gitignore ci(legacy): catch syntax errors on older php versions 2022-08-24 12:18:40 +02:00
.php-cs-fixer.php chore(legacy): set format rules based on version 2022-09-12 14:15:50 +02:00
Makefile fix(legacy): remove composer superuser warning (#2515) 2023-04-19 16:15:15 +01:00
composer.json Merge branch '3.0.x' into main 2023-02-26 20:16:38 +01:00
composer.lock chore(deps): lock file maintenance (legacy/composer.json) 2024-09-17 09:26:00 +00:00
packages.ini chore: list distribution releases by release date 2022-10-10 20:11:33 +02:00