Exemplo n.º 1
0
def simulate(samples, parallel):
    # create simulators
    simulators = {\
        TRProblem: {},
        SphereProblemOriginR1: {},
        SphereProblemOriginR2: {},
        SchwefelsProblem26: {}
    }

    for problem in problems:
        for optimizer in optimizers[problem]:
            simulators_op = []
            for i in range(0, samples):
                simulator = Simulator(optimizer(), problem(), termination)
                simulators_op.append(simulator)
            simulators[problem][optimizer] = simulators_op

    simulate = lambda simulator : simulator.simulate()

    # run simulators 
    for problem in problems:
        for optimizer, simulators_ in simulators[problem].iteritems():
            if(parallel):            
                resulting_simulators = pmap(simulate, simulators_)
            else:
                resulting_simulators = map(simulate, simulators_)
Exemplo n.º 2
0
from os.path import exists
from os import mkdir

from setup import *  

# create simulators
for problem in problems:
    for optimizer in optimizers[problem]:
        simulators_op = []
        for i in range(0, samples):
            simulator = Simulator(optimizer(), problem(), termination)
            simulators_op.append(simulator)
        simulators[problem][optimizer] = simulators_op

simulate = lambda simulator : simulator.simulate()

# run simulators 
for problem in problems:
    for optimizer, simulators_ in simulators[problem].iteritems():
        resulting_simulators = pmap(simulate, simulators_)
        for simulator in resulting_simulators:
            cfc = simulator.logger.all()['count_cfc']
            cfcs[problem][optimizer].append(cfc)
 
if not exists("output/"): 
    mkdir("output/")
 
cfc_file = open("output/cfcs_file.save", "w")
dump(cfcs, cfc_file)
cfc_file.close()
Exemplo n.º 3
0
from os.path import exists
from os import mkdir

from setup import *  

# create simulators
for problem in problems:
    optimizer = optimizers[problem]
    simulators_op = []
    for i in range(0, samples):
        simulator = Simulator(optimizer(), problem(), termination)
        simulators_op.append(simulator)
    simulators[problem] = simulators_op

simulate = lambda simulator : simulator.simulate()

# run simulators 
for problem in problems:
    resulting_simulators = pmap(simulate, simulators[problem])
    for simulator in resulting_simulators:
        cfcs[problem].append(simulator.logger.all()['count_cfc'])

if not exists("output/"): 
    mkdir("output/")
 
cfcs_file = open("output/cfcs_file.save", "w")
dump(cfcs, cfcs_file)
cfcs_file.close()