简体   繁体   English

最佳解决方案,以适应多个容量袋中的物品

[英]Optimal solution to fit the items in multiple capacity bags

I have been working on this problem ( https://github.com/alexpchung/File-Distribution-Planning/blob/master/README.pdf ) where I need to find an optimal solution to place the files in the node. 我一直在研究这个问题( https://github.com/alexpchung/File-Distribution-Planning/blob/master/README.pdf ),我需要找到一个最佳的解决方案来将文件放在节点中。

Here is my algorithm which I have used so far 这是我到目前为止使用的算法

  • Say number of nodes is N. 说节点数是N.

  • keep track of available file size for every node iterate through every file, it has N choices to go to (assuming file fits in etc) 跟踪每个节点的可用文件大小迭代每个文件,它有N个选择去(假设文件适合等)

  • Recursively evaluate for every 递归评估每一个

Another solution which I have thought is to iterate through each and every node and do a knapsack 0/1. 我想到的另一个解决方案是迭代每个节点并做一个背包0/1。 Unfortunately, i got struck because since the node sizes are not fixed it will be an incorrect solution. 不幸的是,我受到了打击,因为由于节点大小没有修复,这将是一个不正确的解决方案。

If you have any pointers that would be great. 如果你有任何指针会很棒。

Thanks. 谢谢。

Maybe you can benchmark this: 也许你可以对此进行测试:

  • Sort two lists.(capacity,size, all increasing) 排序两个列表。(容量,大小,所有增加)

  • Start from biggest file. 从最大的文件开始。

  • Also start from biggest node. 也从最大的节点开始。
  • Check if it fits 检查它是否合适
    • true: put it in 是的:把它放进去
    • false: put it to "failed" list since no bigger node exists. false:将其置于“失败”列表,因为不存在更大的节点。
  • If selected(biggest) node is full, iterate next smaller node 如果选中(最大)节点已满,则迭代下一个较小节点
  • İterate to next smaller file. İterate到下一个较小的文件。
  • go back to checking step until either one of conditions true 回到检查步骤,直到任一条件为真
    • all files assigned, empty nodes exist 分配的所有文件,存在空节点
    • all nodes full, unplaced files exist 所有节点都存在完整的未放置文件
  • (*)sort only nodes on their empty spaces(empty nodes exist=true or both true) (*)仅对空白空间中的节点进行排序(空节点存在= true或两者都为true)
    • duplicate node list with opposite order 具有相反顺序的重复节点列表
      • check if "latest added file" on least "empty space"d can fit biggest "empty space"d node and if transition yields equal/balanced empty space on both 检查“最新添加的文件”至少“空白空间”d是否适合最大的“空白空间”d节点,如果转换在两者上产生相等/平衡的空白空间
        • true: send file to that node true:将文件发送到该节点
        • false: iterate on next "least empty space" node since that file can't fit others neighter false:迭代下一个“最小空格”节点,因为该文件不能更适合其他节点
      • iterate both lists(and remove refined pairs from lists) 迭代两个列表(并从列表中删除精炼对)
  • if at least 1 files could be refined, go to (*) 如果至少可以提炼1个文件,请转到(*)

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM