Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,5 @@ BBOB*.zip
/stn/
/run/
/setup/
.vscode/
.vscode/
.python-version
101 changes: 101 additions & 0 deletions data.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
,id,fitness,name,description,configspace,generation,feedback,error,parent_ids,operator,metadata,task_prompt,method_name,problem_name,seed,_id,cummax_fitness,eval
0,18084962-51ed-4376-8b09-caa9e3c69568,5.955078389147237,AutoCorrCandidate,"Generates a nearly-optimal non-negative function by leveraging a piecewise-constant structure with optimized heights over a central region, tapering to zero at the edges to reduce autocorrelation.",,0,"C1 ratio = 5.95508, best known = 1.5053",,[],,{},"

Write a python class with function `__call__`, that returns a list of floats f of length N.
- Where N is number of bins over [-1/4, 1/4] with discretization of dx = 0.5 / N.
- Auto-convolution of `g = dx * conv(f, f, mode=""full"")`, where g lies in range [-1/2, 1/2].
- Optimise for objective of minimize max_t (f*f)(t) / (∫ f)^2, where all entries in the list f must be greater than or equal to 0 and do not normalise the f, scaling does not change the score.
- Symmetry or piecewise-constant structure is allowed if helpful.
- Set N = 600 as default.

",LLaMEA,auto_corr_ineq_1,0,0,5.955078389147237,1
1,43b5aacb-4de5-45a9-b846-f2331c03b92f,2.108060230292329,AutoCorrCandidate,"Refines the piecewise-constant function by optimizing the heights of the central, tapering, and edge regions to minimize autocorrelation.",,1,"C1 ratio = 2.10806, best known = 1.5053",,['18084962-51ed-4376-8b09-caa9e3c69568'],,{},"

Write a python class with function `__call__`, that returns a list of floats f of length N.
- Where N is number of bins over [-1/4, 1/4] with discretization of dx = 0.5 / N.
- Auto-convolution of `g = dx * conv(f, f, mode=""full"")`, where g lies in range [-1/2, 1/2].
- Optimise for objective of minimize max_t (f*f)(t) / (∫ f)^2, where all entries in the list f must be greater than or equal to 0 and do not normalise the f, scaling does not change the score.
- Symmetry or piecewise-constant structure is allowed if helpful.
- Set N = 600 as default.

",LLaMEA,auto_corr_ineq_1,0,1,5.955078389147237,2
2,f053dcc7-b434-43ac-a0d0-0167c7569ed2,2.244990298343852,AutoCorrCandidate,"Optimizes a piecewise-constant function with central flat, tapered, and constant-height edge regions, incorporating a dynamically adjusted sigmoid taper and refined parameter bounds to further minimize autocorrelation.",,2,"C1 ratio = 2.24499, best known = 1.5053",,['43b5aacb-4de5-45a9-b846-f2331c03b92f'],,{},"

Write a python class with function `__call__`, that returns a list of floats f of length N.
- Where N is number of bins over [-1/4, 1/4] with discretization of dx = 0.5 / N.
- Auto-convolution of `g = dx * conv(f, f, mode=""full"")`, where g lies in range [-1/2, 1/2].
- Optimise for objective of minimize max_t (f*f)(t) / (∫ f)^2, where all entries in the list f must be greater than or equal to 0 and do not normalise the f, scaling does not change the score.
- Symmetry or piecewise-constant structure is allowed if helpful.
- Set N = 600 as default.

",LLaMEA,auto_corr_ineq_1,0,2,5.955078389147237,3
3,dc80fb23-aa09-4b26-9a7a-1c0f535b08a9,2.14625421730855,AutoCorrCandidate,"Optimizes a piecewise-constant function with a central flat region, cosine tapers, and optimized edge values using a more robust optimizer and a refined parameterization, adding a small constant offset to avoid zero values, and using a larger number of iterations.",,3,"C1 ratio = 2.14625, best known = 1.5053",,['43b5aacb-4de5-45a9-b846-f2331c03b92f'],,{},"

Write a python class with function `__call__`, that returns a list of floats f of length N.
- Where N is number of bins over [-1/4, 1/4] with discretization of dx = 0.5 / N.
- Auto-convolution of `g = dx * conv(f, f, mode=""full"")`, where g lies in range [-1/2, 1/2].
- Optimise for objective of minimize max_t (f*f)(t) / (∫ f)^2, where all entries in the list f must be greater than or equal to 0 and do not normalise the f, scaling does not change the score.
- Symmetry or piecewise-constant structure is allowed if helpful.
- Set N = 600 as default.

",LLaMEA,auto_corr_ineq_1,0,3,5.955078389147237,4
4,7e44f5a8-b458-4b51-9e44-87cbd6e3307f,0.0,AutoCorrCandidate,Optimizes a piecewise-constant function with an added Gaussian component and refined tapering to minimize autocorrelation.,,4,calc-error Integral ∫f must be > 0 for C1,calc-failed,['43b5aacb-4de5-45a9-b846-f2331c03b92f'],,{},"

