drupol/phpartition
Composer 安装命令:
composer require drupol/phpartition
包简介
Partition problem for balanced arrays splitting made easy.
README 文档
README
In number theory and computer science, the partition problem is the task of deciding whether a given multiset of items can be partitioned into multiple balanced subsets.
Requirements
- PHP >= 5.6,
- (optional) PHPUnit to run tests.
Examples
<?php include "./vendor/autoload.php"; $data = array(1, 5, 5, 11, 6, 7, 9, 3); $greedy = new \drupol\phpartition\Algorithm\Greedy(); $greedy->setData($data); $greedy->setSize(3); $result = $greedy->getResult(); // $result is: /* * Array ( [0] => Array ( [0] => 9 [1] => 5 [2] => 1 ) [1] => Array ( [0] => 7 [1] => 6 [2] => 3 ) [2] => Array ( [0] => 11 [1] => 5 ) ) */ $simple = new \drupol\phpartition\Algorithm\Simple(); $simple->setData($data); $simple->setSize(3); $result = $simple->getResult(); // $result is: /* * Array ( [0] => Array ( [0] => 5 [1] => 11 ) [1] => Array ( [0] => 1 [1] => 7 [2] => 3 ) [2] => Array ( [0] => 5 [1] => 6 [2] => 9 ) ) */
You may also pass objects or array but then, you'll have to define how to access their value.
<?php include "./vendor/autoload.php"; $data = array( array( 'item' => 'anything A', 'weight' => 1, ), array( 'item' => 'anything B', 'weight' => 2, ), array( 'item' => 'anything C', 'weight' => 3, ), array( 'item' => 'anything D', 'weight' => 4, ), ); $greedy = new \drupol\phpartition\Algorithm\Greedy(); $greedy->setData($data); $greedy->setSize(2); $greedy->setItemAccessCallback(function($item) { return $item['weight']; }); $result = $greedy->getResult(); // $result is /* * Array ( [0] => Array ( [0] => Array ( [item] => anything C [weight] => 3 ) [1] => Array ( [item] => anything B [weight] => 2 ) ) [1] => Array ( [0] => Array ( [item] => anything D [weight] => 4 ) [1] => Array ( [item] => anything A [weight] => 1 ) ) ) */
It's also possible to mix the type of object to partition.
TODO
- Implement Complete Karmarkar-Karp (CKK) algorithm,
- Documentation.
drupol/phpartition 适用场景与选型建议
drupol/phpartition 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.49k 次下载、GitHub Stars 达 9, 最近一次更新时间为 2016 年 12 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「math」 「numbers」 「statistics」 「Partition」 「greedy」 「karmarkar」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 drupol/phpartition 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 drupol/phpartition 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 drupol/phpartition 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Helper to handle stats table with multiple formatter
LaTeX formula to PNG
The "View Counter" bundle
SPSS is a php-based implementation of IBM SPSS Statistics Standard. (Read/write SPSS, PSPP .sav files)
TYPO3 View-Statistics by coding.ms: Logs frontend actions in TYPO3 and displays them in a backend module. It tracks page views, news, downloads, and objects such as products or real estate, while custom objects can be configured via TypoScript. Frontend logins, login duration, user ID, IP address, a
Simple, chainable calculation library.
统计信息
- 总下载量: 4.49k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 10
- 点击次数: 8
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0
- 更新时间: 2016-12-17