text stringlengths 0 93.6k |
|---|
if self.parent: |
self.parent.add_resource(response) |
def process_current_task(self): |
if self.current_task_idx == len(self.tasks): |
self.current_task_idx = 0 |
if all([(isinstance(task, str) or task.done) for task in self.tasks]): |
self.try_objective() |
self.done = True |
if not self.done: |
current_task = self.tasks[self.current_task_idx] |
if isinstance(current_task, str): |
self.tasks[self.current_task_idx] = Objective( |
current_task, |
self.current_task_idx, |
self.recursion_level + 1, |
self.state, |
parent=self |
) |
self.current_task_idx += 1 |
if self.current_task_idx == len(self.tasks): |
self.current_task_idx = 0 |
if self.parent: |
self.parent.current_task_idx += 1 |
else: |
current_task.process_current_task() |
else: |
if self.parent: |
self.parent.current_task_idx += 1 |
def to_string(self, select): |
html_string = f'OBJECTIVE: {escape(self.objective)}<ul class="oobaAgentOutput">' |
for task in self.tasks: |
thinking = False |
p_it = self |
task_idx = p_it.tasks.index(task) if isinstance(task, str) else task.parent_task_idx |
while ((p_it.current_task_idx % len(p_it.tasks)) == task_idx): |
if not p_it.parent: |
thinking = True |
break |
task_idx = p_it.parent_task_idx |
p_it = p_it.parent |
task_disp_class = "oobaAgentOutputThinking" if thinking and select else "oobaAgentOutput" |
if isinstance(task, str): |
html_string += f'<li class="{task_disp_class}">{escape(task)}</li>' |
else: |
html_string += f'<li class="{task_disp_class}">{task.to_string(select)}</li>' |
for out in self.output: |
html_string += f'<li class="oobaAgentOutputResource">{escape(out)}</li>' |
html_string += "</ul>" |
return html_string |
# <FILESEP> |
""" |
Main file for setting up experiments, and compiling results. |
@authors: James Robert Lloyd (jrl44@cam.ac.uk) |
Created May 2015 |
""" |
# TODO |
# - use zeromq communication |
# - make stacking tree code stuff easy - add weights as features that are recorded |
# - try a test e.g. cycle vs freeze thaw |
# - reintroduce database |
import os |
import sys |
import psutil |
import logging |
from multiprocessing import Process |
import numpy as np |
import select |
import signal |
from managers import FixedLearnersStackingManager |
import agent |
import constants |
import util |
def load_experiment_details(filename): |
"""Just loads the exp dictionary""" |
exp_string = open(filename, 'r').read() |
exp = eval(exp_string) |
exp = exp_param_defaults(exp) |
return exp |
def run_experiment_file(filename, plot_override=True, separate_process=False): |
""" |
This is intended to be the function that's called to initiate a series of experiments. |
""" |
exp = load_experiment_details(filename=filename) |
print('BEGIN EXPERIMENT SPECIFICATIONS') |
print(exp_params_to_str(exp)) |
print('END EXPERIMENT SPECIFICATIONS') |
# # Set number of processors |
p = psutil.Process() |
all_cpus = list(range(psutil.cpu_count()-1)) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.