Write a python class with function `__call__`, that returns a list of floats f of length N.
- Where N is number of bins over [-1/4, 1/4] with discretization of dx = 0.5 / N.
- Auto-convolution of `g = dx * conv(f, f, mode=""full"")`, where g lies in range [-1/2, 1/2].
- Optimise for objective of minimize max_t (f*f)(t) / (∫ f)^2, where all entries in the list f must be greater than or equal to 0 and do not normalise the f, scaling does not change the score.
- Symmetry or piecewise-constant structure is allowed if helpful.
- Set N = 600 as default.

",LLaMEA,auto_corr_ineq_1,0,4,5.955078389147237,5
5,d236ef84-7086-4204-882b-7151cddc3692,2.072361474351445,AutoCorrCandidate,"Optimizes a piecewise-quadratic function with a central flat region, tapering quadratic sections, and constant edges to minimize autocorrelation.",,5,"C1 ratio = 2.07236, best known = 1.5053",,['43b5aacb-4de5-45a9-b846-f2331c03b92f'],,{},"

Write a python class with function `__call__`, that returns a list of floats f of length N.
- Where N is number of bins over [-1/4, 1/4] with discretization of dx = 0.5 / N.
- Auto-convolution of `g = dx * conv(f, f, mode=""full"")`, where g lies in range [-1/2, 1/2].
- Optimise for objective of minimize max_t (f*f)(t) / (∫ f)^2, where all entries in the list f must be greater than or equal to 0 and do not normalise the f, scaling does not change the score.
- Symmetry or piecewise-constant structure is allowed if helpful.
- Set N = 600 as default.

",LLaMEA,auto_corr_ineq_1,0,5,5.955078389147237,6
6,617268ca-e233-47c4-9a64-e6889dc5560b,2.000000000000122,AutoCorrCandidate,"Optimizes a piecewise-cubic function with smooth transitions between regions by directly controlling the function values at key points, aiming for a flatter autocorrelation peak.",,6,"C1 ratio = 2, best known = 1.5053",,['d236ef84-7086-4204-882b-7151cddc3692'],,{},"

Write a python class with function `__call__`, that returns a list of floats f of length N.
- Where N is number of bins over [-1/4, 1/4] with discretization of dx = 0.5 / N.
- Auto-convolution of `g = dx * conv(f, f, mode=""full"")`, where g lies in range [-1/2, 1/2].
- Optimise for objective of minimize max_t (f*f)(t) / (∫ f)^2, where all entries in the list f must be greater than or equal to 0 and do not normalise the f, scaling does not change the score.
- Symmetry or piecewise-constant structure is allowed if helpful.
- Set N = 600 as default.

",LLaMEA,auto_corr_ineq_1,0,6,5.955078389147237,7
7,01594200-c881-458f-b751-38ebd030cf6c,10.0,AutoCorrCandidate,"Optimizes a raised cosine function with adjustable parameters for a flatter autocorrelation peak, simplifying the parameter space for faster convergence.",,7,"C1 ratio = 10, best known = 1.5053",,['617268ca-e233-47c4-9a64-e6889dc5560b'],,{},"

Write a python class with function `__call__`, that returns a list of floats f of length N.
- Where N is number of bins over [-1/4, 1/4] with discretization of dx = 0.5 / N.
- Auto-convolution of `g = dx * conv(f, f, mode=""full"")`, where g lies in range [-1/2, 1/2].
- Optimise for objective of minimize max_t (f*f)(t) / (∫ f)^2, where all entries in the list f must be greater than or equal to 0 and do not normalise the f, scaling does not change the score.
- Symmetry or piecewise-constant structure is allowed if helpful.
- Set N = 600 as default.

",LLaMEA,auto_corr_ineq_1,0,7,10.0,8
8,06529ca8-7515-41b3-bfca-120341bfc009,2.000000000000957,AutoCorrCandidate,Optimize a piecewise-quadratic function with a central flat region and parabolic tapers to minimize autocorrelation peak relative to integrated function square.,,8,"C1 ratio = 2, best known = 1.5053",,['617268ca-e233-47c4-9a64-e6889dc5560b'],,{},"

Write a python class with function `__call__`, that returns a list of floats f of length N.
- Where N is number of bins over [-1/4, 1/4] with discretization of dx = 0.5 / N.
- Auto-convolution of `g = dx * conv(f, f, mode=""full"")`, where g lies in range [-1/2, 1/2].
- Optimise for objective of minimize max_t (f*f)(t) / (∫ f)^2, where all entries in the list f must be greater than or equal to 0 and do not normalise the f, scaling does not change the score.
- Symmetry or piecewise-constant structure is allowed if helpful.
- Set N = 600 as default.

",LLaMEA,auto_corr_ineq_1,0,8,10.0,9
9,f2400a0c-cca8-4bb5-9498-b669eb35e167,0.0,AutoCorrCandidate,Optimizes a piecewise-linear function with a central flat region and linearly decaying edges to minimize the autocorrelation peak relative to the integral squared.,,9,"exec-error could not broadcast input array from shape (240,) into shape (120,)",exec-failed,['617268ca-e233-47c4-9a64-e6889dc5560b'],,{},"

