keydev/laff-analyzer
Composer 安装命令:
composer require keydev/laff-analyzer
包简介
PHP Implementation of the Largest Area Fit First (LAFF) 3D (three dimension) box packing algorithm
关键字:
README 文档
README
PHP Implementation of the Largest Area Fit First (LAFF) 3D (three dimensions: length, width, height) box packing algorithm.
With this library you can easily:
- get the required dimensions of the container that will fit all given packages,
- split packages per defined amount of containers,
- split packages per layer in a given container,
- get information about the wasted amount of space per container and per layer,
- get the number of remaining packages that couldn't fit into given containers,
Algorithm definition
Implementation of the used algorithm was defined by M. Zahid Gürbüz, Selim Akyokus, Ibrahim Emiroglu, and Aysun Güran in a paper called "An Efficient Algorithm for 3D Rectangular Box Packing".
Installation
Note To use this library you need PHP in version 8.1+
composer require keydev/laff-analyzer
Usage
Get the size of the required container for selected packages
<?php use LAFF\Analyzer\Analyzer; use LAFF\Analyzer\Model\Package; $packages = [ new Package(50, 50, 8), new Package(33, 8, 8), new Package(16, 20, 8), new Package(3, 18, 8), new Package(14, 12, 8), ]; $analyzer = new Analyzer(); $analyzer->analyze($packages); $containers = $analyzer->getContainers(); /** @var Container $container */ $container = reset($containers); var_dump($container->toArray()); // Output: // array(3) { // ["length"]=> // int(50) // ["width"]=> // int(50) // ["height"]=> // int(16) // } var_dump($container->countLayers()); // Output: // int(2) var_dump($analyzer->getWastePercentage()); // Output (%): // int(32) var_dump($analyzer->getWasteVolume()); // Output (cm3): // int(13552)
Check how many packages can be fitter into a given container
<?php use LAFF\Analyzer\Analyzer; use LAFF\Analyzer\Model\Container; use LAFF\Analyzer\Model\Package; $packages = [ new Package(50, 50, 8), new Package(33, 8, 8), new Package(16, 20, 8), new Package(3, 18, 8), new Package(14, 12, 8), ]; $container = new Container(65, 60, 8); $analyzer = new Analyzer(); $analyzer->analyze($packages, [$container]); var_dump($container->full); // Output: // bool(true) var_dump($container->countLayers()); // Output: // int(1) var_dump($container->getWastePercentage()); // Output (%) //: int(15) var_dump($container->getWasteVolume()); // Output (cm3): // int(4752)
Development
To install dependencies, launch the following commands:
composer install
Run Tests
To execute full test suite, static analyse or coding style fixed, launch the following commands:
composer test
composer phpstan
composer cs-fixer
Kudos
There is already a library for LAFF in PHP: Cloudstek/php-laff; while both use the same algorithm, the internals is different. The main difference between those libraries is that this one can work on an array of containers. I want to say "thank you" for the work on that library in the past!
keydev/laff-analyzer 适用场景与选型建议
keydev/laff-analyzer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 397 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 11 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「packaging」 「largest area fit first」 「box packing algorithm」 「optimization problems」 「three-dimensional packing」 「combinatorial problem」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 keydev/laff-analyzer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 keydev/laff-analyzer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 keydev/laff-analyzer 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
An implementation of the 3D (actually 4D) bin packing/knapsack problem (aka creating parcels by putting items into boxes)
Largest Remainder Method calculation
Impersonate kirby users in the panel
The universal PHP library to convert any values and measures
An implementation of the 3D (actually 4D) bin packing/knapsack problem (aka creating parcels by putting items into boxes)
AreportDpmXBRL is a package for parsing XBRL taxonomy which is created by EU standards
统计信息
- 总下载量: 397
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 29
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-11-12