File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1316,6 +1316,15 @@ def suggest(
13161316 ]
13171317 self .previous_candidates = np .array (x_max )
13181318 idx = self ._sample_idx_from_softmax_gains (random_state = random_state )
1319+ if not target_space ._allow_duplicate_points and x_max [idx ] in target_space :
1320+ # If every candidate is a duplicate, keep the original choice.
1321+ # Avoiding duplicates then requires generating new candidates, which
1322+ # is outside GPHedge's candidate-selection responsibility.
1323+ non_duplicate_idx = [idx for idx , x in enumerate (x_max ) if x not in target_space ]
1324+ if len (non_duplicate_idx ) > 0 :
1325+ cumsum_softmax_g = np .cumsum (softmax (self .gains [non_duplicate_idx ]))
1326+ r = random_state .rand ()
1327+ idx = non_duplicate_idx [np .argmax (r <= cumsum_softmax_g )]
13191328 return x_max [idx ]
13201329
13211330 def get_acquisition_params (self ) -> dict [str , Any ]:
You can’t perform that action at this time.
0 commit comments