Write a python class with function `__call__`, that returns a list of floats f of length N.
- Where N is number of bins over [-1/4, 1/4] with discretization of dx = 0.5 / N.
- Auto-convolution of `g = dx * conv(f, f, mode=""full"")`, where g lies in range [-1/2, 1/2].
- Optimise for objective of minimize max_t (f*f)(t) / (∫ f)^2, where all entries in the list f must be greater than or equal to 0 and do not normalise the f, scaling does not change the score.
- Symmetry or piecewise-constant structure is allowed if helpful.
- Set N = 600 as default.

",LLaMEA,auto_corr_ineq_1,0,9,10.0,10
137 changes: 135 additions & 2 deletions iohblade/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
import os
from collections import Counter

import plotly.graph_objects as go

import jsonlines
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import plotly.graph_objects as go
import seaborn as sns
from scipy.stats import ttest_ind
from sklearn.decomposition import PCA
Expand Down Expand Up @@ -459,6 +458,140 @@ def plotly_code_evolution(
return fig


def code_diff_chain(
run_data: pd.DataFrame, solution_id: str
) -> list[dict[str, pd.Series | str]]:
"""Return diffs along the lineage of ``solution_id``.

The function follows the first parent of each solution until the root is
reached. For every parent-child pair a unified diff of their code is
produced.

Args:
run_data: DataFrame containing at least ``id``, ``parent_ids`` and
``code`` columns. ``name``, ``generation`` and ``fitness`` are
optional but will be preserved if present.
solution_id: Identifier of the final solution.

Returns:
A list of dictionaries ordered from the first ancestor to
``solution_id``. Each dictionary has ``parent`` and ``child`` keys with
the respective rows and a ``diff`` key containing a unified diff string.
"""

data = run_data.copy()
data["parent_ids"] = data["parent_ids"].apply(
lambda x: ast.literal_eval(x) if isinstance(x, str) else x
)
data = data.set_index("id", drop=False)
if solution_id not in data.index:
raise ValueError(f"Unknown solution_id: {solution_id}")

chain: list[dict[str, pd.Series | str]] = []
current = solution_id

while True:
row = data.loc[current]
parents = row["parent_ids"]
if not parents:
break
parent_id = parents[0]
parent_row = data.loc[parent_id]
parent_code = parent_row["code"]
current_code = row["code"]
parent_lines = parent_code.splitlines()
current_lines = current_code.splitlines()
diff_lines = difflib.unified_diff(
parent_lines,
current_lines,
fromfile=str(parent_id),
tofile=str(current),
lineterm="",
n=max(len(parent_lines), len(current_lines)),
)
chain.append(
{"parent": parent_row, "child": row, "diff": "\n".join(diff_lines)}
)
current = parent_id

chain.reverse()
return chain


def get_code_lineage(run_data: pd.DataFrame, solution_id: str) -> list[pd.Series]:
"""Return lineage of an individual with id ``solution_id``, across generation.

The function follows the first parent of each solution until the root is
reached. Generating a chin from first generation to the last generation.
Args:
run_data: DataFrame containing at least ``id``, ``parent_ids`` and
``code`` columns. ``name``, ``generation`` and ``fitness`` are
optional but will be preserved if present.
solution_id: Identifier of the final solution.

Returns:
A list of pd.Series `rows` that present individual lineage in ascending order, oldest -> newest.
"""
data = run_data.copy()
data["parent_ids"] = data["parent_ids"].apply(
lambda x: ast.literal_eval(x) if isinstance(x, str) else x
)
data = data.set_index("id", drop=False)
if solution_id not in data.index:
raise ValueError(f"Unknown solution_id: {solution_id}")

lineage: list[pd.Series] = []
id = solution_id
while id:
try:
parent = data.loc[data["id"] == id].iloc[0]
except:
parent = None
if parent is not None:
lineage.append(parent)
pid = parent["parent_ids"]
if pid:
id = pid[0]
else:
id = None
return lineage[::-1]


def print_code_diff_chain(run_data: pd.DataFrame, solution_id: str) -> None:
"""Print the code diff chain for ``solution_id``."""

chain = code_diff_chain(run_data, solution_id)
if not chain:
return
root = chain[0]["parent"]
print(
"Initial {p} (gen {pg}, fit {pf})".format(
p=root.get("name", root["id"]),
pg=root.get("generation", "?"),
pf=root.get("fitness", "?"),
)
)
print(root["code"])
print()
for step, entry in enumerate(chain, start=1):
parent = entry["parent"]
child = entry["child"]
diff = entry["diff"]
print(
"Step {step}: {p} (gen {pg}, fit {pf}) -> {c} (gen {cg}, fit {cf})".format(
step=step,
p=parent.get("name", parent["id"]),
pg=parent.get("generation", "?"),
pf=parent.get("fitness", "?"),
c=child.get("name", child["id"]),
cg=child.get("generation", "?"),
cf=child.get("fitness", "?"),
)
)
print(diff)
print()


def plot_boxplot_fitness(
logger: ExperimentLogger, y_label="Fitness", x_label="Method", problems=None
):
Expand Down
Loading