Sample a parent program from the current island for the next evolution step Returns: Parent program from current island
(self)
| 1274 | ) |
| 1275 | |
| 1276 | def _sample_parent(self) -> Program: |
| 1277 | """ |
| 1278 | Sample a parent program from the current island for the next evolution step |
| 1279 | |
| 1280 | Returns: |
| 1281 | Parent program from current island |
| 1282 | """ |
| 1283 | # Use exploration_ratio and exploitation_ratio to decide sampling strategy |
| 1284 | rand_val = random.random() |
| 1285 | |
| 1286 | if rand_val < self.config.exploration_ratio: |
| 1287 | # EXPLORATION: Sample from current island (diverse sampling) |
| 1288 | return self._sample_exploration_parent() |
| 1289 | elif rand_val < self.config.exploration_ratio + self.config.exploitation_ratio: |
| 1290 | # EXPLOITATION: Sample from archive (elite programs) |
| 1291 | return self._sample_exploitation_parent() |
| 1292 | else: |
| 1293 | # RANDOM: Sample from any program (remaining probability) |
| 1294 | return self._sample_random_parent() |
| 1295 | |
| 1296 | def _sample_exploration_parent(self) -> Program: |
| 1297 | """ |
no test coverage detected