Benchmark Instance Generation¶
Li&Lim instances are included to be used with PDPTW environment.
Benchmark instance generation settings are defined in file benchmark_instances_generator.py.
Data files format¶
************************
* PDPTW instances *
************************
Below is an explanation of the format of the instance definitions (text files). Note that tabulator is used as field separator rather than spaces.
NUMBER OF VEHICLES VEHICLE CAPACITY SPEED(not used)
K Q S
TASK NO. X Y DEMAND EARLIEST PICKUP/DELIVERY TIME LATEST PICKUP/DELIVERY TIME SERVICE TIME PICKUP(index to sibling) DELIVERY(index to sibling)
0 x0 y0 q0 e0 l0 s0 p0 d0
… … … … … … … … …
Task 0 specifies the coordinates of the depot. For pickup tasks, the PICKUP index is 0, whereas the DELIVERY sibling gives the index of the corresponding delivery task. For delivery tasks, the PICKUP index gives the index of the corresponding pickup task. The value of travel time is equal to the value of distance.
Taken from: https://www.sintef.no/projectweb/top/pdptw/
BenchmarkInstanceGenerator¶
- class maenvs4vrp.environments.pdptw.benchmark_instances_generator.BenchmarkInstanceGenerator(instance_type: str = 'Li&Lim', set_of_instances: set = None, device: str | None = 'cpu', batch_size: Size | None = None, seed: int = None)[source]¶
PDPTW benchmark instance generation class.
- __init__(instance_type: str = 'Li&Lim', 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, instance_name: str) 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_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