def __init__(self, conf_file, pattern_file): self.conf_file = conf_file self.pattern_file = pattern_file self.loaded_modules = module_loader(conf_file) # load desired automaton from serialized file self.pattern = load_pattern(pattern_file) # load all important properties self.dimensions = (self.pattern.width, self.pattern.height) self.resolution = self.pattern.resolution stop_crit = self.loaded_modules["stopcriterion"]["criterion"] stop_crit_args = dict([(arg, val) for arg,val in self.loaded_modules["stopcriterion"].items() if arg != "criterion"]) self.stop_criterion = stop_crit(**stop_crit_args) self.max_difference = self.get_max_difference(self.pattern) self.min_error = 1.0 self.best_weights = None self.lattice_age = 0 self.lattice_age_list = [] self.progress = [] self.callback = None
def create_automaton(conf_file): """ Loads configuration file and creates lattice based on parameters :param conf_file: config file describing cellular automata :return: lattice instance """ conf = module_loader(conf_file) lattice_class = conf["lattice"]["type"] lattice = lattice_class.create_initialized(conf) return lattice
def __init__(self, cfg, callback=None): self.conf = module_loader(cfg) self.callback = callback objective_class = self.conf["evolution"]["objective"] pattern_file = self.conf["evolution"]["pattern"] self.objective = objective_class(cfg, pattern_file) self.objective.callback = self.callback2 self.strategy = self.conf["evolution"]["strategy"]