def start_sequential_strategy(wf): """ executes all experiments from the definition file """ info("> ExecStrategy | Sequential", Fore.CYAN) wf.totalExperiments = len(wf.execution_strategy["knobs"]) for kn in wf.execution_strategy["knobs"]: experimentFunction(wf, { "knobs":kn, "ignore_first_n_results": wf.execution_strategy["ignore_first_n_results"], "sample_size": wf.execution_strategy["sample_size"], })
def start_forever_strategy(wf): """ executes forever - changes must come from definition file """ info("> ExecStrategy | Forever ", Fore.CYAN) wf.totalExperiments = -1 while True: experimentFunction( wf, { "knobs": { "forever": True }, "ignore_first_n_results": wf.execution_strategy["ignore_first_n_results"], "sample_size": wf.execution_strategy["sample_size"], })
def evolutionary_execution(wf, opti_values, variables): global crowdnav_instance_number """ this is the function we call and that returns a value for optimization """ knob_object = recreate_knob_from_optimizer_values(variables, opti_values) # create a new experiment to run in execution exp = dict() # TODO where do we start multiple threads to call the experimentFunction concurrently, once for each experiment and crowdnav instance? # TODO should we create new/fresh CrowdNav instances for each iteration/generation? Otherwise, we use the same instance to evaluate across interations/generations to evaluate individiuals. if wf.execution_strategy["parallel_execution_of_individuals"]: wf.primary_data_provider[ "instance"].topic = original_primary_data_provider_topic + "-" + str( crowdnav_instance_number) wf.change_provider[ "instance"].topic = original_change_provider_topic + "-" + str( crowdnav_instance_number) info("Listering on " + wf.primary_data_provider["instance"].topic) info("Posting changes to " + wf.change_provider["instance"].topic) crowdnav_instance_number = crowdnav_instance_number + 1 if crowdnav_instance_number == wf.execution_strategy[ "population_size"]: crowdnav_instance_number = 0 exp["ignore_first_n_results"] = wf.execution_strategy[ "ignore_first_n_results"] exp["sample_size"] = wf.execution_strategy["sample_size"] exp["knobs"] = knob_object # the experiment function returns what the evaluator in definition.py is computing return experimentFunction(wf, exp)
def start_seq_runtime_stategy(wf): """ executes all experiments from the definition file """ info("> ExecStrategy | SequentialRuntimeConfigs", Fore.CYAN) retrieve_true_knobs(wf) #the regular sequential code starts here wf.totalExperiments = len(wf.execution_strategy["knobs"]) for kn in wf.execution_strategy["knobs"]: experimentFunction(wf, { "knobs":kn, "ignore_first_n_results": wf.execution_strategy["ignore_first_n_results"], "sample_size": wf.execution_strategy["sample_size"], })
def self_optimizer_execution(wf, opti_values, variables): """ this is the function we call and that returns a value for optimization """ knob_object = recreate_knob_from_optimizer_values(variables, opti_values) # create a new experiment to run in execution exp = dict() exp["ignore_first_n_results"] = wf.execution_strategy[ "ignore_first_n_results"] exp["sample_size"] = wf.execution_strategy["sample_size"] exp["knobs"] = knob_object return experimentFunction(wf, exp)
def arm_experiment(wf, arm): return experimentFunction( wf, { "knobs": { "config": arm }, "ignore_first_n_results": wf.execution_strategy["ignore_first_n_results"], "sample_size": wf.execution_strategy["sample_size"] })
def step_execution(wf, configuration, variables): """ runs a single step_execution experiment """ knob_object = recreate_knob_from_step_explorer_values( variables, configuration) # create a new experiment to run in execution exp = dict() exp["ignore_first_n_results"] = wf.execution_strategy[ "ignore_first_n_results"] exp["sample_size"] = wf.execution_strategy["sample_size"] exp["knobs"] = knob_object return experimentFunction(wf, exp)
def effector(wf, action): print("\n\n\n\n\nEffecting action " + action + "\n\n\n\n\n") wf.primary_data_provider["last_action"] = action.split()[0] return experimentFunction( wf, { "knobs": action, "ignore_first_n_results": wf.execution_strategy["ignore_first_n_results"], "sample_size": wf.execution_strategy["sample_size"] })