MCPcopy Index your code
hub / github.com/algorithmicsuperintelligence/openevolve / _is_novel

Method _is_novel

openevolve/database.py:1058–1099  ·  view source on GitHub ↗

Determine if a program is novel based on diversity to existing programs Args: program: Program to check island_idx: Island index Returns: True if novel, False otherwise

(self, program_id: int, island_idx: int)

Source from the content-addressed store, hash-verified

1056 return True
1057
1058 def _is_novel(self, program_id: int, island_idx: int) -> bool:
1059 """
1060 Determine if a program is novel based on diversity to existing programs
1061
1062 Args:
1063 program: Program to check
1064 island_idx: Island index
1065
1066 Returns:
1067 True if novel, False otherwise
1068 """
1069 if self.embedding_client is None or self.similarity_threshold <= 0.0:
1070 # Novelty checking disabled
1071 return True
1072
1073 program = self.programs[program_id]
1074 embd = self.embedding_client.get_embedding(program.code)
1075 self.programs[program_id].embedding = embd
1076
1077 max_smlty = float("-inf")
1078 max_smlty_pid = None
1079
1080 for pid in self.islands[island_idx]:
1081 other = self.programs[pid]
1082
1083 if other.embedding is None:
1084 logger.warning(
1085 f"Program {other.id} has no embedding, skipping similarity check"
1086 )
1087 continue
1088
1089 similarity = self._cosine_similarity(embd, other.embedding)
1090
1091 if similarity >= max(max_smlty, self.similarity_threshold):
1092 max_smlty = similarity
1093 max_smlty_pid = pid
1094
1095 if max_smlty_pid is None:
1096 # No similar programs found, consider it novel
1097 return True
1098
1099 return self._llm_judge_novelty(program, self.programs[max_smlty_pid])
1100
1101 def _is_better(self, program1: Program, program2: Program) -> bool:
1102 """

Callers 1

addMethod · 0.95

Calls 3

_cosine_similarityMethod · 0.95
_llm_judge_noveltyMethod · 0.95
get_embeddingMethod · 0.80

Tested by

no test coverage detected