def run_mpi():
    from libtbx.mpi4py import MPI
    comm = MPI.COMM_WORLD
    rank = comm.Get_rank()
    size = comm.Get_size()
    W = simple_quadratic()
    if (rank == 0):
        W.run()
        print(list(W.a), 'Single process final answer')
    else:
        pass
    comm.barrier()
    M = mpi_quadratic()
    M.reinitialize(idx=rank, logical_size=len(W.datax))
    minimizer = mpi_split_evaluator_run(target_evaluator=M, termination_params=scitbx.lbfgs.termination_parameters(traditional_convergence_test=True, traditional_convergence_test_eps=0.001, max_calls=1000))
    if (rank == 0):
        print(list(M.x), 'MPI final answer')
        try:
            from libtbx.test_utils import approx_equal
            assert approx_equal(M.x, W.a)
            assert approx_equal(M.x, [0.09601410216133123, (- 0.28424727078557327), (- 4.848332140888606)])
            print('OK')
        except Exception:
            print('FAIL')
def run_mpi():
    from libtbx.mpi4py import MPI
    comm = MPI.COMM_WORLD
    rank = comm.Get_rank()
    size = comm.Get_size()
    W = simple_quadratic()
    if (rank == 0):
        W.run()
        print(list(W.a), 'Single process final answer')
    else:
        pass
    comm.barrier()
    M = mpi_quadratic()
    M.reinitialize(idx=rank, logical_size=len(W.datax))
    minimizer = mpi_split_evaluator_run(target_evaluator=M, termination_params=scitbx.lbfgs.termination_parameters(traditional_convergence_test=True, traditional_convergence_test_eps=0.001, max_calls=1000))
    if (rank == 0):
        print(list(M.x), 'MPI final answer')
        try:
            from libtbx.test_utils import approx_equal
            assert approx_equal(M.x, W.a)
            assert approx_equal(M.x, [0.09601410216133123, (- 0.28424727078557327), (- 4.848332140888606)])
            print('OK')
        except Exception:
            print('FAIL')