智能分单算法

算法描述

```public class BusinessmenAndOrder {

private String id;//job标号
private String orderx;//订单坐标x
private String ordery;//订单坐标y

}

this.id=id;
this.orderx=orderx;
this.ordery=ordery;
}

public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
}
}
}
}
public String getOrderx() {
return orderx;
}
public void setOrderx(String orderx) {
this.orderx = orderx;
}
public String getOrdery() {
return ordery;
}
public void setOrdery(String ordery) {
this.ordery = ordery;
}

}```

```// 得到取件坐标和送达坐标（相当于商家和订单）

```public class Driver {
private String driverId;//骑士编号
private String driverx;//骑士坐标x
private String drivery;//骑士坐标y
public Driver(){

}
public Driver(String driverId,String driverx,String drivery){
this.driverId=driverId;
this.driverx=driverx;
this.drivery=drivery;
}
public String getDriverId() {
return driverId;
}
public void setDriverId(String driverId) {
this.driverId = driverId;
}
public String getDriverx() {
return driverx;
}
public void setDriverx(String driverx) {
this.driverx = driverx;
}
public String getDrivery() {
return drivery;
}
public void setDrivery(String drivery) {
this.drivery = drivery;
}
}```

```// 模拟骑士
List<Driver> driveList = new ArrayList<Driver>();
Driver driver1 = new Driver("driveA", "137.50", "575.78");
Driver driver2 = new Driver("driveB", "151.04", "534.10");
Driver driver3 = new Driver("driveC", "137.28", "558.01");
Driver driver4 = new Driver("driveD", "127.41", "634.78");
Driver driver5 = new Driver("driveE", "46.76", "285.75");
Driver driver6 = new Driver("driveF", "176.76", "485.75");
Driver driver7 = new Driver("driveG", "386.76", "405.75");
Driver driver8 = new Driver("driveH", "246.76", "685.75");

```List<DistributionSep> distList = new ArrayList<DistributionSep>();
distList = autoSeperateOrder(baoList, driveList);
for (DistributionSep distribution : distList) {
System.out.println("配送人员 "+distribution.getDriverName());
List<OrderSort> orderSet = distribution.getDist();
for (OrderSort order : orderSet) {
System.out.println(order.getOrder() + " " + order.getPors() + " " + order.getBussinessOrder());
}
}```

结果查看

```2017-06-30 14:49:38,888 INFO  [main] problem.VehicleRoutingProblem - setup problem: [fleetSize=FINITE][#jobs=40][#vehicles=8][#vehicleTypes=1][transportCost=[name=crowFlyCosts]][activityCosts=com.graphhopper.jsprit.core.problem.cost.WaitingTimeCosts@47d90b9e]
2017-06-30 14:49:38,970 INFO  [main] algorithm.VehicleRoutingAlgorithm - algorithm starts: [maxIterations=2000]
2017-06-30 14:49:38,972 INFO  [main] algorithm.InsertionInitialSolutionFactory - create initial solution
2017-06-30 14:49:39,823 INFO  [main] algorithm.VehicleRoutingAlgorithm - iterations start
2017-06-30 14:49:39,825 INFO  [main] algorithm.VehicleRoutingAlgorithm\$Counter - iterations 1
2017-06-30 14:49:39,843 INFO  [main] algorithm.VehicleRoutingAlgorithm\$Counter - iterations 2
2017-06-30 14:49:39,910 INFO  [main] algorithm.VehicleRoutingAlgorithm\$Counter - iterations 4
2017-06-30 14:49:40,032 INFO  [main] algorithm.VehicleRoutingAlgorithm\$Counter - iterations 8
2017-06-30 14:49:40,142 INFO  [main] algorithm.VehicleRoutingAlgorithm\$Counter - iterations 16
2017-06-30 14:49:41,014 INFO  [main] algorithm.VehicleRoutingAlgorithm\$Counter - iterations 32
2017-06-30 14:49:41,194 INFO  [main] algorithm.VehicleRoutingAlgorithm\$Counter - iterations 64
2017-06-30 14:49:41,728 INFO  [main] algorithm.VehicleRoutingAlgorithm\$Counter - iterations 128
2017-06-30 14:49:42,439 INFO  [main] algorithm.VehicleRoutingAlgorithm\$Counter - iterations 256
2017-06-30 14:49:43,599 INFO  [main] algorithm.VehicleRoutingAlgorithm\$Counter - iterations 512
2017-06-30 14:49:45,723 INFO  [main] algorithm.VehicleRoutingAlgorithm\$Counter - iterations 1024
2017-06-30 14:49:49,703 INFO  [main] algorithm.VehicleRoutingAlgorithm - iterations end at 2000 iterations
2017-06-30 14:49:49,703 INFO  [main] algorithm.VehicleRoutingAlgorithm - took 10.732 seconds```

