def runComputationAtPoint(worker, params, evsAdditionalParams, parallelClients=1): print('Running evs-arrowbots pair with the following parameters: ' + str(params)) parsedParams = tal.classifyDictWithRegexps(params, cl.serverClientClassifier) serverParams = tal.sumOfDicts(parsedParams['server'], evsAdditionalParams) print('Server params: ' + str(serverParams)) #clientParams = tal.sumOfDicts(parsedParams['client'], arrowbotsAdditionalParams) #print('Client params: ' + str(clientParams)) tiniw.write(serverParams, cl.evsClassifier, 'evs.ini') #tiniw.write(clientParams, classifiers.arrowbotsClassifier, 'arrowbot.ini') #tfio.writeColumns(arrowbotInitialConditions, 'initialConditions.dat') #tfio.writeColumns(arrowbotTargetOrientations, 'targetOrientations.dat') geneFifos = [] evalFifos = [] for i in range(parallelClients): geneFifos.append(tfs.makeUniqueFifo('.', 'indiv' + str(i))) evalFifos.append(tfs.makeUniqueFifo('.', 'evals' + str(i))) clientProcs = [] for gf, ef in zip(geneFifos, evalFifos): clientProcs.append(worker.spawnProcess([cr.python3, cr.evaluatorExecutable, gf, ef])) if not worker.runCommand([cr.evsExecutable, 'evals', 'indiv', str(serverParams['randomSeed']), 'evs.ini']): return False for cp in clientProcs: worker.killProcess(cp, label='client') for gf, ef in zip(geneFifos, evalFifos): os.remove(gf) os.remove(ef) # TODO: Validation of the obtained files here return True
def runComputationAtPoint(worker, params): print('Running evs-arrowbots pair with the following parameters: ' + str(params)) parsedParams = tal.classifyDict(params, classifiers.serverClientClassifier) serverParams = tal.sumOfDicts(parsedParams['server'], evsAdditionalParams) clientParams = tal.sumOfDicts(parsedParams['client'], arrowbotsAdditionalParams) tiniw.write(serverParams, classifiers.evsClassifier, 'evs.ini') tiniw.write(clientParams, classifiers.arrowbotsClassifier, 'arrowbot.ini') tfio.writeColumns(arrowbotInitialConditions, 'initialConditions.dat') tfio.writeColumns(arrowbotTargetOrientations, 'targetOrientations.dat') geneFifo = tfs.makeUniqueFifo('.', 'genes') evalFifo = tfs.makeUniqueFifo('.', 'evals') clientProc = worker.spawnProcess( [mmr.arrowbotsExecutable, geneFifo, evalFifo]) if not worker.runCommand([ mmr.evsExecutable, evalFifo, geneFifo, str(serverParams['randomSeed']), 'evs.ini' ]): return False worker.killProcess(clientProc) # TODO: Validation of the obtained files here return True