ding0.grid.mv_grid.util package

Submodules

ding0.grid.mv_grid.util.data_input module

Based on code by Romulo Oliveira copyright (C) 2015, https://github.com/RomuloOliveira/monte-carlo-cvrp Originally licensed under the Apache License, Version 2.0. You may obtain a copy of the license at http://www.apache.org/licenses/LICENSE-2.0

exception ding0.grid.mv_grid.util.data_input.ParseException(value)[source]

Bases: Exception

Exception raised when something unexpected occurs in a TSPLIB file parsing

value

Description

Type:type
Parameters:value (type) – Description
ding0.grid.mv_grid.util.data_input.calculate_euc_distance(a, b)[source]

Calculates Eclidian distances from two points a and b

Parameters:
  • a ((float, float)) – Two-dimension tuple (x1,y1)
  • b ((float, float)) – Two-dimension tuple (x2,y2)
Returns:

float – the distance.

ding0.grid.mv_grid.util.data_input.read_file(filename)[source]

Reads a TSPLIB file and returns the problem data.

Parameters:filename (str) –
Returns:type – Problem specs.
ding0.grid.mv_grid.util.data_input.sanitize(filename)[source]

Returns a sanitized file name with absolut path

Example

~/input.txt -> /home/<your_home/input.txt

Returns:str – The sanitized file name with absolut path.
ding0.grid.mv_grid.util.data_input.strip(line)[source]

Removes any \r or \n from line and remove trailing whitespaces

Parameters:line (str) –
Returns:str – the stripped line.

ding0.grid.mv_grid.util.util module

Based on code by Romulo Oliveira copyright (C) 2015, https://github.com/RomuloOliveira/monte-carlo-cvrp Originally licensed under the Apache License, Version 2.0. You may obtain a copy of the license at http://www.apache.org/licenses/LICENSE-2.0

ding0.grid.mv_grid.util.util.print_solution(solution)[source]

Prints a solution

Parameters:solution (BaseSolution) –

Example

[8, 9, 10, 7]: 160
[5, 6]: 131
[3, 4, 2]: 154
Total cost: 445
ding0.grid.mv_grid.util.util.print_upper_triangular_matrix(matrix)[source]

Prints a CVRP data dict matrix

Parameters:matrix (dict) – Description

Note

It is assummed that the first row of matrix contains all needed headers.

ding0.grid.mv_grid.util.util.print_upper_triangular_matrix_as_complete(matrix)[source]

Prints a CVRP data dict upper triangular matrix as a normal matrix

Doesn’t print headers.

Parameters:matrix (dict) – Description

Module contents