FoPra Beluga Challenge - Reinforcement Learning v1.0
Deep Reinforcement Learning solution for the Beluga Challenge shipping container optimization problem using PPO and MCTS
rl.agents.low_level.heuristics Namespace Reference

Functions

 decide_parameters (obs, high_level_action)
 Decide action parameters based on high-level action and current observation.
 

Function Documentation

◆ decide_parameters()

rl.agents.low_level.heuristics.decide_parameters ( obs,
high_level_action )

Decide action parameters based on high-level action and current observation.

This function implements heuristic decision-making for low-level action parameters. It analyzes the current state observation to determine appropriate parameters for the given high-level action.

Parameters
obsCurrent state observation array
high_level_actionHigh-level action string to execute
Returns
Tuple of (action_name, parameters) or ("None", []) if no action possible
3def decide_parameters(obs, high_level_action):
4 """!
5 @brief Decide action parameters based on high-level action and current observation
6
7 This function implements heuristic decision-making for low-level action parameters.
8 It analyzes the current state observation to determine appropriate parameters
9 for the given high-level action.
10
11 @param obs Current state observation array
12 @param high_level_action High-level action string to execute
13 @return Tuple of (action_name, parameters) or ("None", []) if no action possible
14 """
15 n_racks = 10 # Number of available racks
16
17 # Switch case for high-level agent action
18 match high_level_action:
19 # If unload_beluga, no parameters are returned
20 case "unload_beluga":
21 return "unload_beluga", []
22
23 # If load_beluga, return trailer index
24 case "load_beluga":
25 for i in range(3):
26 if obs[1 + i] == 0: # Trailer has matching empty jig
27 return "load_beluga", {"trailer_beluga": i, "none": None}
28
29 # If right_unstack_rack, return rack index and trailer ID
30 case "right_unstack_rack":
31 for rack_idx in range(n_racks):
32 slot = 10 + rack_idx * 3
33 if obs[slot + 1] == 1:
34 for trailer_idx in range(3):
35 if obs[4 + trailer_idx] == 0.5:
36 return "right_unstack_rack", {"rack": rack_idx, "trailer_id": trailer_idx}
37
38 # If left_unstack_rack, return rack index and trailer ID
39 case "left_unstack_rack":
40 for rack_idx in range(n_racks):
41 slot = 10 + rack_idx * 3
42 if obs[slot] == 1:
43 for trailer_idx in range(3):
44 if obs[1 + trailer_idx] == 0.5:
45 return "left_unstack_rack", {"rack": rack_idx, "trailer_id": trailer_idx}
46
47 # If get_from_hangar, return hangar index and trailer factory index
48 case "get_from_hangar":
49 for hangar_idx in range(3):
50 if obs[7 + hangar_idx] == 1:
51 for trailer_idx in range(3):
52 if obs[4 + trailer_idx] == 0.5:
53 return "get_from_hangar", {"hangar": hangar_idx, "trailer_factory": trailer_idx}
54
55 # If deliver_to_hangar, return hangar index and trailer factory index
56 case "deliver_to_hangar":
57 for trailer_idx in range(3):
58 if obs[4 + trailer_idx] == 1:
59 for hangar_idx in range(3):
60 if obs[7 + hangar_idx] == 0:
61 return "deliver_to_hangar", {"hangar": hangar_idx, "trailer_factory": trailer_idx}
62
63
64 # No action available
65 case _:
66 return "None", []
67
68 return "None", []