```+--------------------------------------------------------------------------------------------------------------------------------+
| detailed solution                                                                                                              |
+---------+----------------------+-----------------------+-----------------+-----------------+-----------------+-----------------+
| route   | vehicle              | activity              | job             | arrTime         | endTime         | costs           |
+---------+----------------------+-----------------------+-----------------+-----------------+-----------------+-----------------+
| 1       | driveA               | start                 | -               | undef           | 0               | 0               |
| 1       | driveA               | pickupShipment        | 商家订单25          | 4               | 4               | 4               |
| 1       | driveA               | deliverShipment       | 商家订单25          | 9               | 9               | 9               |
| 1       | driveA               | pickupShipment        | 商家订单21          | 20              | 20              | 20              |
| 1       | driveA               | pickupShipment        | 商家订单23          | 22              | 22              | 22              |
| 1       | driveA               | pickupShipment        | 商家订单22          | 30              | 30              | 30              |
| 1       | driveA               | pickupShipment        | 商家订单20          | 34              | 34              | 34              |
| 1       | driveA               | deliverShipment       | 商家订单22          | 38              | 38              | 38              |
| 1       | driveA               | deliverShipment       | 商家订单23          | 38              | 38              | 38              |
| 1       | driveA               | pickupShipment        | 商家订单18          | 70              | 70              | 70              |
| 1       | driveA               | deliverShipment       | 商家订单18          | 82              | 82              | 82              |
| 1       | driveA               | deliverShipment       | 商家订单21          | 102             | 102             | 102             |
| 1       | driveA               | deliverShipment       | 商家订单20          | 123             | 123             | 123             |
| 1       | driveA               | end                   | -               | 123             | undef           | 123             |
+---------+----------------------+-----------------------+-----------------+-----------------+-----------------+-----------------+
| 2       | driveB               | start                 | -               | undef           | 0               | 0               |
| 2       | driveB               | pickupShipment        | 商家订单7           | 24              | 24              | 24              |
| 2       | driveB               | deliverShipment       | 商家订单7           | 42              | 42              | 42              |
| 2       | driveB               | pickupShipment        | 商家订单19          | 68              | 68              | 68              |
| 2       | driveB               | deliverShipment       | 商家订单19          | 70              | 70              | 70              |
| 2       | driveB               | pickupShipment        | 商家订单15          | 96              | 96              | 96              |
| 2       | driveB               | deliverShipment       | 商家订单15          | 104             | 104             | 104             |
| 2       | driveB               | end                   | -               | 104             | undef           | 104             |
+---------+----------------------+-----------------------+-----------------+-----------------+-----------------+-----------------+
| 3       | driveC               | start                 | -               | undef           | 0               | 0               |
| 3       | driveC               | pickupShipment        | 商家订单1           | 4               | 4               | 4               |
| 3       | driveC               | pickupShipment        | 商家订单28          | 9               | 9               | 9               |
| 3       | driveC               | deliverShipment       | 商家订单1           | 17              | 17              | 17              |
| 3       | driveC               | deliverShipment       | 商家订单28          | 21              | 21              | 21              |
| 3       | driveC               | pickupShipment        | 商家订单12          | 26              | 26              | 26              |
| 3       | driveC               | pickupShipment        | 商家订单5           | 27              | 27              | 27              |
| 3       | driveC               | pickupShipment        | 商家订单6           | 35              | 35              | 35              |
| 3       | driveC               | pickupShipment        | 商家订单8           | 58              | 58              | 58              |
| 3       | driveC               | pickupShipment        | 商家订单11          | 61              | 61              | 61              |
| 3       | driveC               | deliverShipment       | 商家订单8           | 69              | 69              | 69              |
| 3       | driveC               | deliverShipment       | 商家订单6           | 73              | 73              | 73              |
| 3       | driveC               | deliverShipment       | 商家订单11          | 87              | 87              | 87              |
| 3       | driveC               | pickupShipment        | 商家订单24          | 101             | 101             | 101             |
| 3       | driveC               | pickupShipment        | 商家订单10          | 119             | 119             | 119             |
| 3       | driveC               | pickupShipment        | 商家订单3           | 127             | 127             | 127             |
| 3       | driveC               | pickupShipment        | 商家订单29          | 157             | 157             | 157             |
| 3       | driveC               | deliverShipment       | 商家订单29          | 192             | 192             | 192             |
| 3       | driveC               | deliverShipment       | 商家订单10          | 415             | 415             | 415             |
| 3       | driveC               | deliverShipment       | 商家订单5           | 418             | 418             | 418             |
| 3       | driveC               | deliverShipment       | 商家订单24          | 423             | 423             | 423             |
| 3       | driveC               | deliverShipment       | 商家订单12          | 425             | 425             | 425             |
| 3       | driveC               | deliverShipment       | 商家订单3           | 432             | 432             | 432             |
| 3       | driveC               | end                   | -               | 432             | undef           | 432             |
+---------+----------------------+-----------------------+-----------------+-----------------+-----------------+-----------------+
| 4       | driveD               | start                 | -               | undef           | 0               | 0               |
| 4       | driveD               | pickupShipment        | 商家订单27          | 0               | 0               | 0               |
| 4       | driveD               | pickupShipment        | 商家订单9           | 10              | 10              | 10              |
| 4       | driveD               | pickupShipment        | 商家订单13          | 55              | 55              | 55              |
| 4       | driveD               | deliverShipment       | 商家订单27          | 66              | 66              | 66              |
| 4       | driveD               | deliverShipment       | 商家订单9           | 78              | 78              | 78              |
| 4       | driveD               | pickupShipment        | 商家订单14          | 107             | 107             | 107             |
| 4       | driveD               | pickupShipment        | 商家订单30          | 132             | 132             | 132             |
| 4       | driveD               | deliverShipment       | 商家订单14          | 182             | 182             | 182             |
| 4       | driveD               | deliverShipment       | 商家订单13          | 233             | 233             | 233             |
| 4       | driveD               | pickupShipment        | 商家订单37          | 596             | 596             | 596             |
| 4       | driveD               | deliverShipment       | 商家订单30          | 760             | 760             | 760             |
| 4       | driveD               | pickupShipment        | 商家订单40          | 768             | 768             | 768             |
| 4       | driveD               | pickupShipment        | 商家订单39          | 768             | 768             | 768             |
| 4       | driveD               | pickupShipment        | 商家订单38          | 768             | 768             | 768             |
| 4       | driveD               | pickupShipment        | 商家订单2           | 971             | 971             | 971             |
| 4       | driveD               | deliverShipment       | 商家订单40          | 1255            | 1255            | 1255            |
| 4       | driveD               | pickupShipment        | 商家订单31          | 1325            | 1325            | 1325            |
| 4       | driveD               | deliverShipment       | 商家订单39          | 1734            | 1734            | 1734            |
| 4       | driveD               | deliverShipment       | 商家订单38          | 1875            | 1875            | 1875            |
| 4       | driveD               | deliverShipment       | 商家订单2           | 1936            | 1936            | 1936            |
| 4       | driveD               | deliverShipment       | 商家订单37          | 1972            | 1972            | 1972            |
| 4       | driveD               | deliverShipment       | 商家订单31          | 2017            | 2017            | 2017            |
| 4       | driveD               | end                   | -               | 2017            | undef           | 2017            |
+---------+----------------------+-----------------------+-----------------+-----------------+-----------------+-----------------+
| 5       | driveE               | start                 | -               | undef           | 0               | 0               |
| 5       | driveE               | pickupShipment        | 商家订单35          | 119             | 119             | 119             |
| 5       | driveE               | pickupShipment        | 商家订单34          | 192             | 192             | 192             |
| 5       | driveE               | pickupShipment        | 商家订单33          | 271             | 271             | 271             |
| 5       | driveE               | deliverShipment       | 商家订单35          | 382             | 382             | 382             |
| 5       | driveE               | pickupShipment        | 商家订单36          | 559             | 559             | 559             |
| 5       | driveE               | deliverShipment       | 商家订单36          | 628             | 628             | 628             |
| 5       | driveE               | deliverShipment       | 商家订单34          | 921             | 921             | 921             |
| 5       | driveE               | deliverShipment       | 商家订单33          | 993             | 993             | 993             |
| 5       | driveE               | end                   | -               | 993             | undef           | 993             |
+---------+----------------------+-----------------------+-----------------+-----------------+-----------------+-----------------+
| 6       | driveF               | start                 | -               | undef           | 0               | 0               |
| 6       | driveF               | pickupShipment        | 商家订单26          | 43              | 43              | 43              |
| 6       | driveF               | deliverShipment       | 商家订单26          | 81              | 81              | 81              |
| 6       | driveF               | pickupShipment        | 商家订单16          | 133             | 133             | 133             |
| 6       | driveF               | pickupShipment        | 商家订单17          | 166             | 166             | 166             |
| 6       | driveF               | deliverShipment       | 商家订单17          | 237             | 237             | 237             |
| 6       | driveF               | pickupShipment        | 商家订单4           | 249             | 249             | 249             |
| 6       | driveF               | deliverShipment       | 商家订单16          | 306             | 306             | 306             |
| 6       | driveF               | deliverShipment       | 商家订单4           | 329             | 329             | 329             |
| 6       | driveF               | end                   | -               | 329             | undef           | 329             |
+---------+----------------------+-----------------------+-----------------+-----------------+-----------------+-----------------+
| 7       | driveG               | start                 | -               | undef           | 0               | 0               |
| 7       | driveG               | pickupShipment        | 商家订单32          | 65              | 65              | 65              |
| 7       | driveG               | deliverShipment       | 商家订单32          | 204             | 204             | 204             |
| 7       | driveG               | end                   | -               | 204             | undef           | 204             |
+--------------------------------------------------------------------------------------------------------------------------------+```

