Struct Instance

Source
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

Source

pub fn parse(input: &str) -> Result<Instance, Box<dyn Error>>

Parses an instance from a string.

Source

pub fn load(filename: &str) -> Result<Instance, Box<dyn Error>>

Loads an instance from a file.

Examples found in repository?
examples/load_and_display.rs (line 10)
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

Source

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?
examples/load_and_display.rs (line 13)
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}

Trait Implementations§

Source§

impl Clone for Instance

Source§

fn clone(&self) -> Instance

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Instance

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.