Skip to content

Commit

Permalink
trial function, plan to integrate inspyredtk
Browse files Browse the repository at this point in the history
  • Loading branch information
jchen6727 committed May 21, 2024
1 parent a729916 commit 52e3032
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
3 changes: 3 additions & 0 deletions batchtk/inspyredtk/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@



10 changes: 10 additions & 0 deletions batchtk/inspyredtk/search.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from inspyred import ec
import random

ALGO = {
'DEA': ec.DEA,
'EDA': ec.EDA,
'ES': ec.ES,
'GA': ec.GA,
'SA': ec.SA,
}
23 changes: 19 additions & 4 deletions batchtk/runtk/trial.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
def trials():
pass
import types
import pandas
def trials(configs, label, gen, dispatcher_constructor, project_path, output_path, submit):
results = []
for tid, config in enumerate(configs):
results.append(trial(config, label, tid, dispatcher_constructor, project_path, output_path, submit))
return results


def trial(config, label, tid, dispatcher_constructor, project_path, output_path, submit):
run_label = '{}_{}'.format(label, tid)
trial.run_label = run_label
trial.output_path = output_path
for k, v in config.items(): #call any function pointers
if isinstance(v, types.FunctionType):
config[k] = v()
dispatcher = dispatcher_constructor(project_path=project_path, output_path=output_path, submit=submit,
gid=run_label)

dispatcher.update_env(dictionary=config)
try:
dispatcher.run()
Expand All @@ -17,4 +26,10 @@ def trial(config, label, tid, dispatcher_constructor, project_path, output_path,
dispatcher.clean()
raise (e)
data = pandas.read_json(data, typ='series', dtype=float)
return data
return data


LABEL_POINTER = lambda:trial.run_label


PATH_POINTER = lambda:trial.output_path

0 comments on commit 52e3032

Please sign in to comment.