litvinenko/combinatorics

此软件包最新版本(v0.0.1)没有提供许可信息。

生成组合集和解决一些组合问题的类

v0.0.1 2015-09-29 06:54 UTC

This package is not auto-updated.

Last update: 2024-10-02 10:22:23 UTC


README

此代码可以

  • 生成排列以及排列的一些特殊情况
  • 通过分支定界法和束搜索方法解决组合问题

PDP问题

主接口类是Pdp.php。使用https://bitbucket.org/absent1706/grebennik-pdp-python检查3D约束。使用https://github.com/absent1706/common_php_app处理事件观察者模式。使用https://github.com/absent1706/extended_varien_object作为所有对象的基础

####使用示例

require_once 'vendor/autoload.php';

$xmlConfigFile  = __DIR__.'/config.xml';
$paramsFile = __DIR__.'/data/params.json';

\Litvinenko\Common\App::init($xmlConfigFile);

$launcher = new \Litvinenko\Combinatorics\Pdp\Pdp;
$params     = json_decode(file_get_contents($paramsFile), true);

echo json_encode($launcher->getSolution($params['data'], $params['config']));

####输入参数示例(如果输入JSON)

{
   "method": "gen", // hardcoded to use one solution method for now
   "config": { // config section. sets how to solve pdp problem
      "check_final_loading": false, // check 3D constraints for finally generated 'best' paths
      "check_transitional_loading_probability": "20", // probability of checking 3D constraints in partial paths
      "python_file": "/home/litvinenko/www/pdp-php/public_html/demo/pdphelper/pdphelper.py", // where script for checking 3D constraints is located
      "precise": "5", // beam width in % of generated path variants
      "weight_capacity": "1000", // vehicle weight_capacity
      "load_area": { // vehicle load area size
         "x": "100",
         "y": "100",
         "z": "100"
      }
   },
   "data": {
      "depot": [
         "200", // depot x
         "200" // depot y
      ],
      "points": {
        "1": [        // point id. Points with id < <point count> (first 2 points in this example) will be treated as pickups, other half of points - as deliveries
            "117463", // point X coord
            "476120", // point Y coord
            "27",     // point box size x (for pickups)
            "38",     // point box size y (for pickups)
            "47",     // point box size z (for pickups)
            "38"      // point weight (for pickups)
        ],
         "2": [
            "400.39",
            "152.36",
            "9.37",
            "9.62",
            "9.34",
            "13.43"
         ],
         "3": [
            "345.42",
            "414.24",
            null,
            null,
            null,
            null
         ],
         "4": [
            "10.35",
            "17.68",
            null,
            null,
            null,
            null
         ]
      }
   }
}

基于输入点,在Litvinenko\Combinatorics\Pdp\Pdp::createPointsFromArray方法中创建点对象。为了正确创建PDP对,点必须有从1到2N的ID,其中N是PDP对的数目。编号为i(i<N)的取货将关联到编号i+N的配送。例如,对于2个PDP对,我们有2个取货(ID为1和2)和2个配送(ID为3和4)。PDP对为:1-3和2-4。因此,我们必须从一个点1送到点3,并从点2送到点4。

应用程序的XML配置

<?xml version="1.0"?>
<config>
    <events>
<!--         <new_path_generated>
            <observers>
                <solutioninfocollector_new_path_generated>
                    <class>\SolutionInfoCollector</class>
                    <method>logGeneratedPath</method>
                    <singleton>1</singleton>
                </solutioninfocollector_new_path_generated>
            </observers>
        </new_path_generated>
        <cant_load>
            <observers>
                <solutioninfocollector_cant_load>
                    <class>\SolutionInfoCollector</class>
                    <method>logNotLoadedPath</method>
                    <singleton>1</singleton>
                </solutioninfocollector_cant_load>
            </observers>
        </cant_load> -->
        <point_add_before>
            <observers>
                <precise_generation_solver_point_add_before>
                    <class>\Litvinenko\Combinatorics\Pdp\Solver\PreciseGenerationSolver</class>
                    <method>canLoadObserver</method>
                    <singleton>1</singleton>
                </precise_generation_solver_point_add_before>
            </observers>
        </point_add_before>
     </events>
    <developer_mode>1</developer_mode>
</config>