定制 keydev/laff-analyzer 二次开发

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

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

keydev/laff-analyzer

最新稳定版本:0.1

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!

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-11-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固