예제 #1
0
def main_master(opt_prob, num_workers):
    if not os.path.exists("./logfiles"):
        os.makedirs("logfiles")
    if os.path.exists("./logfiles/mpiexample_mpi.log"):
        os.remove("./logfiles/mpiexample_mpi.log")
    logging.basicConfig(filename="./logfiles/mpiexample_mpi.log",
                        level=logging.INFO)

    max_evals = 500

    rbf = RBFInterpolant(dim=opt_prob.dim, kernel=CubicKernel(),
                         tail=LinearTail(opt_prob.dim))
    slhd = SymmetricLatinHypercube(
        dim=opt_prob.dim, num_pts=2*(opt_prob.dim+1))

    # Create a strategy and a controller
    strategy = SRBFStrategy(
        max_evals=max_evals, opt_prob=opt_prob, exp_design=slhd,
        surrogate=rbf, asynchronous=True, batch_size=num_workers)
    controller = MPIController(strategy)

    print("Number of workers: {}".format(num_workers))
    print("Maximum number of evaluations: {}".format(max_evals))
    print("Strategy: {}".format(controller.strategy.__class__.__name__))
    print("Experimental design: {}".format(slhd.__class__.__name__))
    print("Surrogate: {}".format(rbf.__class__.__name__))

    result = controller.run()
    print('Best value found: {0}'.format(result.value))
    print('Best solution found: {0}\n'.format(
        np.array_str(result.params[0], max_line_width=np.inf,
                     precision=5, suppress_small=True)))
예제 #2
0
def main_master(num_workers):
    if not os.path.exists("./logfiles"):
        os.makedirs("logfiles")
    if os.path.exists("./logfiles/test_subprocess_mpi.log"):
        os.remove("./logfiles/test_subprocess_mpi.log")
    logging.basicConfig(filename="./logfiles/test_subprocess_mpi.log",
                        level=logging.INFO)

    print("\nTesting the POAP MPI controller with {0} workers".format(
        num_workers))
    print("Maximum number of evaluations: 200")
    print("Search strategy: Candidate DYCORS")
    print("Experimental design: Symmetric Latin Hypercube")
    print("Surrogate: Cubic RBF")

    assert os.path.isfile(path), "You need to build sphere_ext"

    max_evals = 200

    sphere = Sphere(dim=10)
    rbf = RBFInterpolant(dim=sphere.dim,
                         kernel=CubicKernel(),
                         tail=LinearTail(sphere.dim))
    slhd = SymmetricLatinHypercube(dim=sphere.dim,
                                   num_pts=2 * (sphere.dim + 1))

    # Create a strategy and a controller
    strategy = SRBFStrategy(max_evals=max_evals,
                            opt_prob=sphere,
                            exp_design=slhd,
                            surrogate=rbf,
                            asynchronous=True,
                            batch_size=num_workers)
    controller = MPIController(strategy)

    print("Number of threads: {}".format(num_workers))
    print("Maximum number of evaluations: {}".format(max_evals))
    print("Strategy: {}".format(controller.strategy.__class__.__name__))
    print("Experimental design: {}".format(slhd.__class__.__name__))
    print("Surrogate: {}".format(rbf.__class__.__name__))

    # Run the optimization strategy
    result = controller.run()
    print('Best value found: {0}'.format(result.value))
    print('Best solution found: {0}\n'.format(
        np.array_str(result.params[0],
                     max_line_width=np.inf,
                     precision=5,
                     suppress_small=True)))
예제 #3
0
def main():
    "Controller process main."
    logging.basicConfig(format="%(name)-18s: %(levelname)-8s %(message)s",
                        filename='test_mpi_serve.log-{0}'.format(rank),
                        level=logging.DEBUG)
    ch = logging.StreamHandler()
    ch.setLevel(logging.INFO)
    formatter = logging.Formatter("%(name)-12s: %(levelname)-8s %(message)s")
    ch.setFormatter(formatter)
    logging.getLogger('').addHandler(ch)

    strategy = FixedSampleStrategy([1, 2, 3, 4, 5])
    c = MPIController(strategy)
    result = c.run()
    print("Final: {0:.3e} @ {1}".format(result.value, result.params))
예제 #4
0
def main():
    "Controller process main."
    logging.basicConfig(format="%(name)-18s: %(levelname)-8s %(message)s",
                        filename='test_mpi_serve.log-{0}'.format(rank),
                        level=logging.DEBUG)
    ch = logging.StreamHandler()
    ch.setLevel(logging.INFO)
    formatter = logging.Formatter("%(name)-12s: %(levelname)-8s %(message)s")
    ch.setFormatter(formatter)
    logging.getLogger('').addHandler(ch)

    strategy = FixedSampleStrategy([1, 2, 3, 4, 5])
    c = MPIController(strategy)
    result = c.run()
    print(("Final: {0:.3e} @ {1}".format(result.value, result.params)))
