Benchmark Instance Generation¶
Description here if any.
Benchmark instance generation settings are defined in file benchmark_instances_generator.py.
Data files format¶
************************
* DVRPTW instances *
************************
Description here if any.
Taken from: https://www.sintef.no/projectweb/top/vrptw/
BenchmarkInstanceGenerator¶
- class maenvs4vrp.environments.dvrptw.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]¶
DVRPTW 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) 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) 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) 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