[Paper Review] Rethinking Code Similarity for Automated Algorithm Design with LLMs
The paper introduces BehaveSim, a behavioral similarity metric for algorithms based on problem-solving trajectories and dynamic time warping, to better assess algorithmic similarity in LLM-AAD settings.
The rise of Large Language Model-based Automated Algorithm Design (LLM-AAD) has transformed algorithm development by autonomously generating code implementations of expert-level algorithms. Unlike traditional expert-driven algorithm development, in the LLM-AAD paradigm, the main design principle behind an algorithm is often implicitly embedded in the generated code. Therefore, assessing algorithmic similarity directly from code, distinguishing genuine algorithmic innovation from mere syntactic variation, becomes essential. While various code similarity metrics exist, they fail to capture algorithmic similarity, as they focus on surface-level syntax or output equivalence rather than the underlying algorithmic logic. We propose BehaveSim, a novel method to measure algorithmic similarity through the lens of problem-solving behavior as a sequence of intermediate solutions produced during execution, dubbed as problem-solving trajectories (PSTrajs). By quantifying the alignment between PSTrajs using dynamic time warping (DTW), BehaveSim distinguishes algorithms with divergent logic despite syntactic or output-level similarities. We demonstrate its utility in two key applications: (i) Enhancing LLM-AAD: Integrating BehaveSim into existing LLM-AAD frameworks (e.g., FunSearch, EoH) promotes behavioral diversity, significantly improving performance on three AAD tasks. (ii) Algorithm analysis: BehaveSim clusters generated algorithms by behavior, enabling systematic analysis of problem-solving strategies--a crucial tool for the growing ecosystem of AI-generated algorithms. Data and code of this work are open-sourced at https://github.com/RayZhhh/behavesim.
Motivation & Objective
- Motivate the need to measure algorithmic similarity from the perspective of problem-solving behavior in LLM-AAD.
- Propose a behavioral similarity metric (BehaveSim) based on problem-solving trajectories (PSTrajs).
- Demonstrate how PSTrajs-aligned similarity improves diversity and performance in LLM-AAD frameworks.
- Show how BehaveSim enables quantitative analysis and clustering of AI-generated algorithms.
Proposed method
- Define problem-solving trajectory (PSTraj) as a sequence of intermediate solutions produced during execution.
- Measure behavioral similarity by computing pairwise distances between PSTrajs using Dynamic Time Warping (DTW).
- Contrast BehaveSim with static (token/structure/embedding) and execution-based similarity measures.
- Integrate BehaveSim into LLM-AAD frameworks (e.g., FunSearch, EoH) to promote behavioral diversity.
- Provide open-source data and code at the provided GitHub repository.

Experimental results
Research questions
- RQ1Can problem-solving trajectories capture underlying algorithmic logic beyond surface syntax or outputs?
- RQ2Does BehaveSim improve performance of existing LLM-AAD methods by promoting behavioral diversity?
- RQ3Can BehaveSim cluster AI-generated algorithms by problem-solving behavior for quantitative analysis?
Key findings
- BehaveSim differentiates algorithms with divergent problem-solving behaviors despite similar code structure or outputs.
- Integrating BehaveSim into FunSearch and EoH enhances performance on three AAD tasks.
- BehaveSim enables clustering of generated algorithms by behavior, aiding analysis of problem-solving strategies.

Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.