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

Functions

bool check_load_beluga (state, obs)
 Check if a beluga can be loaded from a trailer.
 
bool check_unload_beluga (state, obs)
 Check if a beluga can be unloaded.
 
bool check_get_from_hangar (state, obs)
 Check if a jig can be retrieved from hangar.
 
bool check_deliver_to_hangar (state, obs)
 Check if a jig can be delivered to hangar.
 
bool check_left_stack_rack (state, obs)
 Check if a jig can be stacked from left (Beluga) trailer to rack.
 
bool check_right_stack_rack (state, obs)
 Check if a jig can be stacked from right (Factory) trailer to rack.
 
bool check_left_unstack_rack (state, obs)
 Check if a jig can be unstacked from rack to left (Beluga) trailer.
 
bool check_right_unstack_rack (state, obs)
 Check if a jig can be unstacked from rack to right (Factory) trailer.
 

Function Documentation

◆ check_deliver_to_hangar()

bool rl.env.check_action.check_deliver_to_hangar ( state,
obs )

Check if a jig can be delivered to hangar.

Parameters
stateCurrent problem state
obsCurrent observation array
Returns
True if delivery is possible, False otherwise
64def check_deliver_to_hangar(state, obs) -> bool:
65 """!
66 @brief Check if a jig can be delivered to hangar
67 @param state Current problem state
68 @param obs Current observation array
69 @return True if delivery is possible, False otherwise
70 """
71 # Preconditions
72 for trailer_idx in range(3):
73 if obs[4 + trailer_idx] == 1:
74 for hangar_idx in range(3):
75 if obs[7 + hangar_idx] == 0:
76 return True
77
78 return False
79
80# 4

◆ check_get_from_hangar()

bool rl.env.check_action.check_get_from_hangar ( state,
obs )

Check if a jig can be retrieved from hangar.

Parameters
stateCurrent problem state
obsCurrent observation array
Returns
True if retrieval is possible, False otherwise
46def check_get_from_hangar(state, obs) -> bool:
47 """!
48 @brief Check if a jig can be retrieved from hangar
49 @param state Current problem state
50 @param obs Current observation array
51 @return True if retrieval is possible, False otherwise
52 """
53 # Preconditions
54 for hangar_idx in range(3):
55 if obs[7 + hangar_idx] == 1:
56 for trailer_idx in range(3):
57 if obs[4 + trailer_idx] == 0.5:
58 return True
59
60 return False
61
62
63# 3

◆ check_left_stack_rack()

bool rl.env.check_action.check_left_stack_rack ( state,
obs )

Check if a jig can be stacked from left (Beluga) trailer to rack.

Parameters
stateCurrent problem state
obsCurrent observation array
Returns
True if stacking is possible, False otherwise
81def check_left_stack_rack(state, obs) -> bool:
82 """!
83 @brief Check if a jig can be stacked from left (Beluga) trailer to rack
84 @param state Current problem state
85 @param obs Current observation array
86 @return True if stacking is possible, False otherwise
87 """
88 # Preconditions
89 for i in range(3):
90 if obs[1 + i] != 0.5 and obs[1 + i] != -1:
91 jig_id = state.trailers_beluga[i]
92 jig = state.jigs[jig_id]
93 jig_size = jig.jig_type.size_empty if jig.empty else jig.jig_type.size_loaded
94 for rack_idx in range(len(state.racks)):
95 rack_obj = state.racks[rack_idx]
96 if rack_obj.get_free_space(state.jigs) >= jig_size:
97 return True
98
99 return False
100
101
102# 5

◆ check_left_unstack_rack()

bool rl.env.check_action.check_left_unstack_rack ( state,
obs )

Check if a jig can be unstacked from rack to left (Beluga) trailer.

