资源描述:
《基于扫描算法的企业配送路线优化》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、基于打描算法的企业配送路线优化DECLARE@tempOTABLE(corpidINT,TcountDECIMAL(19,4))DECLARE@templTABLE(corpidINT,FcorpidINT^distanceDECIMAL(19,4))DECLARE@temp2TABLE(corpidINT,FcorpidINTJdistanceDECIMAL(19,4)JdistancelDECIMAL(19,4),TcountDECIMAL(19,4),TcountlDECIMAL(19,4)JcornerDECIMAL(19,4))DECLARE@temp3TABLE(CarNumINT
2、,TloadDECIMAL(19,4)JdistanceDECIMAL(19,4))DECLARE@temp4TABLE(CarNumINT,corpidINT^corpidINT,TcountDECIMAL(19,4)JdistanceDECIMAL(19,4)JcornerDECIMAL(19,4),numINT)DECLARE@countINT,@countlINT,@count2INT,@corpidINT,@FcorpidINT,@RcorpidINT,@HcorpidINT,@CarNumINT,@TloadDECIMAL(19,4),@TcountDECIMAL(19,4),@T
3、distaneeDECIMAL(19,4),@TdjstancelDECIMAL(19,4),@numINT,@TcounsumDECIMAL(19,4),@TloadsumDECIMAL(19,4),@TcornerDECIMAL(19,4)SET@count=0SET@countl=50一门店及配送数量WHILE@count<=@countlBEGININSERTINTO@tempOSELECT@count,30+RAND()*30-RAND()*100-门店配送数最SET@count=@count+lEND-车辆信息SET@count2=1WHILE@count2<=10BEGININS
4、ERTINTO@temp3SELECT@count2,300一负载,300-里程SET@count2=@count2+lEND-店间距WHILE@count>=0BEGINSET@countl=50WHILE@countl>=0BEGININSERTINTO@templSELECTtl.corpidzt2.corpid,20+RAND()*40-RAND()*100一店间距FROM@temp0tl,@temp012WHEREtl.corpid5、ENDSET@count=@count-1END-店间距合并角度表INSERTINTO@temp2SELECTtl.Fcorpid,t2.Fcorpid,tl.Tdistance+t2.Tdistance-t3.Tdistance一节约里程数,tl.Tdistance+t2.Tdistance+t3.Tdistance"里程增量,tO.Tcount,tOO.Teount,(tl.Tdistance*tl.Tdistance+t2.Tdistance*t2.Tdistance・t3.Tdistance*t3.Tdistance)/(2*tl.Tdistance*t2.Tdistance)-求两个
6、门店到中心角度的cosFROM@templtl,@templt2,@templt3,@tempOtO,@tempOtOOWHEREtl.corpid=0ANDt2.corpid=0ANDtl.Fcorpid0"保证三点成三角形ANDtO.corpid=tl.FcorpidANDtOO.corpid=t2.FcorpidAND(tl.Tdistance*tl.Tdistance+t2.Tdistan
7、ce*t2.Tdistance・t3.Tdistance*t3.Tdistance)/(2*tl.Tdistance*t2.Tdistance)>=-1-<=1803三点间直线AND(tl.Tdistance*tl.Tdistance+t2.Tdistance*t2.Tdistance・t3.Tdistance*t3.Tdistance)/(2*tl.Tdistance*t2.Tdistance)