Class: GEPA::Strategies::ParetoCandidateSelector

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/gepa/strategies/candidate_selector.rb

Instance Method Summary collapse

Constructor Details

#initialize(rng: nil, telemetry: nil) ⇒ ParetoCandidateSelector

Returns a new instance of ParetoCandidateSelector.



11
12
13
14
# File 'lib/gepa/strategies/candidate_selector.rb', line 11

def initialize(rng: nil, telemetry: nil)
  @rng = rng || Random.new(0)
  @telemetry = telemetry
end

Instance Method Details

#select_candidate_idx(state) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/gepa/strategies/candidate_selector.rb', line 17

def select_candidate_idx(state)
  ensure_lengths!(state)
  with_span('gepa.strategies.candidate_selector', strategy: 'pareto') do
    scores = state.per_program_tracked_scores.each_with_index.to_h { |score, idx| [idx, score] }
    GEPA::Utils::Pareto.select_program_candidate_from_pareto_front(
      state.program_at_pareto_front_valset,
      scores,
      @rng
    )
  end
end