예제 #5
0
def main_master(num_workers):
    if not os.path.exists("./logfiles"):
        os.makedirs("logfiles")
    if os.path.exists("./logfiles/test_subprocess_mpi.log"):
        os.remove("./logfiles/test_subprocess_mpi.log")
    logging.basicConfig(filename="./logfiles/test_subprocess_mpi.log",
                        level=logging.INFO)

    print("\nTesting the POAP MPI controller with {0} workers".format(
        num_workers))
    print("Maximum number of evaluations: 200")
    print("Search strategy: Candidate DYCORS")
    print("Experimental design: Symmetric Latin Hypercube")
    print("Surrogate: Cubic RBF")

    assert os.path.isfile(path), "You need to build sphere_ext"

    max_evals = 200

    sphere = Sphere(dim=10)
    rbf = RBFInterpolant(dim=sphere.dim, kernel=CubicKernel(),
                         tail=LinearTail(sphere.dim))
    slhd = SymmetricLatinHypercube(
        dim=sphere.dim, num_pts=2*(sphere.dim+1))

    # Create a strategy and a controller
    strategy = SRBFStrategy(
        max_evals=max_evals, opt_prob=sphere, exp_design=slhd,
        surrogate=rbf, asynchronous=True, batch_size=num_workers)
    controller = MPIController(strategy)

    print("Number of threads: {}".format(num_workers))
    print("Maximum number of evaluations: {}".format(max_evals))
    print("Strategy: {}".format(controller.strategy.__class__.__name__))
    print("Experimental design: {}".format(slhd.__class__.__name__))
    print("Surrogate: {}".format(rbf.__class__.__name__))

    # Run the optimization strategy
    result = controller.run()
    print('Best value found: {0}'.format(result.value))
    print('Best solution found: {0}\n'.format(
        np.array_str(result.params[0], max_line_width=np.inf,
                     precision=5, suppress_small=True)))
예제 #6
0
def main_master(opt_prob, num_workers):
    if not os.path.exists("./logfiles"):
        os.makedirs("logfiles")
    if os.path.exists("./logfiles/mpiexample_mpi.log"):
        os.remove("./logfiles/mpiexample_mpi.log")
    logging.basicConfig(filename="./logfiles/mpiexample_mpi.log",
                        level=logging.INFO)

    max_evals = 500

    rbf = RBFInterpolant(dim=opt_prob.dim,
                         lb=opt_prob.lb,
                         ub=opt_prob.ub,
                         kernel=CubicKernel(),
                         tail=LinearTail(opt_prob.dim))
    slhd = SymmetricLatinHypercube(dim=opt_prob.dim,
                                   num_pts=2 * (opt_prob.dim + 1))

    # Create a strategy and a controller
    strategy = SRBFStrategy(
        max_evals=max_evals,
        opt_prob=opt_prob,
        exp_design=slhd,
        surrogate=rbf,
        asynchronous=True,
        batch_size=num_workers,
    )
    controller = MPIController(strategy)

    print("Number of workers: {}".format(num_workers))
    print("Maximum number of evaluations: {}".format(max_evals))
    print("Strategy: {}".format(controller.strategy.__class__.__name__))
    print("Experimental design: {}".format(slhd.__class__.__name__))
    print("Surrogate: {}".format(rbf.__class__.__name__))

    result = controller.run()
    print("Best value found: {0}".format(result.value))
    print("Best solution found: {0}\n".format(
        np.array_str(result.params[0],
                     max_line_width=np.inf,
                     precision=5,
                     suppress_small=True)))
