Skip to content

Commit 4c4e621

Browse files
committed
Update task_adapter.py
1 parent 599cd54 commit 4c4e621

1 file changed

Lines changed: 19 additions & 12 deletions

File tree

examples/algotune/task_adapter.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -960,10 +960,11 @@ def replace_latex_command(match):
960960
# Replace LaTeX commands with their command names
961961
clean_description = re.sub(r'\\(\w+)(?:\{[^}]*\})?', replace_latex_command, clean_description)
962962

963-
# Handle YAML escape sequences properly
963+
# Handle YAML escape sequences properly - but keep newlines for block scalar
964964
clean_description = clean_description.replace('\\', '\\\\')
965965
clean_description = clean_description.replace('"', '\\"')
966-
clean_description = clean_description.replace('\n', '\\n')
966+
# Don't escape newlines - we'll use block scalar syntax
967+
# clean_description = clean_description.replace('\n', '\\n')
967968
clean_description = clean_description.replace('\t', '\\t')
968969
clean_description = clean_description.replace('\r', '\\r')
969970

@@ -992,16 +993,16 @@ def replace_latex_command(match):
992993
# If no good word boundary, truncate and ensure we don't break escape sequences
993994
clean_description = truncated.rstrip('\\') + "..."
994995

995-
# Insert the new system prompt before the task description
996+
# Insert the new system prompt before the task description - properly indented for block scalar
996997
system_prompt = (
997-
"SETTING:\n"
998-
"You're an autonomous programmer tasked with solving a specific problem. You are to use the commands defined below to accomplish this task. Every message you send incurs a cost—you will be informed of your usage and remaining budget by the system.\n"
999-
"You will be evaluated based on the best-performing piece of code you produce, even if the final code doesn't work or compile (as long as it worked at some point and achieved a score, you will be eligible).\n"
1000-
"Apart from the default Python packages, you have access to the following additional packages:\n"
1001-
" - cryptography\n - cvxpy\n - cython\n - dace\n - dask\n - diffrax\n - ecos\n - faiss-cpu\n - hdbscan\n - highspy\n - jax\n - networkx\n - numba\n - numpy\n - ortools\n - pandas\n - pot\n - psutil\n - pulp\n - pyomo\n - python-sat\n - pythran\n - scikit-learn\n - scipy\n - sympy\n - torch\n"
1002-
"Your primary objective is to optimize the `solve` function to run as as fast as possible, while returning the optimal solution.\n"
1003-
"You will receive better scores the quicker your solution runs, and you will be penalized for exceeding the time limit or returning non-optimal solutions.\n\n"
1004-
"Below you find the description of the task you will have to solve. Read it carefully and understand what the problem is and what your solver should do.\n\n"
998+
" SETTING:\n"
999+
" You're an autonomous programmer tasked with solving a specific problem. You are to use the commands defined below to accomplish this task. Every message you send incurs a cost—you will be informed of your usage and remaining budget by the system.\n"
1000+
" You will be evaluated based on the best-performing piece of code you produce, even if the final code doesn't work or compile (as long as it worked at some point and achieved a score, you will be eligible).\n"
1001+
" Apart from the default Python packages, you have access to the following additional packages:\n"
1002+
" - cryptography\n - cvxpy\n - cython\n - dace\n - dask\n - diffrax\n - ecos\n - faiss-cpu\n - hdbscan\n - highspy\n - jax\n - networkx\n - numba\n - numpy\n - ortools\n - pandas\n - pot\n - psutil\n - pulp\n - pyomo\n - python-sat\n - pythran\n - scikit-learn\n - scipy\n - sympy\n - torch\n"
1003+
" Your primary objective is to optimize the `solve` function to run as as fast as possible, while returning the optimal solution.\n"
1004+
" You will receive better scores the quicker your solution runs, and you will be penalized for exceeding the time limit or returning non-optimal solutions.\n\n"
1005+
" Below you find the description of the task you will have to solve. Read it carefully and understand what the problem is and what your solver should do.\n\n"
10051006
)
10061007
config = f'''# Configuration for {task_name} task with baseline comparison
10071008
max_iterations: 100
@@ -1021,7 +1022,13 @@ def replace_latex_command(match):
10211022
10221023
# Prompt configuration
10231024
prompt:
1024-
system_message: "{system_prompt}You are an expert programmer specializing in {category} algorithms. Your task is to improve the {task_name} algorithm implementation with baseline comparison. The problem description is: {clean_description}. Focus on improving the solve method to correctly handle the input format and produce valid solutions efficiently. Your solution will be compared against the reference AlgoTune baseline implementation to measure speedup and correctness."
1025+
system_message: |
1026+
{system_prompt} You are an expert programmer specializing in {category} algorithms. Your task is to improve the {task_name} algorithm implementation with baseline comparison.
1027+
1028+
The problem description is:
1029+
{clean_description}
1030+
1031+
Focus on improving the solve method to correctly handle the input format and produce valid solutions efficiently. Your solution will be compared against the reference AlgoTune baseline implementation to measure speedup and correctness.
10251032
num_top_programs: 3
10261033
use_template_stochasticity: true
10271034

0 commit comments

Comments
 (0)