1616import gymnasium as gym
1717from gymnasium import spaces
1818
19- from das .env .observation import (
20- compute_observation ,
21- observation_dim ,
22- compute_ela_features ,
23- MAX_HISTORY_SAMPLE ,
24- ELA_DIM ,
25- )
19+ from das .env .observation import (compute_observation , observation_dim , MAX_HISTORY_SAMPLE )
2620from das .env .reward import compute_reward
2721from das .optimizers .base import get_checkpoints
2822
29- # Recompute ELA every ~500 new population samples. pflacco runs regression,
30- # nearest-neighbour search, and IC calculations on every call — running it
31- # every step would dominate wall-clock time for long training runs.
32- _ELA_RECOMPUTE_THRESHOLD = MAX_HISTORY_SAMPLE // 5
33-
3423
3524class DASEnv (gym .Env ):
3625 """DAS environment.
@@ -107,11 +96,6 @@ def __init__(
10796 self ._stagnation_count = 0
10897 self ._choices_history : list [int ] = []
10998
110- # ELA features are expensive; cache the last computed vector and refresh
111- # lazily once _ELA_RECOMPUTE_THRESHOLD new samples have arrived.
112- self ._ela_cache : np .ndarray = np .zeros (ELA_DIM , dtype = np .float32 )
113- self ._ela_cache_len : int = 0
114-
11599 # ------------------------------------------------------------------ #
116100 # Gymnasium interface #
117101 # ------------------------------------------------------------------ #
@@ -141,8 +125,6 @@ def reset(self, seed=None, options=None):
141125 self ._initial_range = (float ("inf" ), - np .inf )
142126 self ._stagnation_count = 0
143127 self ._choices_history = []
144- self ._ela_cache = np .zeros (ELA_DIM , dtype = np .float32 )
145- self ._ela_cache_len = 0
146128
147129 obs = self ._build_observation ()
148130 info = {"problem_id" : problem_id , "dimension" : dim }
@@ -289,13 +271,6 @@ def _update_episode_state(self, result: dict, prev_best_y: float):
289271 )
290272
291273 def _build_observation (self ) -> np .ndarray :
292- # Recompute ELA only when enough new samples have arrived.
293- # _ela_cache starts as zeros (correct before 50 samples) and is reset
294- # each episode, so stale features from a previous episode never leak in.
295- current_len = len (self ._x_history ) if self ._x_history is not None else 0
296- if current_len >= 50 and current_len - self ._ela_cache_len >= _ELA_RECOMPUTE_THRESHOLD :
297- self ._ela_cache = compute_ela_features (self ._x_history , self ._y_history )
298- self ._ela_cache_len = current_len
299274
300275 return compute_observation (
301276 x_history = self ._x_history ,
@@ -307,5 +282,4 @@ def _build_observation(self) -> np.ndarray:
307282 max_fe = max (self ._max_fe , 1 ),
308283 stagnation_count = self ._stagnation_count ,
309284 ndim_problem = self ._problem .dimension if self ._problem is not None else 1 ,
310- ela = self ._ela_cache ,
311285 )
0 commit comments