Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
954051f
cleaned up imports, regenerated requirements, removed compiled files …
SpyroL7 Feb 17, 2026
81d00c0
formatting
SpyroL7 Feb 19, 2026
36c6c95
added gbb construct method to CodeConstructor, added method to genera…
SpyroL7 Feb 20, 2026
abccb17
hill climbing now swaps rather than flips bits for gbb codes, modifie…
SpyroL7 Feb 25, 2026
6f2a082
allowed code type to be optionally passed as the first arg to BOplayg…
SpyroL7 Feb 25, 2026
bb6521d
bug fixes: gbb codes now run
SpyroL7 Feb 25, 2026
04fd891
results from first GBB experiment, plus notebook to view results
SpyroL7 Mar 6, 2026
eb21351
added function to generate gb codes from a list of parameters
SpyroL7 Mar 25, 2026
fbf2b57
added code to generate new starting gb codes, excluding selection of …
SpyroL7 Mar 25, 2026
0a5c27a
modifed hill climbing to find different qa and qb factors for a(x) an…
SpyroL7 Mar 26, 2026
d2ddb2c
bug fixes for gb, modified main loop to support additional gb paramet…
SpyroL7 Apr 1, 2026
06dcf36
added some tests and bug fixes. tests work, but BO stuff (untested as…
SpyroL7 Apr 15, 2026
fba25f1
small refactor plus removed clamp and promoted floats that deal with …
SpyroL7 Apr 16, 2026
c54fd10
formatting + removed gbb codes (not valid)
SpyroL7 Apr 16, 2026
2fa381f
added a new standard normalizer for a mode where the GP predicts dist…
SpyroL7 Apr 16, 2026
794e4b8
moved to new file + formatting
SpyroL7 Apr 16, 2026
4ea5b18
updated objective function so flag can be used to select distance or …
SpyroL7 Apr 17, 2026
e0ff09b
renamed some references to pl in logging, removed clamp on logged dis…
SpyroL7 Apr 18, 2026
d196990
improved arg parsing for upcoming features that require various options
SpyroL7 Apr 20, 2026
7f58be0
bug fixes and code to support distance estimation with codeDistance l…
SpyroL7 Apr 20, 2026
c9ca1e7
added some tests for new distance and estimated distance evaluation m…
SpyroL7 Apr 21, 2026
e6babf8
added configurable timeout to exact distance calculations
SpyroL7 Apr 21, 2026
fbd40be
fixed tests, bug fixes, and arg validation
SpyroL7 Apr 22, 2026
1875992
arg bug fix, small test change, formatting
SpyroL7 Apr 27, 2026
b72bfb9
small args fix
SpyroL7 Apr 30, 2026
ab07ca4
small optimisations
SpyroL7 May 1, 2026
5e03b17
changed internal rep of all parameters to be binary arrays, and chang…
SpyroL7 May 4, 2026
90c8ced
fixed issues with int to binary vector migration, updated tests in te…
SpyroL7 May 5, 2026
e85d230
changed GB representation to flattened binary array as BO code was me…
SpyroL7 May 6, 2026
4f52337
fixed edge case where no neighbours can be found, prints warning and …
SpyroL7 May 9, 2026
6c5d6ef
reverted floats to 32bit from 64, tidied up, read_results can now est…
SpyroL7 May 11, 2026
8fa2ca7
evaluation bug fixes
SpyroL7 May 18, 2026
ff1e79e
updated requirements and setup to be more robust
SpyroL7 May 21, 2026
0a70426
small installation fix
SpyroL7 Jun 5, 2026
3ca3c6c
notebooks and scripts for evaluating qeccs and making graphs
SpyroL7 Jun 5, 2026
b7524cf
uploaded best codes and updated notebook paths
SpyroL7 Jun 5, 2026
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
Binary file added .gitignore
Binary file not shown.
1,169 changes: 753 additions & 416 deletions BOplayground.py

Large diffs are not rendered by default.

77 changes: 45 additions & 32 deletions EAplayground.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
# Evolutionary algorim
from code_construction.code_construction import CodeConstructor
import numpy as np
from evolutionary_algorithm.ea import BivariateBicycleCodeEvolutionaryOptimization
from pymoo.operators.crossover.sbx import SBX
from pymoo.operators.mutation.pm import PM
from pymoo.operators.repair.rounding import RoundingRepair
from pymoo.operators.sampling.rnd import IntegerRandomSampling
from pymoo.algorithms.soo.nonconvex.ga import GA
from pymoo.operators.crossover.ux import UniformCrossover
from pymoo.optimize import minimize
Expand All @@ -18,22 +15,27 @@
# print(undetectable_error_rate.evaluate(p=0.01))
from pymoo.core.sampling import Sampling
import sys


if len(sys.argv) == 3:
seed= int(sys.argv[1])
dataset_index = int(sys.argv[2])
lambda_ = 1
elif len(sys.argv) >3:
seed= int(sys.argv[1])
seed = int(sys.argv[1])
dataset_index = int(sys.argv[2])
lambda_ = 1
elif len(sys.argv) > 3:
seed = int(sys.argv[1])
dataset_index = int(sys.argv[2])
lambda_ = float(sys.argv[3])
else:
seed = 42
dataset_index = 0
lambda_ = 1

l=12
g=6
print(f'(l,g)=({l},{g}), dataset_index = {dataset_index}, seed={seed}, lambda = {lambda_}')
l = 12
g = 6
print(
f"(l,g)=({l},{g}), dataset_index = {dataset_index}, seed={seed}, lambda = {lambda_}"
)


class MySampling(Sampling):
def __init__(self, init_samples):
Expand All @@ -42,38 +44,47 @@ def __init__(self, init_samples):

def _do(self, problem, n_samples, **kwargs):
return self.init_samples
para_dict = {'l':l,'g':g}
code_class = 'bb'


code_constructor = CodeConstructor(method=code_class,para_dict = para_dict)
para_dict = {"l": l, "g": g}
code_class = "bb"


code_constructor = CodeConstructor(method=code_class, para_dict=para_dict)
# define objective function
pp=0.05
Obj_Func = ObjectiveFunction(code_constructor,lambda_=lambda_, pp=pp,decoder_param={'trail':10_000})
pp = 0.05
Obj_Func = ObjectiveFunction(
code_constructor, lambda_=lambda_, pp=pp, decoder_param={"trail": 10_000}
)
obj_func = Obj_Func.forward
if l ==6 and g==3:
init_data_file = f"./data/BO_initial_points/BO_initial_points_{dataset_index}_{lambda_}_63.pkl"
if l == 6 and g == 3:
init_data_file = (
f"./data/BO_initial_points/BO_initial_points_{dataset_index}_{lambda_}_63.pkl"
)
else:
init_data_file = f"./data/BO_initial_points/BO_initial_points_{dataset_index}_{lambda_}.pkl"
init_data_file = (
f"./data/BO_initial_points/BO_initial_points_{dataset_index}_{lambda_}.pkl"
)
# file with 63 suffix has (l,m)=(6,3). Otherwise (l,m)=(12,6)
with open(init_data_file, "rb") as f:
data = pickle.load(f)
X_init = data['X']
y_init = data['y']
pl_init = data['pl']
problem = BivariateBicycleCodeEvolutionaryOptimization(l=l,m=g,obj_func=Obj_Func)
X_init = data["X"]
y_init = data["y"]
pl_init = data["pl"]
problem = BivariateBicycleCodeEvolutionaryOptimization(l=l, m=g, obj_func=Obj_Func)
algorithm = GA(
pop_size=20,
sampling=MySampling(X_init),
crossover=UniformCrossover(prob=1.0),
mutation=PM(prob=1.0, eta=3.0, vtype=float, repair=RoundingRepair()),
eliminate_duplicates=True
eliminate_duplicates=True,
)

res = minimize(problem,
algorithm,
termination=('n_gen', 11),
seed=seed,
res = minimize(
problem,
algorithm,
termination=("n_gen", 11),
seed=seed,
)
flat2 = [-v for row in problem.evaluation_history for v in row]

Expand All @@ -82,10 +93,12 @@ def _do(self, problem, n_samples, **kwargs):
print(problem.best_parameters)
print("Best solution found: \nX = %s\nF = %s" % (res.X, -res.F))

with open(f'./data/BO_results/EA_{l}_{g}_{dataset_index}_{seed}_{lambda_}.pkl','wb') as f:
with open(
f"./data/BO_results/EA_{l}_{g}_{dataset_index}_{seed}_{lambda_}.pkl", "wb"
) as f:
results = {
'best_x':problem.best_parameters,
'best_y':problem.best_result,
'evaluation_history':flat2,
"best_x": problem.best_parameters,
"best_y": problem.best_result,
"evaluation_history": flat2,
}
pickle.dump(results, f)
Loading