```配送人员 driveA
1 取 商家订单25
2 送 商家订单25
3 取 商家订单21
4 取 商家订单23
5 取 商家订单22
6 取 商家订单20
7 送 商家订单22
8 送 商家订单23
9 取 商家订单18
10 送 商家订单18
11 送 商家订单21
12 送 商家订单20

1 取 商家订单7
2 送 商家订单7
3 取 商家订单19
4 送 商家订单19
5 取 商家订单15
6 送 商家订单15

1 取 商家订单1
2 取 商家订单28
3 送 商家订单1
4 送 商家订单28
5 取 商家订单12
6 取 商家订单5
7 取 商家订单6
8 取 商家订单8
9 取 商家订单11
10 送 商家订单8
11 送 商家订单6
12 送 商家订单11
13 取 商家订单24
14 取 商家订单10
15 取 商家订单3
16 取 商家订单29
17 送 商家订单29
18 送 商家订单10
19 送 商家订单5
20 送 商家订单24
21 送 商家订单12
22 送 商家订单3

1 取 商家订单27
2 取 商家订单9
3 取 商家订单13
4 送 商家订单27
5 送 商家订单9
6 取 商家订单14
7 取 商家订单30
8 送 商家订单14
9 送 商家订单13
10 取 商家订单37
11 送 商家订单30
12 取 商家订单40
13 取 商家订单39
14 取 商家订单38
15 取 商家订单2
16 送 商家订单40
17 取 商家订单31
18 送 商家订单39
19 送 商家订单38
20 送 商家订单2
21 送 商家订单37
22 送 商家订单31

1 取 商家订单35
2 取 商家订单34
3 取 商家订单33
4 送 商家订单35
5 取 商家订单36
6 送 商家订单36
7 送 商家订单34
8 送 商家订单33

1 取 商家订单26
2 送 商家订单26
3 取 商家订单16
4 取 商家订单17
5 送 商家订单17
6 取 商家订单4
7 送 商家订单16
8 送 商家订单4

1 取 商家订单32
2 送 商家订单32```

217 篇文章54 人订阅

0 条评论

相关文章

1263

904

581

从MSN退出中国,看本土的SAAS服务

“我最不忍看你，背向我转面。要走的一刻，不必诸多眷恋。” 当腾讯还在“QQ在手，天下我有”恣意扩张的进程上，28日，微软Skype官方向MSN用户发送了一份邮件...

2826

922

知乎320万用户的信息分析与数据可视化

art 1: 动机 作为一个知乎的重度用户，我深深的被知乎社区的高素质群体所吸引，这也是我在微信朋友圈、新浪微博、baidutieba等社区见不到的东西。那么为...

42211

2044

752

3575

1867