资源简介
粒子群算法 实现 最短路径,解决TSL多旅行商问题,以此为基础解决VRP问题
代码片段和文件信息
package algoProject;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class PSOSolution {
public static final long serialVersionUID = 1L;
public static final int VEHICLE_COUNT = 30;
public static final int MAX_VELOCITY = 4;
public static final int MAX_ITERATION = 100;
private static ArrayList vehicles = new ArrayList();
public static ArrayList stations = new ArrayList();
public static final int STATION_COUNT = 10;
public static final double TARGET = 86.63;
public static int X[] = new int[STATION_COUNT];
public static int Y[] = new int[STATION_COUNT];
public List> pathList;
public List finalList;
public void initializePath()
{
for (int i = 0; i < STATION_COUNT; i++) {
X[i] = new Random().nextInt(30);
Y[i] = new Random().nextInt(30);
}
for (int i = 0; i < STATION_COUNT; i++) {
VisitingStations station = new VisitingStations();
station.x(X[i]);
station.y(Y[i]);
stations.add(station);
}
return;
}
public void executePSO() {
Vehicle vehicle = null;
int iterationNo = 0;
boolean done = false;
pathList = new ArrayList<>();
initialize();
while (!done) {
if (iterationNo < MAX_ITERATION) {
for (int i = 0; i < VEHICLE_COUNT; i++) {
List sublist = new ArrayList<>();
vehicle = vehicles.get(i);
System.out.print(“Route: “);
for (int j = 0; j < STATION_COUNT; j++) {
System.out.print(vehicle.getStationData(j) + “ “);
sublist.add(vehicle.getStationData(j));
}
findTotalDistance(i);
System.out.print(“Distance: “ + vehicle.getVehicleBest() + “\n“);
if (vehicle.getVehicleBest() <= TARGET) {
done = true;
}
pathList.add(sublist);
}
bubbleSort();
fitnessFunction();
updatevehicles();
System.out.println(“iterationNo number: “ + iterationNo);
iterationNo++;
} else {
done = true;
}
}
return;
}
public void initialize() {
for (int i = 0; i < VEHICLE_COUNT; i++) {
Vehicle newVehicle = new Vehicle(STATION_COUNT);
for (int j = 0; j < STATION_COUNT; j++) {
newVehicle.setStationData(j j);
}
vehicles.add(newVehicle);
for (int j = 0; j < 10; j++) {
randomStationArrange(vehicles.indexOf(newVehicle));
}
findTotalDistance(vehicles.indexOf(newVehicle));
}
return;
}
private static void randomStationArrange(final int index) {
int stationA = new Random().nextInt(STATION_COUNT);
int stationB = 0;
boolean done = false;
while (!done) {
stationB = new Random().nextInt(STATION_COUNT);
if (stationB != stationA) {
done = true;
}
}
int temp = vehicles.get(index).getStationData(stationA);
vehicles.get(index).setStationData(stationA vehicles.get(index).getStationData(stationB));
vehicles.get(index).setStationData(stati
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-05-10 02:04 vehicle-path-optimization-using-pso-master\
文件 7172 2017-05-10 02:04 vehicle-path-optimization-using-pso-master\PSOSolution.java
文件 37 2017-05-10 02:04 vehicle-path-optimization-using-pso-master\README.md
文件 4422 2017-05-10 02:04 vehicle-path-optimization-using-pso-master\Simulation.java
文件 1147 2017-05-10 02:04 vehicle-path-optimization-using-pso-master\Vehicle.java
文件 406 2017-05-10 02:04 vehicle-path-optimization-using-pso-master\VisitingStations.java
- 上一篇:计算机网络谢希仁第七版课后答案完整版
- 下一篇:Axure手机开发必用的设计素材
相关资源
- MOPSO.zip124181
- 改进的自适应遗传算法和粒子群算法
- psoc 开发额: 多功能步进马达驱动器
- 基于粒子群算法优化Spiking神经网络
- 模拟退火SA、遗传算法GA、粒子群优化
- SVM实现负荷预测,其中包含基本SVM,
- 一种更简化而高效的粒子群优化算法
- 基于粒子群优化神经网络的程序
- vrptw问题代码
- 粒子群优化粒子滤波方法
- 基于改进离散粒子群算法的电力系统
- VRP问题蚁群算法
- 混合粒子群和引力搜索算法代码
- 工业调度粒子群算法
- PSO-BP神经网络论文
- 粒子群算法(详细的算法介绍讲解及
- VRP代码车辆路径问题 供参考
- 车辆路径问题 CVRP
- linux Qt局域网聊天
- PSO+SA算法 (粒子群和模拟退火算法的
- 粒子群多目标优化
- epson1390清零软件新版中文专业版
- 智能优化算法--粒子群算法应用代码
- 基于PSO移动机器人路径规划算法
- 基于粒子群算法的机组组合计算
- 基于PSO-SVM负荷预测
- 自适应多目标粒子群优化器AMOPSO
- 二元粒子群算法.zip
- 粒子群神经网络混合算法在负荷预测
- 复化simpson公式求积分
评论
共有 条评论