def main():

    # Obtain SBML model from Biomodels and populate Road Runner
    model = urllib.request.urlopen('http://www.ebi.ac.uk/biomodels-main/download?mid=BIOMD0000000299')
    sbml = model.read().decode('utf-8')
    rr = roadrunner.RoadRunner(sbml)

    # Run the simulation and produce some fake experiment data.  If you have
    # actual experiment data you will not need to run this simulation.
    rr.resetToOrigin()
    rr.timeCourseSelections = ['time', 'M', 'FC', 'FN']
    fake_experiment_data = rr.simulate(0, 96, 97)

    # Reduce the experiment data to be the data from 48 hours
    # onwards when limit cycle has been reached and remove the
    # time from the experiment data
    fake_experiment_data = np.array(fake_experiment_data[48:, 1:])

    # Now run NMMSO to find the modes
    nmmso = Nmmso(UniformRangeProblem(SbmlModelProblem(sbml, fake_experiment_data)), 10)
    nmmso.add_listener(TraceListener(1))
    my_result = nmmso.run(50000)

    for mode_result in my_result:
        print("Mode at {} has value {}".format(mode_result.location, mode_result.value))
Beispiel #2
0
def main():
    number_of_fitness_evaluations = 1000
    nmmso = Nmmso(MyProblem())
    nmmso.add_listener(TraceListener(level=2))
    my_result = nmmso.run(number_of_fitness_evaluations)
    for mode_result in my_result:
        print("Mode at {} has value {}".format(mode_result.location,
                                               mode_result.value))
def main():
    number_of_fitness_evaluations = 1000
    num_workers = 4
    with MultiprocessorFitnessCaller(
            num_workers) as my_multi_processor_fitness_caller:
        nmmso = Nmmso(MyProblem(),
                      fitness_caller=my_multi_processor_fitness_caller)
        my_result = nmmso.run(number_of_fitness_evaluations)

    for mode_result in my_result:
        print("Mode at {} has value {}".format(mode_result.location,
                                               mode_result.value))
def main():
    number_of_fitness_evaluations = 1000
    problem = UniformRangeProblem(MyProblem())
    nmmso = Nmmso(problem)
    my_result = nmmso.run(number_of_fitness_evaluations)
    for mode_result in my_result:
        print("Mode at {} has value {}".format(mode_result.location, mode_result.value))

    # The internals of the Nmmso object will be in the uniform parameter space
    for swarm in nmmso.swarms:
        print("Swarm id: {} uniform parameter space location : {}  original parameter space location: {}".format(
            swarm.id, swarm.mode_location, problem.remap_parameters(swarm.mode_location)))
Beispiel #5
0
def main():
    number_of_fitness_evaluations = 1000

    nmmso = Nmmso(MyProblem())

    while nmmso.evaluations < number_of_fitness_evaluations:
        nmmso.iterate()
        for swarm in nmmso.swarms:
            print("Swarm {} has {} particles.".format(
                swarm.id, swarm.number_of_particles))

    for mode_result in nmmso.get_result():
        print("Mode at {} has value {}".format(mode_result.location,
                                               mode_result.value))
Beispiel #6
0
def main():
    number_of_fitness_evaluations = 5000

    nmmso = Nmmso(My2DProblem())

    parallel_predictor = ParallelPredictorListener()
    nmmso.add_listener(parallel_predictor)

    nmmso.run(number_of_fitness_evaluations)

    for mode_result in nmmso.get_result():
        print("Mode at {} has value {}".format(mode_result.location,
                                               mode_result.value))

    parallel_predictor.print_summary()
Beispiel #7
0
def nmmso_runner(func_num, benchmarking=False):

    # Simplest way of running a multiprocessing job is to have the process as a single function,
    # rather than try and use an unnecessary class

    #
    # for benchmarking we set up some loops to run all needed:
    #  - 20 problems
    #  - PR and SR for all accuracy levels (doesn't need a rerun of the simulations)
    #  - CR for accuracy level 1e-4
    #

    simulation_runs = 50
    max_evals = CEC2013(func_num).get_maxfes()
    problem = CECFunction(func_num)
    nmmso = Nmmso(problem)

    if benchmarking:
        bm = benchmarks.Benchmarking()

        for i in range(simulation_runs):

            print('simulation run {} of function {}'.format(i, func_num))

            bm.run_info(problem, nmmso, simulation_runs, func_num)

            while nmmso.evaluations < max_evals:
                nmmso.iterate()

                if not all(bm.all_found):
                    bm.total_swarms[nmmso.evaluations] = bm.check_convergence()

            bm.benchmarking_result.SimulationSwarms.append(bm.total_swarms)
            bm.add_convergence()
            bm.all_found = [False for _ in range(len(bm.accuracies))]

        bm.calculate_stats(export_data=True)

    else:
        for i in range(simulation_runs):

            print('simulation run {} of function {}'.format(i, func_num))

            while nmmso.evaluations < max_evals:
                nmmso.iterate()
Beispiel #8
0
def main():
    number_of_fitness_evaluations = 5000
    nmmso = Nmmso(My2DProblem())
    my_result = nmmso.run(number_of_fitness_evaluations)
    for mode_result in my_result:
        print("Mode at {} has value {}".format(mode_result.location, mode_result.value))
Beispiel #9
0
def main():

    number_of_fitness_evaluations = 1000
    nmmso = Nmmso(MyProblem())
    nmmso.add_listener(MyListener())
    my_result = nmmso.run(number_of_fitness_evaluations)