예제 #7
0
def main_master(nworkers):
    if not os.path.exists("./logfiles"):
        os.makedirs("logfiles")
    if os.path.exists("./logfiles/test_subprocess_mpi.log"):
        os.remove("./logfiles/test_subprocess_mpi.log")
    logging.basicConfig(filename="./logfiles/test_subprocess_mpi.log",
                        level=logging.INFO)

    print(
        "\nTesting the POAP MPI controller with {0} workers".format(nworkers))
    print("Maximum number of evaluations: 200")
    print("Search strategy: Candidate DYCORS")
    print("Experimental design: Symmetric Latin Hypercube")
    print("Surrogate: Cubic RBF")

    assert os.path.isfile("./sphere_ext"), "You need to build sphere_ext"

    maxeval = 200

    data = Sphere(dim=10)
    print(data.info)

    # Create a strategy and a controller
    strategy = \
        SyncStrategyNoConstraints(
            worker_id=0, data=data,
            maxeval=maxeval, nsamples=nworkers,
            exp_design=SymmetricLatinHypercube(dim=data.dim, npts=2*(data.dim+1)),
            sampling_method=CandidateDYCORS(data=data, numcand=100*data.dim),
            response_surface=RBFInterpolant(kernel=CubicKernel, tail=LinearTail,
                                            maxp=maxeval))

    controller = MPIController(strategy)

    # Run the optimization strategy
    result = controller.run()
    print('Best value found: {0}'.format(result.value))
    print('Best solution found: {0}\n'.format(
        np.array_str(result.params[0],
                     max_line_width=np.inf,
                     precision=5,
                     suppress_small=True)))
예제 #8
0
def main():
    "Testing routine."
    # Log at DEBUG level to file, higher level to console
    logging.basicConfig(format="%(name)-18s: %(levelname)-8s %(message)s",
                        filename='test_mpi_pw.log-{0}'.format(rank),
                        level=logging.DEBUG)
    ch = logging.StreamHandler()
    ch.setLevel(logging.INFO)
    formatter = logging.Formatter("%(name)-12s: %(levelname)-8s %(message)s")
    ch.setFormatter(formatter)
    logging.getLogger('').addHandler(ch)

    samples = [0.0, 0.1, 0.2, 0.3, 0.4, 0.5]
    controller = MPIController()
    strategy = FixedSampleStrategy(samples)
    strategy = CheckWorkerStrategy(controller, strategy)
    strategy = AddArgStrategy(strategy, extra_args='./dummy_sim')
    strategy = ChaosMonkeyStrategy(controller, strategy, mtbf=3)
    controller.strategy = strategy
    result = controller.run()
    print("Final: {0:.3e} @ {1}".format(result.value, result.params))
예제 #9
0
def main():
    "Testing routine."
    # Log at DEBUG level to file, higher level to console
    logging.basicConfig(format="%(name)-18s: %(levelname)-8s %(message)s",
                        filename='test_mpi_pw.log-{0}'.format(rank),
                        level=logging.DEBUG)
    ch = logging.StreamHandler()
    ch.setLevel(logging.INFO)
    formatter = logging.Formatter("%(name)-12s: %(levelname)-8s %(message)s")
    ch.setFormatter(formatter)
    logging.getLogger('').addHandler(ch)

    samples = [0.0, 0.1, 0.2, 0.3, 0.4, 0.5]
    controller = MPIController()
    strategy = FixedSampleStrategy(samples)
    strategy = CheckWorkerStrategy(controller, strategy)
    strategy = AddArgStrategy(strategy, extra_args='./dummy_sim')
    strategy = ChaosMonkeyStrategy(controller, strategy, mtbf=3)
    controller.strategy = strategy
    result = controller.run()
    print("Final: {0:.3e} @ {1}".format(result.value, result.params))
예제 #10
0
def main_master(data, nworkers):
    if not os.path.exists("./logfiles"):
        os.makedirs("logfiles")
    if os.path.exists("./logfiles/test_simple_mpi.log"):
        os.remove("./logfiles/test_simple_mpi.log")
    logging.basicConfig(filename="./logfiles/test_simple_mpi.log",
                        level=logging.INFO)

    print(
        "\nTesting the POAP MPI controller with {0} workers".format(nworkers))
    print("Maximum number of evaluations: 500")
    print("Sampling method: CandidateDYCORS, with weight 0.5")
    print("Experimental design: Symmetric Latin Hypercube")
    print("Surrogate: Cubic RBF, domain scaled to unit box")

    maxeval = 500
    print(data.info)

    # Create a strategy and a controller
    strategy = \
        SyncStrategyNoConstraints(
            worker_id=0, data=data,
            maxeval=maxeval, nsamples=nworkers,
            exp_design=SymmetricLatinHypercube(dim=data.dim, npts=2*(data.dim+1)),
            response_surface=RBFInterpolant(kernel=CubicKernel, tail=LinearTail,
                                            maxp=maxeval),
            sampling_method=CandidateDYCORS(data=data, numcand=100*data.dim, weights=[0.5]))
    controller = MPIController(strategy)

    result = controller.run()
    print('Best value found: {0}'.format(result.value))
    print('Best solution found: {0}\n'.format(
        np.array_str(result.params[0],
                     max_line_width=np.inf,
                     precision=5,
                     suppress_small=True)))