def evaluate(self): for chunknum, chunk in zip(range(len(self.parallelizer.chunks)), self.parallelizer.chunks): write_to = self.source_folder + '/' + self.source + str(self.generation) + 'chunk:' + repr(chunknum)+ '.lisp' lisp.start_writing(write_to) lisp.comment("----Automatically generated code") lisp.comment("----Autogened by agents.py - Joe Doliner") lisp.comment("----Generated on: " + str(datetime.date.today())) lisp.comment("------------- at: " + time.strftime('%H:%M:%S', time.localtime(time.time()))) for agent in chunk: if(agent.argcount == self.datumlength): stream_to = self.source_folder + '/' + self.stream + '_' + str(self.generation) + '_' + agent.name agent.stream = stream_to lisp.comment("Opening file... " + stream_to) lisp.open_stream(stream_to) lisp.lprint("Evaluating " + agent.client.name + "...") lisp.comment("Code to evaluate agent " + agent.name) for datum in self.data: agent.evaluate(datum) lisp.close_stream() lisp.comment("----Evaluation ends here") lisp.comment("----signal that the evaluation has ended to the host") #the following writes code to signal the grader when it's done lisp.comment("Opening fifo..." + self.parallelizer.fifo) lisp.open_stream(self.parallelizer.fifo) lisp.streamprint("'" + str(chunknum)) lisp.close_stream() lisp.stop_writing() if(self.required): self.parallelizer.load_file(chunknum, self.required) self.parallelizer.load_file(chunknum, write_to)
def code(self): sourcename = self.source_folder + '/' + self.source_string + '_' + str(self.generation) + '.lisp' bytecodename = self.source_folder + '/' + self.source_string + '_' + str(self.generation) + '.fas' lisp.start_writing(sourcename) lisp.comment("Code to implement generation " + str(self.generation)) if (self.required != None): lisp.load(self.required) for agent in self.population: lisp.defun(agent.client) lisp.stop_writing() #lisp.compile(sourcename) self.required = bytecodename return [sourcename, bytecodename] #returns the bytecode and the source as both are needed