資源簡介
求解大規模具有能力約束的車輛路徑問題(Capacitated Vehicle Routing Problem, CVRP)求解大規模具有能力約束的車輛路徑問題(Capacitated Vehicle Routing Problem, CVRP)求解大規模具有能力約束的車輛路徑問題(Capacitated Vehicle Routing Problem, CVRP)求解大規模具有能力約束的車輛路徑問題(Capacitated Vehicle Routing Problem, CVRP)

代碼片段和文件信息
import?java.io.*;
import?java.awt.Point;
/**
?*?CVRPData.java
?*
?*?This?class?reads?in?a?CVRP?data?file?and?provides?“get?methods“?to
?*?access?the?demand?and?distance?information.?It?does?some
?*?parameter?checking?to?make?sure?that?nodes?passed?to?the?get
?*?methods?are?within?the?valid?range.
?*
?*?It?should?be?initialised?by?calling?readFile().?
?*
?*?@author?Tim?Kovacs
?*?@version?20/10/2013
?*/
public?class?CVRPData?{
????/**?The?capacity?that?each?vehicle?has?*/
????public?static?int?VEHICLE_CAPACITY;
????/**?The?number?of?nodes?in?the?fruitybun?CVRP?i.e.?the?depot?and?the?customers?*/
????public?static?int?NUM_NODES;
????/**?This?is?only?used?for?testing.?Normally?the?class?is?initialised?by?calling?readFile()?*/
????public?static?void?main(String[]?dataFileName)?throws?FileNotFoundException?IOException?{
if?(dataFileName.length?!=?1)
????quit(“I?need?exactly?1?argument:?the?name?of?the?data?file?to?read“);
readFile(dataFileName[0]);
????}
????/**?Return?the?demand?for?a?given?node.?*/
????public?static?int?getDemand(int?node)?{
if?(!nodeIsValid(node))?{
????System.err.println(“Error:?demand?for?node?“?+?node?+?
???????“?was?requested?from?getDemand()?but?only?nodes?1..“?+?NUM_NODES?+?“?exist“);
????System.exit(-1);
} ????
return?demand[node];
????}
????????
????/**?Return?the?Euclidean?distance?between?the?two?given?nodes?*/
????public?static?double?getDistance(int?node1?int?node2)?{
if?(!nodeIsValid(node1))?{
????System.err.println(“Error:?distance?for?node?“?+?node1?+?
???????“?was?requested?from?getDistance()?but?only?nodes?1..“?+?NUM_NODES?+?“?exist“);
????System.exit(-1);
} ????
if?(!nodeIsValid(node2))?{
????System.err.println(“Error:?distance?for?node?“?+?node2?+?
???????“?was?requested?from?getDistance()?but?only?nodes?1..“?+?NUM_NODES?+?“?exist“);
????System.exit(-1);
} ????
int?x1?=?coords[node1][X_COORDINATE];
int?y1?=?coords[node1][Y_COORDINATE];
int?x2?=?coords[node2][X_COORDINATE];
int?y2?=?coords[node2][Y_COORDINATE];
//?compute?Euclidean?distance
return?Math.sqrt(Math.pow((x1-x2)2)?+?Math.pow((y1-y2)2));
????//?For?example?the?distance?between?3344?and?4413?is:
????//?33-44?=?-11?and?11^2?=?121
????//?44-13?=?31?and?31^2?=?961
????//?121?+?961?=?1082
????//?The?square?root?of?1082?=?32.893768...
????}????
????//*?Return?the?absolute?co-ordinates?of?the?given?node?*/
????public?static?Point?getLocation(int?node)?{
??????if?(!nodeIsValid(node))?{
System.err.println(“Error:?Request?for?location?of?non-existent?node?“?+?node?+?“.“);
System.exit(-1);
??????}
??????return?new?Point(coords[node][X_COORDINATE]?coords[node][Y_COORDINATE]);
????}
????/**?Return?true?if?the?given?node?is?within?the?valid?range?(1..NUM_NODES)?false?otherwise?*/
????private?static?boolean?nodeIsValid(int?node)?{
if?(node?1?||?node?>?NUM_NODES)
????return?false;
else
????return?true;
????}
????
????private?static?final?int?X_COORDINATE?=?0;?//?x-axis?coordinate?is?dimension?0?in?coords[][]
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2016-11-17?21:00??CVRP-master\
?????文件??????121190??2016-11-17?21:00??CVRP-master\COMSM0305-1.pdf
?????文件??????148903??2016-11-17?21:00??CVRP-master\COMSM0305-2.pdf
?????文件??????112511??2016-11-17?21:00??CVRP-master\COMSM0305-2print.pdf
?????目錄???????????0??2016-11-17?21:00??CVRP-master\CVRP\
?????文件????????6356??2016-11-17?21:00??CVRP-master\CVRP\CVRPData.java
?????文件???????17752??2016-11-17?21:00??CVRP-master\CVRP\CVRPValidater.jar
?????文件????????4260??2016-11-17?21:00??CVRP-master\CVRP\fruitybun250.vrp
?????文件?????3175807??2016-11-17?21:00??CVRP-master\SuttonBook.pdf
評論
共有 條評論