Parameters
stateCurrent problem state
obsCurrent observation array
Returns
True if unstacking is possible, False otherwise
125def check_left_unstack_rack(state, obs) -> bool:
126 """!
127 @brief Check if a jig can be unstacked from rack to left (Beluga) trailer
128 @param state Current problem state
129 @param obs Current observation array
130 @return True if unstacking is possible, False otherwise
131 """
132 # Preconditions
133 for trailer_idx in range(3):
134 if obs[1 + trailer_idx] == 0.5:
135 for rack_idx in range(len(state.racks)):
136 if state.racks[rack_idx].current_jigs != []:
137 return True
138
139 return False
140
141
142# 7

◆ check_load_beluga()

bool rl.env.check_action.check_load_beluga ( state,
obs )

Check if a beluga can be loaded from a trailer.

Parameters
stateCurrent problem state
obsCurrent observation array
Returns
True if loading is possible, False otherwise
8def check_load_beluga(state, obs) -> bool:
9 """!
10 @brief Check if a beluga can be loaded from a trailer
11 @param state Current problem state
12 @param obs Current observation array
13 @return True if loading is possible, False otherwise
14 """
15 # Preconditions
16 if obs[0] != 0:
17 return False
18
19 for i in range(3):
20 if obs[1 + i] == 0: # Trailer has matching empty jig
21 return True
22
23 return False
24
25
26# 1

◆ check_right_stack_rack()

bool rl.env.check_action.check_right_stack_rack ( state,
obs )

Check if a jig can be stacked from right (Factory) trailer to rack.

Parameters
stateCurrent problem state
obsCurrent observation array
Returns
True if stacking is possible, False otherwise
103def check_right_stack_rack(state, obs) -> bool:
104 """!
105 @brief Check if a jig can be stacked from right (Factory) trailer to rack
106 @param state Current problem state
107 @param obs Current observation array
108 @return True if stacking is possible, False otherwise
109 """
110 # Preconditions
111 for i in range(3):
112 if obs[4 + i] != 0.5 and obs[4 + i] != -1:
113 jig_id = state.trailers_factory[i]
114 jig = state.jigs[jig_id]
115 jig_size = jig.jig_type.size_empty if jig.empty else jig.jig_type.size_loaded
116 for rack_idx in range(len(state.racks)):
117 rack_obj = state.racks[rack_idx]
118 if rack_obj.get_free_space(state.jigs) >= jig_size:
119 return True
120
121 return False
122
123
124# 6

◆ check_right_unstack_rack()

bool rl.env.check_action.check_right_unstack_rack ( state,
obs )

Check if a jig can be unstacked from rack to right (Factory) trailer.

Parameters
stateCurrent problem state
obsCurrent observation array
Returns
True if unstacking is possible, False otherwise
143def check_right_unstack_rack(state, obs) -> bool:
144 """!
145 @brief Check if a jig can be unstacked from rack to right (Factory) trailer
146 @param state Current problem state
147 @param obs Current observation array
148 @return True if unstacking is possible, False otherwise
149 """
150 # Preconditions
151 # Preconditions
152 for trailer_idx in range(3):
153 if obs[4 + trailer_idx] == 0.5:
154 for rack_idx in range(len(state.racks)):
155 if state.racks[rack_idx].current_jigs != []:
156 return True
157
158 return False

◆ check_unload_beluga()

bool rl.env.check_action.check_unload_beluga ( state,
obs )

Check if a beluga can be unloaded.

Parameters
stateCurrent problem state
obsCurrent observation array
Returns
True if unloading is possible, False otherwise
27def check_unload_beluga(state, obs) -> bool:
28 """!
29 @brief Check if a beluga can be unloaded
30 @param state Current problem state
31 @param obs Current observation array
32 @return True if unloading is possible, False otherwise
33 """
34 # Preconditions
35 if obs[0] != 1:
36 return False
37
38 for i in range(3):
39 if obs[1 + i] == 0.5: # Trailer is empty
40 return True
41
42 return False
43
44
45# 2