Observations¶
MTDVRP observations.
Observations settings are defined in file observations.py.
Observations¶
- class maenvs4vrp.environments.mtdvrp.observations.Observations(feature_list: Dict = None)[source]¶
MTDVRP 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_linehaul_demand()[source]¶
Nodes linehaul demands.
- Parameters:
n/a.
- Returns:
Nodes linehaul demands.
- Return type:
torch.Tensor
- Observations.get_feat_backhaul_demand()[source]¶
Nodes backhaul demands.
- Parameters:
n/a.
- Returns:
Nodes backhaul demands.
- Return type:
torch.Tensor
- Observations.get_feat_service_time()[source]¶
Nodes service times.
- Parameters:
n/a.
- Returns:
Nodes service times.
- 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_used_capacity_linehaul()[source]¶
Used linehaul capacity by agent.
- Parameters:
n/a.
- Returns:
Used linehaul capacity.
- Return type:
torch.Tensor
- Observations.get_feat_agent_used_capacity_backhaul()[source]¶
Used backhaul capacity by agent.
- Parameters:
n/a.
- Returns:
Used backhaul capacity.
- Return type:
torch.Tensor
- Observations.get_feat_agent_avaliable_load()[source]¶
Agent’s avaliable load when problem is unmixed.
- Parameters:
n/a.
- Returns:
Avaliable load.
- Return type:
torch.Tensor
- Observations.get_feat_agent_avaliable_load_vrpmpd()[source]¶
Agent’s avaliable load when problem is mixed.
- Parameters:
n/a.
- Returns:
Avaliable load.
- Return type:
torch.Tensor
- Observations.get_feat_agent_arrivedepot_div_end_time()[source]¶
Agent time to depot divided by end time.
- Parameters:
n/a.
- Returns:
Agent time to depot divided by end time.
- Return type:
torch.Tensor
- Observations.get_feat_agent_frac_feasible_nodes()[source]¶
Fraction of current agent feasible nodes, in order to the total number of instance nodes.
- Parameters:
n/a.
- Returns:
Fraction of current agent feasible nodes, in order to the total number of instance nodes.
- 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_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
- 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_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
Global features¶
- Observations.get_feat_global_frac_done_agents()[source]¶
Fraction of done agents.
- Parameters:
n/a.
- Returns:
Fraction of done agents.
- Return type:
torch.Tensor
- Observations.get_feat_global_frac_linehaul_demands()[source]¶
Fraction of served demands.
- Parameters:
n/a.
- Returns:
Fraction of served demands.
- Return type:
torch.Tensor
- Observations.get_feat_global_frac_backhaul_demands()[source]¶
Fraction of served demands.
- Parameters:
n/a.
- Returns:
Fraction of served demands.
- Return type:
torch.Tensor
- Observations.get_feat_global_open_routes()[source]¶
Checks if problems have open routes.
- Parameters:
n/a.
- Returns:
Open routes.
- Return type:
torch.Tensor
- Observations.get_feat_global_distance_limits()[source]¶
Chack problems distance limits.
- Parameters:
n/a.
- Returns:
Distance limits.
- Return type:
torch.Tensor
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