简体   繁体   English

给定一系列不同持续时间的对象,如何在给定的时间范围内找到所有可能的安排

[英]Given an array of objects of varying durations, how can you find all possible arrangements within a given time frame

So if you have a set objects that each have different duration values, like songs for example - and you want to create a bunch of playlists that all fit within a specific timeframe, what would be the easiest way of going about this? 因此,如果您有一组对象,每个对象具有不同的持续时间值(例如歌曲),并且想要创建一堆都适合特定时间范围的播放列表,那么最简单的方法是什么?

Example: 例:

  • Song 1 : 1:30 歌1:1:30
  • Song 2 : 2:56 歌2:2:56
  • Song 3 : 3:56 歌3:3:56
  • Song 4 : 4:54 歌4:4:54
  • Song 5 : 1:00 歌曲5:1:00

Maximum duration: 5:00 最长持续时间:5:00

Possible Combinations: (Song 1, Song 2), (Song 2, Song 1), (Song 2, Song 5), (Song 5, Song 2), (Song 3, Song 5), (Song 5, Song 3), (Song 4). 可能的组合:(歌曲1,歌曲2),(歌曲2,歌曲1),(歌曲2,歌曲5),(歌曲5,歌曲2),(歌曲3,歌曲5),(歌曲5,歌曲3) ,(歌曲4)。

I am curious about neural networks, but do not know much about them or if they would be easily applied to this problem. 我对神经网络很好奇,但是对神经网络知之甚少,或者它们是否可以轻松地应用于此问题。 The target language is php. 目标语言是php。

It would be ideal if an allowed variance could be provided like +/- 0:30 so that generated playlists could fall either below or above the maximum limit by the given amount. 理想的情况是,可以提供允许的差异(例如+/- 0:30),以使生成的播放列表可以低于或高于最大限制达到给定的数量。

Any help would be appreciated, just trying to figure out how to begin approaching this problem, Thanks! 任何帮助将不胜感激,只是试图找出如何开始解决这个问题,谢谢!

This is a bin-packing problem. 这是一个装箱问题。 You can sort the list and then you can try to fill the time frames with the best fit,the next fit, the first fit or worst fit. 您可以对列表进行排序,然后尝试用最适合,最适合,最适合或最不适合的时间范围填充时间范围。 Imagine you have more then one time frame and you need to find the smallest amount of time frames with a given playlist. 假设您有一个以上的时间范围,并且您需要找到具有给定播放列表的最小时间范围。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何找到给定数组的可能子集? - how to find possible subsets of a given array? 如何找到给定数组的数量 - How can I find qty of given array 如何有效地生成给定长度字母的所有可能字母组合的数组? - How can I efficiently generate an array of all possible alphabetical combinations of a given length of letters? 给定一个时间,我怎样才能找到一个月前的时间 - Given a time, how can I find the time one month ago 如何在给定范围内不重复数组的情况下打印所有可能的变化? - How to print all possible variations without repetitions of array for given range? 如何从给定的子键中查找数组的所有父键? - How to find all parent keys of an array from a given child key? 给定一个数组数组,如何将所有空值替换为0? - Given an array of arrays, how can I replace all empty values with 0? PHP - 在数组中查找最小值并组合所有可能的数字以达到给定的总和 - PHP - Find minimum value in an array and combine all possible numbers to reach a given sum 在给定属性值的对象数组中查找数组键 - Find array key in objects array given an attribute value 给定字符生成器和长度,如何生成所有可能字符串的列表? - How do you generate a list of all possible strings given a generator of characters and a length?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM