def express(self): result = [] self.ann.allConnections = self.values for world in self.population.goal: if self.population.is_visual: from gui_ann_runner import GuiAnnRunner runner = GuiAnnRunner(world, self.population.units_per_cell) else: runner = AnnRunner(world, self.population.units_per_cell) ideal_grid, actual_grid = runner.run(self.ann, iterations=self.population.printer_runtime) result.append((ideal_grid.grid, actual_grid.grid)) return result
def express(self): """Control the simulated 2d 3d-printer with this member of the population and evaluate the fitness of the output""" result = [] self.ann.allConnections = self.values for world in self.population.goal: if self.population.is_visual: from gui_ann_runner import GuiAnnRunner runner = GuiAnnRunner(world, self.population.cell_size, self.population.units_per_cell) else: runner = AnnRunner(world, self.population.cell_size, self.population.units_per_cell) ideal_grid, actual_grid = runner.run(self.ann, iterations=self.population.printer_runtime) result.append((ideal_grid.grid, actual_grid.grid)) return result
import getopt import sys helptext = 'run_from_file.py -A annfile -W worldfile -t time_to_run -u units_per_cell' try: opts, args = getopt.getopt(sys.argv[1:], "A:W:t:u:", ["ANNfile=", "Worldfile=", "time=", "units="]) except getopt.GetoptError: print helptext sys.exit() ann_file = None world_file = None num_iterations = 1000 units_per_cell = 20 for opt, arg in opts: if opt in ('-A', '--ANNfile'): ann_file = arg elif opt in ('-W', '--Worldfile'): world_file = arg elif opt in ('-t', '--time'): num_iterations = int(arg) elif opt in ('-u', '--units_per_cell'): units_per_cell = int(arg) n = ann_io.load(ann_file) ideal_grid = Grid(scale=30, path=world_file) runner = GuiAnnRunner(ideal_grid, units_per_cell=units_per_cell) runner.run(n, iterations=num_iterations)
from gui_ann_runner import GuiAnnRunner from grid import Grid import ann_io import sys import getopt import sys helptext = 'loopCurrentBest.py -A annfile -W worldfile' try: opts, args = getopt.getopt(sys.argv[1:], "A:W:", ["ANNfile=", "Worldfile="]) except getopt.GetoptError: print helptext sys.exit() ann_file = None world_file = None for opt, arg in opts: if opt in ('-A', '--ANNfile'): ann_file = arg elif opt in ('-W', '--Worldfile'): world_file = arg while(True): n = ann_io.load(ann_file) ideal_grid = Grid(scale=50, path=world_file) runner = GuiAnnRunner(ideal_grid) runner.run(n, iterations=1000)