Benchmark Instance Generation¶
Bianchessi, Solomon and Homberger instances are included to be used with SDVRPTW environment.
Benchmark instance generation settings are defined in file benchmark_instances_generator.py.
Data files format¶
************************
* SDVRPTW instances *
************************
Data files format:
For these problem, data files format is as follows:
The first line contains the following data, number of paths, all vertices can be visited and number of vertices.
From the 3th line, each line contains the integer data associated to each customer, starting with the depot:
vertex number
x coordinate
y coordinate
service duration or visiting time
profit of the location
Opening of time window
Closing of time window
Gavalas
For these problem, data files format is as follows:
The first line contains the following data, number of tours, start day,number of vertices.
The second line associties with start/end point:
vertex number = 0
x coordinate
y coordinate
visiting duration = 0
score of the location = 0
Opening of time window
Closing of time window
The remaining lines contain the data of each point. For each point, the line contains the following data:
vertex number
x coordinate
y coordinate
visiting duration
score of the location
Opening hour of the day i, i = 0,1,2,3,4,5,6
Closing hour of the day i, i = 0,1,2,3,4,5,6
BenchmarkInstanceGenerator¶
- class maenvs4vrp.environments.sdvrptw.benchmark_instances_generator.BenchmarkInstanceGenerator(instance_type: str = 'Solomon', set_of_instances: set = None, device: str | None = 'cpu', batch_size: Size | None = None, seed: int = None)[source]¶
SDVRPTW benchmark instance generation class.
- __init__(instance_type: str = 'Solomon', set_of_instances: set = None, device: str | None = 'cpu', batch_size: Size | None = None, seed: int = None) None[source]¶
Constructor. Create an instance space of one or several sets of data.
- Parameters:
instance_type (str) – Instance type. Can be “Solomon” or “Homberger”. Defaults to “Solomon”.
set_of_instances (set) – Set of instances file names. Defaults to None.
device (str, optional) – Type of processing. It can be “cpu” or “gpu”. Defaults to “cpu”.
batch_size (torch.Size, optional) – Batch size. If not specified, defaults to 1.
seed (int) – Random number generator seed. Defaults to None.
- Returns:
None.
- get_instance(instance_name: str, num_agents: int = None) Dict[source]¶
Get an instance with custom number of agents.
- Parameters:
instance_name (str) – Instance file name.
num_agents (int) – Number of agents. Defaults to None.
- Returns:
Instance data.
- Return type:
Dict
- classmethod get_list_of_benchmark_instances()[source]¶
Get list of possible instances from benchmark files.
- Parameters:
n/a.
- Returns:
None.
- load_set_of_instances(set_of_instances: set = None)[source]¶
Load every instance on set_of_instances set.
- Parameters:
set_of_instances (set) – Set of instances file names. Defaults to None.
- Returns:
None.
- parse_instance_data(instance_data: list) Dict[source]¶
Parse instance data list into a dictionary.
- Parameters:
instance_data (list) – Instance data.
- Returns:
Parsed instance data.
- Return type:
Dict
- random_sample_instance(instance_name: str = None, num_agents: int = None, num_nodes: int = None, seed: int = None, device: str | None = 'cpu') Dict[source]¶
Sample one instance from instance space, randomly adjusting the nodes.
- Parameters:
instance_name (str) – Instance file name. Defaults to None.
num_agents (int) – Total number of agents. Defaults to None.
num_nodes (int) – Total number of nodes. Defaults to None.
seed (int) – Random number generator seed. Defaults to None.
- Returns:
Instance data.
- Return type:
Dict
- read_instance_data(instance_name: str) Dict[source]¶
Read instance data from file.
- Parameters:
instance_name (str) – Instance file name.
- Returns:
Instance data.
- Return type:
Dict
- sample_first_n_services(instance_name: str = None, num_agents: int = None, num_nodes: int = None, device: str | None = 'cpu') Dict[source]¶
Sample first n nodes.
- Parameters:
instance_name (str) – Instance file name. Defaults to None.
num_agents (int) – Total number of agents. Defaults to None.
num_nodes (int) – Total number of (n) nodes intended. Defaults to None.
- Returns:
New instance of the first n nodes.
- Return type:
Dict
- sample_instance(num_agents: int = None, num_nodes: int = None, capacity: int = None, service_times: float = None, instance_name: str = None, sample_type: str = 'random', batch_size: Size | None = None, n_augment: int | None = None, seed: int = None, device: str | None = 'cpu') Dict[source]¶
Sample one instance from instance space.
- Parameters:
num_agents (int) – Total number of agents. Defaults to None.
num_nodes (int) – Total number of nodes. Defaults to None.
capacity (int) – Capacity of the agents. Defaults to None.
service_times (float) – Service time in the nodes. Defaults to None.
instance_name (str) – Instance name. Defaults to None.
sample_type (str) – Sample type. It can be “random” or something else for “first n”. Defaults to “random”.
batch_size (torch.Size or None) – Batch size. Defaults to None.
n_augment (int, optional) – Data augmentation. Defaults to None.
seed (int) – Random number generator seed. Defaults to None.
- Returns:
Instance data.
- Return type:
Dict