定制 giorgio93p/bin-packing 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

giorgio93p/bin-packing

最新稳定版本:v1.0.2

Composer 安装命令:

composer require giorgio93p/bin-packing

包简介

Implementation of a branch and bound algorithm for bin packing, where bins can have a lower bound on their capacity

关键字:

README 文档

README

The algorithm tries to find the best possible solution (i.e. with the smaller number of bins) by (almost) exhaustively searching the possible solutions. This implies that it is quite slow and will not terminate for an input of more than a few dozen items.

You need to have your items implement the interface BinItem. This includes just a size(): int method. This is meant to be the size of the item. Notice that it must be a strictly positive integer. The size() method of BinItems should run in constant time.

You can pass an iterable (e.g. array or laravel Collection) of BinItems into BinPacking::pack, along with the options of the packing (min and max size of bin). Again, sizes are strictly positive integers. Min size can also be 0.

BinPacking::pack will return an array of bins. Each bin has a method items(), which returns the items of the input that are in the said bin.

For example,

class MyClass implements \Gpits\BinPacking\BinItem
{
    public function size(): int
    {
        //fill this
    }
}

$items = MyClass::getAllItems();

$bins = \Gpits\BinPacking\BinPacking::pack($items, 150, 4000); // for min bin size 150 and max bin size 4000
foreach($bins as $bin){
    foreach($bin->items() as $item){
        //do something with
        $item;
        // where $item instanceof MyClass
    }
}

If you have an item that is too big to fit in any bin, a BinPackingException will be thrown.

统计信息

  • 总下载量: 3
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: AGPL-3.0-or-later
  • 更新时间: 2023-04-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固