pub struct Instance {Show 18 fields
pub name: String,
pub instance_type: InstanceType,
pub comment: String,
pub dimension: usize,
pub capacity: Option<i32>,
pub edge_weight_type: EdgeWeightType,
pub edge_weight_format: Option<EdgeWeightFormat>,
pub distance: Option<f64>,
pub service_time: Option<f64>,
pub demand_dimension: Option<usize>,
pub node_coords: Option<NodeCoords>,
pub depots: Option<Vec<usize>>,
pub demands: Option<Vec<(usize, Vec<i32>)>>,
pub edge_data: Option<EdgeData>,
pub fixed_edges: Option<Vec<(usize, usize)>>,
pub display_data: Option<DisplayData>,
pub tours: Option<Vec<Vec<usize>>>,
pub edge_weights: Option<Vec<Vec<i32>>>,
}
Expand description
An instance of a TSP or related problem.
Fields§
§name: String
Name of the instance.
instance_type: InstanceType
Type of the data.
comment: String
Additional comments.
dimension: usize
For a TSP or ATSP, the dimension is the number of its nodes. For a CVRP, it is the total number of nodes and depots. For a TOUR file, it is the dimension of the corresponding problem.
capacity: Option<i32>
The truck capacity.
edge_weight_type: EdgeWeightType
How the edge weights (or distances) are given.
edge_weight_format: Option<EdgeWeightFormat>
Describes the format of the edge weights if they are given explicitly.
distance: Option<f64>
Maximum route duration.
service_time: Option<f64>
Service time.
demand_dimension: Option<usize>
The number of commodities at each node.
node_coords: Option<NodeCoords>
Node coordinates. (which, for example may be used for either graphical display or for computing the edge weights).
depots: Option<Vec<usize>>
A list of possible alternate depot nodes.
demands: Option<Vec<(usize, Vec<i32>)>>
The demands of all nodes. The first element of each tuple is the node number, the second element is a list of possibly multi-dimensional demands.
edge_data: Option<EdgeData>
Edges of a graph, if the graph is not complete.
fixed_edges: Option<Vec<(usize, usize)>>
Edges required to appear in each solution to the problem.
display_data: Option<DisplayData>
How a graphical display of the nodes can be obtained.
tours: Option<Vec<Vec<usize>>>
A collection of tours.
edge_weights: Option<Vec<Vec<i32>>>
Edge weights in a matrix format specified by edge_weight_format
.
Implementations§
Source§impl Instance
impl Instance
Sourcepub fn parse(input: &str) -> Result<Instance, Box<dyn Error>>
pub fn parse(input: &str) -> Result<Instance, Box<dyn Error>>
Parses an instance from a string.
Sourcepub fn load(filename: &str) -> Result<Instance, Box<dyn Error>>
pub fn load(filename: &str) -> Result<Instance, Box<dyn Error>>
Loads an instance from a file.
Examples found in repository?
4fn main() {
5 let mut args = env::args();
6 args.next().unwrap();
7 let input = args.next().unwrap();
8
9 println!("Loading instance from file: {}", input);
10 let instance = Instance::load(&input).unwrap();
11 println!("{:?}", instance);
12
13 let matrix = instance.get_full_distance_matrix().unwrap();
14 println!("{:?}", matrix);
15}
Source§impl Instance
impl Instance
Sourcepub fn get_full_distance_matrix(&self) -> Result<Vec<Vec<i32>>, Box<dyn Error>>
pub fn get_full_distance_matrix(&self) -> Result<Vec<Vec<i32>>, Box<dyn Error>>
Returns the full distance matrix of the instance.
Examples found in repository?
4fn main() {
5 let mut args = env::args();
6 args.next().unwrap();
7 let input = args.next().unwrap();
8
9 println!("Loading instance from file: {}", input);
10 let instance = Instance::load(&input).unwrap();
11 println!("{:?}", instance);
12
13 let matrix = instance.get_full_distance_matrix().unwrap();
14 println!("{:?}", matrix);
15}