Observations¶
CVRPTW observations.
Observations settings are defined in file observations.py.
Observations¶
- class maenvs4vrp.environments.cvrptw.observations.Observations(feature_list: Dict = None)[source]¶
CVRPTW observations class.
Nodes static features¶
- Observations.get_feat_x_coordinate()[source]¶
Instance nodes X coordinates.
- Parameters:
n/a.
- Returns:
Instance nodes X coordinates.
- Return type:
torch.Tensor
- Observations.get_feat_y_coordinate()[source]¶
Instance nodes Y coordinates.
- Parameters:
n/a.
- Returns:
Instance nodes Y coordinates.
- Return type:
torch.Tensor
- Observations.get_feat_x_coordinate_min_max()[source]¶
Min-max normalized X coordinates of instance nodes.
- Parameters:
n/a.
- Returns:
Min. and max. x coordinates of instance nodes.
- Return type:
torch.Tensor
- Observations.get_feat_y_coordinate_min_max()[source]¶
Min-max normalized Y coordinates of instance nodes.
- Parameters:
n/a.
- Returns:
Min-max normalized Y coordinates of instance nodes.
- Return type:
torch.Tensor
- Observations.get_feat_tw_low()[source]¶
Nodes time windows starting times.
- Parameters:
n/a.
- Returns:
Nodes time windows starting times.
- Return type:
torch.Tensor
- Observations.get_feat_tw_high()[source]¶
Nodes time windows ending times.
- Parameters:
n/a.
- Returns:
Nodes time windows ending times.
- Return type:
torch.Tensor
- Observations.get_feat_demand()[source]¶
Nodes demand.
- Parameters:
n/a.
- Returns:
Nodes demand.
- Return type:
torch.Tensor
- Observations.get_feat_service_time()[source]¶
Nodes service time.
- Parameters:
n/a.
- Returns:
Nodes service time.
- Return type:
torch.Tensor
Nodes dynamic features¶
- Observations.get_feat_time2open_div_end_time()[source]¶
Nodes time to open divided by end time.
- Parameters:
n/a.
- Returns:
Nodes time to open divided by end time.
- Return type:
torch.Tensor
- Observations.get_feat_time2close_div_end_time()[source]¶
Nodes time to close divided by end time.
- Parameters:
n/a.
- Returns:
Nodes time to close divided by end time.
- Return type:
torch.Tensor
- Observations.get_feat_arrive2node_div_end_time()[source]¶
Agent arriving time to nodes divided by end time.
- Parameters:
n/a.
- Returns:
Agent arriving time to nodes divided by end time.
- Return type:
torch.Tensor
- Observations.get_feat_time2open_after_step_div_end_time()[source]¶
Nodes time to open, after agent step, divided by end time.
- Parameters:
n/a.
- Returns:
Nodes time to open, after agent step, divided by end time.
- Return type:
torch.Tensor
- Observations.get_feat_time2close_after_step_div_end_time()[source]¶
Nodes time to close, after agent step, divided by end time.
- Parameters:
n/a.
- Returns:
Nodes time to close, after agent step, divided by end time.
- Return type:
torch.Tensor
- Observations.get_feat_time2end_after_step_div_end_time()[source]¶
Time end, after agent step to node, divided by end time.
- Parameters:
n/a.
- Returns:
Time end, after agent step to node, divided by end time.
- Return type:
torch.Tensor
Current agent features¶
- Observations.get_feat_agent_x_coordinate()[source]¶
Current agent X coordinate.
- Parameters:
n/a.
- Returns:
Current agent X coordinate.
- Return type:
torch.Tensor
- Observations.get_feat_agent_y_coordinate()[source]¶
Current agent Y coordinate.
- Parameters:
n/a.
- Returns:
Current agent Y coordinate.
- Return type:
torch.Tensor
- Observations.get_feat_agent_x_coordinate_min_max()[source]¶
Current agent min-max normalized X location.
- Parameters:
n/a.
- Returns:
Current agent min-max normalized X location.
- Return type:
torch.Tensor
- Observations.get_feat_agent_y_coordinate_min_max()[source]¶
Current agent min-max normalized Y location.
- Parameters:
n/a.
- Returns:
Current agent min-max normalized Y location.
- Return type:
torch.Tensor
- Observations.get_feat_agent_frac_current_time()[source]¶
Agent fraction of time elapsed.
- Parameters:
n/a.
- Returns:
Agent fraction of time elapsed.
- Return type:
torch.Tensor
- Observations.get_feat_agent_frac_current_load()[source]¶
Agent fraction of used capacity.
- Parameters:
n/a.
- Returns:
Agent fraction of used capacity.
- Return type:
torch.Tensor
Other agents features¶
- Observations.get_feat_agents_x_coordinate()[source]¶
Agents X coordinates.
- Parameters:
n/a.
- Returns:
Agents X coordinates.
- Return type:
torch.Tensor
- Observations.get_feat_agents_y_coordinate()[source]¶
Agents Y coordinates.
- Parameters:
n/a.
- Returns:
Agents Y coordinates.
- Return type:
torch.Tensor
- Observations.get_feat_agents_x_coordinate_min_max()[source]¶
Agents min-max normalized X location.
- Parameters:
n/a.
- Returns:
Agents min-max normalized X location.
- Return type:
torch.Tensor
- Observations.get_feat_agents_y_coordinate_min_max()[source]¶
Agents min-max normalized Y location.
- Parameters:
n/a.
- Returns:
Agents min-max normalized Y location.
- Return type:
torch.Tensor
- Observations.get_feat_agents_frac_current_time()[source]¶
Agents fraction of elapsed time.
- Parameters:
n/a.
- Returns:
Agents fraction of elapsed time.
- Return type:
torch.Tensor
- Observations.get_feat_agents_frac_current_load()[source]¶
Agents fraction of used capacity.
- Parameters:
n/a.
- Returns:
Agents fraction of used capacity.
- Return type:
torch.Tensor
- Observations.get_feat_agents_frac_feasible_nodes()[source]¶
Fraction of agents feasible nodes, in order to the total number of instance nodes.
- Parameters:
n/a.
- Returns:
Fraction of agents feasible nodes, in order to the total number of instance nodes.
- Return type:
torch.Tensor
- Observations.get_feat_agents_dist2agent_div_end_time()[source]¶
Agents distance to active agent divided by end time.
- Parameters:
n/a.
- Returns:
Agents distance to active agent divided by end time.
- Return type:
torch.Tensor
- Observations.get_feat_agents_dist2depot_div_end_time()[source]¶
Fraction of current agent distance to depot compared to its end time.
- Parameters:
n/a.
- Returns:
Fraction of current agent distance to depot compared to its end time.
- Return type:
torch.Tensor
Global features¶
Computing features¶
- Observations.compute_static_features()[source]¶
Compute nodes static features.
- Parameters:
n/a.
- Returns:
Nodes static features.
- Return type:
torch.Tensor
- Observations.compute_dynamic_features()[source]¶
Compute nodes dynamic features.
- Parameters:
n/a.
- Returns:
Nodes dynamic features.
- Return type:
torch.Tensor
- Observations.compute_agent_features()[source]¶
Compute current agent features.
- Parameters:
n/a.
- Returns:
Current agent features.
- Return type:
torch.Tensor
- Observations.compute_agents_features()[source]¶
Compute other agent features.
- Parameters:
n/a.
- Returns:
Other agent features.
- Return type:
torch.Tensor
Internal methods¶
- static Observations._concat_features(features)[source]¶
Concatenate features.
- Parameters:
features (list) – Features to concatenate.
- Returns:
Concatenated tensor.
- Return type:
torch.Tensor
- Observations._normalize_feature(x, norm)[source]¶
Normalize features.
- Parameters:
x (torch.Tensor) – Tensor to be normalized.
norm (str) – Type of normalization. It can be ‘min_max’ or ‘standardize’. If None, tensor is returned.
- Returns:
Tensor normalized or default tensor if norm is invalid.
- Return type:
torch.Tensor
- static Observations._min_max_normalization(x)[source]¶
Min. max. normalization.
- Parameters:
x (torch.Tensor) – Tensor to be normalized.
- Returns:
Normalized tensor.
- Return type:
torch.Tensor