资源简介
该资源为2018年5月份京东举办的物流车辆调度比赛的测试代码,该比赛的参与者来时与全球500所高等院校,值得你学习!是Python写的
代码片段和文件信息
# -*- coding: utf-8 -*-
“““
Created on Sat Jul 07 23:24:28 2018
@author: jiuxia
“““
import random math sys
import matplotlib.pyplot as plt #
from copy import deepcopy
import copy
import pandas as pd
data = pd.Dataframe()
result = pd.Dataframe()
distance = pd.read_table(‘input_distance_time.txt‘sep = ‘‘)
for c in [0]:
for i in range(3):
data1_title = str(c) +‘_‘+str(i)+‘.xlsx‘
result_title = ‘result_‘ + str(c) +‘_‘ +str(i) + ‘.csv‘
data1 = pd.read_excel(data1_title)
result1 = pd.read_csv(result_title)
data = data.append(data1)
result = result.append(result1)
data.set_index([‘ID‘]inplace = True)
station = []
for i in data.index:
if i>1000 and i not in station:
station.append(i)
print(station)
result = result[‘经过的点‘]
result = pd.Series.to_frame(result)
node =[]
station_used = []
for i in range(len(result)):
each = result.iloc[i0]
each = each[1:len(each)-1]
each = each.split(‘‘)
each = [int(x) for x in each]
node.append(each)
print(node)
for i in range(len(node)):
for j in range(len(node[i])):
if node[i][j]>1000:
station_used.append(node[i][j])
if station_used.count(node[i][j])>1:
for s in station:
if s not in station_used:
station_used[len(station_used)-1] = s
node[i][j] = s
break
cus_data = data[data[‘type‘]==2]
Node = [0] +list(cus_data.index) + station_used
all_Node = [0] +list(cus_data.index) + station
print(Node)
final_data = pd.Dataframe()
final_all_data = pd.Dataframe()
for i in Node:
final_data = final_data.append(data.ix[i])
final_data.drop_duplicates(subset=None keep=‘first‘ inplace=True)
for i in all_Node:
final_all_data = final_all_data.append(data.ix[i])
final_all_data.drop_duplicates(subset=None keep=‘first‘ inplace=True)
d_1 = pd.merge(final_all_datadistancehow = ‘inner‘left_on = ‘ID‘ right_on = ‘from_node‘)
d_2 = pd.merge(final_all_datad_1how = ‘inner‘left_on = ‘ID‘right_on = ‘to_node‘)
d_2 = d_2[[‘from_node‘‘to_node‘‘distance‘‘spend_tm‘]]
test_data = final_all_data
test_dist = d_2
DEBUG = False
initial = []
l = []
for i in range(29):
l.append(i)
for i in Node:
each = []
random.shuffle(l)
for j in l:
each = each+node[j]
each.append(0)
initial.append(each)
geneNum =200 # 种群数量
generationNum = 1000 # 迭代次数
CENTER = 0 # 配送中心
HUGE = 999999999999
VARY = 0.5 # 变异几率
n = len(test_data[test_data[‘type‘] == 2]) # 客户点数量
print(n)
m = len(test_data[test_data[‘type‘] == 3]) # 换电站数量
k =999 # 车辆数量
Q = 2.5 # 额定载重量 t
Q_V = 16.0
dis = 120000 # 续航里程 m
costPerKilo = 0.014 # 油价
epu = 0.04 # 早到惩罚成本
lpu = 999999999999 # 晚到惩罚成本
X = {}
Y = {}
t_w ={}
t_v ={}
eh = {}
lh = {}
h = {}
Distance = {}
Time = {}
for i in all_Node:
#坐标
X[i] = test_data.loc[i‘lng‘]
Y[i] = test_data.loc[i‘lat‘]
#需求量
t_w[i] = te
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-11-17 14:18 GOC-EVRPTW-master\
目录 0 2018-11-17 14:18 GOC-EVRPTW-master\GA\
文件 16457 2018-11-17 14:18 GOC-EVRPTW-master\GA\0_0.xlsx
文件 15640 2018-11-17 14:18 GOC-EVRPTW-master\GA\0_1.xlsx
文件 15459 2018-11-17 14:18 GOC-EVRPTW-master\GA\0_2.xlsx
文件 17793 2018-11-17 14:18 GOC-EVRPTW-master\GA\GA.py
文件 30309734 2018-11-17 14:18 GOC-EVRPTW-master\GA\input_distance_time.txt
文件 1637 2018-11-17 14:18 GOC-EVRPTW-master\GA\result_0_0.csv
文件 1743 2018-11-17 14:18 GOC-EVRPTW-master\GA\result_0_1.csv
文件 1815 2018-11-17 14:18 GOC-EVRPTW-master\GA\result_0_2.csv
文件 1100 2018-11-17 14:18 GOC-EVRPTW-master\README.md
目录 0 2018-11-17 14:18 GOC-EVRPTW-master\VRP_SubRegion\
文件 549 2018-11-17 14:18 GOC-EVRPTW-master\VRP_SubRegion\allcmd.sh
文件 501 2018-11-17 14:18 GOC-EVRPTW-master\VRP_SubRegion\checktask.sh
文件 444 2018-11-17 14:18 GOC-EVRPTW-master\VRP_SubRegion\clearout.sh
文件 6068 2018-11-17 14:18 GOC-EVRPTW-master\VRP_SubRegion\cluster.py
文件 691 2018-11-17 14:18 GOC-EVRPTW-master\VRP_SubRegion\copymdoel.sh
文件 2356 2018-11-17 14:18 GOC-EVRPTW-master\VRP_SubRegion\group.py
文件 46 2018-11-17 14:18 GOC-EVRPTW-master\VRP_SubRegion\host.txt
目录 0 2018-11-17 14:18 GOC-EVRPTW-master\VRP_SubRegion\input\
文件 30309734 2018-11-17 14:18 GOC-EVRPTW-master\VRP_SubRegion\input\input_distance_time.txt
文件 80550 2018-11-17 14:18 GOC-EVRPTW-master\VRP_SubRegion\input\input_node.xlsx
文件 9230 2018-11-17 14:18 GOC-EVRPTW-master\VRP_SubRegion\input\m.xlsx
文件 17691 2018-11-17 14:18 GOC-EVRPTW-master\VRP_SubRegion\model.sh
文件 3383 2018-11-17 14:18 GOC-EVRPTW-master\VRP_SubRegion\once.sh
文件 385 2018-11-17 14:18 GOC-EVRPTW-master\VRP_SubRegion\pid
文件 291 2018-11-17 14:18 GOC-EVRPTW-master\VRP_SubRegion\result.txt
文件 182 2018-11-17 14:18 GOC-EVRPTW-master\VRP_SubRegion\run.sh
文件 387 2018-11-17 14:18 GOC-EVRPTW-master\VRP_SubRegion\runstep2.sh
文件 564 2018-11-17 14:18 GOC-EVRPTW-master\VRP_SubRegion\runstep3.sh
文件 7097 2018-11-17 14:18 GOC-EVRPTW-master\VRP_SubRegion\solver.py
............此处省略3个文件信息
相关资源
- [全套55讲]鱼C论坛小甲鱼Python课后题
- 《Python数据挖掘入门与实践 》 作者:
- Python-3.8.1.tgz
- 基于python编写的串口调试助手,内含
- 物体检测识别python源代码
- python_x64_v3.8.5.zip
- python-3.5.2-amd64.exe
- Python学习手册(第5版)英文版
- Python编程:从入门到实践原版高清P
- pywin32-221.win-py3.7 for x86 and x64
- python课件
- python+html桌面应用
- Python语言及其应用(超清版)带书签
- 《Python 3数据分析与机器学习实战》自
- 《Python 3数据分析与机器学习实战》随
- python数据科学手册 真正的pdf版
- win10+anaconda3+python3 mnist训练代码
- 基于opencvpython的全景拼接
- 从零开始学Python网络爬虫源代码+教学
- pywin32 for python 2.7 32位和64位
- Python强化学习实战:应用OpenAI Gym和
- python+freetype+opencv 中文汉字显示 项目
- wxPython几本好书
- python cad
- python 做的串口助手
- Django restful web services the easiest way to
- 利用Python做数据分析.mobi
- 基于python的车牌识别黄绿蓝都可Lice
- Python机器学习Python machine learning中英合
- 精通Python设计模式 高清完整.pdf版+源
评论
共有 条评论