@@ -0,0 +1,2233 @@
+from __future__ import division%0Aimport optparse%0A%0Afrom mpi4py import MPI%0Aimport numpy as np%0A%0Afrom serial import find_solution, write_results%0A%0A%0Adef process_interval(rank, work, verbose=False):%0A    %22%22%22%0A    Iterate over the given interval and runs the function for finding solutions%0A    from %60serial.py%60.%0A    %22%22%22%0A%0A    print('process %7B%7D working on %7B%7D to %7B%7D%5Cn'.format(rank, work.min(), work.max()))%0A%0A    results = %5B%5D%0A    i = 0%0A    while work.size:%0A        linear_value, row = find_solution(work.min())%0A%0A        if not linear_value:%0A            break%0A%0A        results.append(row)%0A        work = work%5Bwork %3E linear_value%5D%0A        i += 1%0A%0A        if verbose:%0A            print('process %7B%7D just finished solution %7B%7D, objective function '%0A                  'value %7B%7D'.format(rank, i, linear_value))%0A%0A    print('process %7B%7D finished%5Cn'.format(rank))%0A    return results%0A%0A%0Aif __name__ == '__main__':%0A    # parse command line options%0A    parser = optparse.OptionParser()%0A    parser.add_option(%22-v%22, dest=%22verbose%22, action=%22store_true%22,%0A                      default=False,%0A                      help=%22verbose (print every solution instead of every 10)%22)%0A    parser.add_option(%22--min%22, dest=%22min%22, type=%22float%22,%0A                      default=9927.0,%0A                      help=%22minimum objective value%22)%0A    parser.add_option(%22--max%22, dest=%22max%22, type=%22float%22,%0A                      default=11534.0,%0A                      help=%22maximum objective value%22)%0A    options, args = parser.parse_args()%0A%0A    comm = MPI.COMM_WORLD%0A    rank = comm.Get_rank()%0A    size = comm.Get_size()%0A%0A    work = np.arange(options.min, options.max+1)%0A    local_work = np.split(work, size)%5Brank%5D%0A%0A    if rank == 0:%0A        start_time = MPI.Wtime()%0A%0A        # do the Integer Linear Programming process on interval%0A        results = process_interval(rank, local_work, verbose=options.verbose)%0A%0A        # collect results from other processors%0A        for i in range(1, size):%0A            results += comm.recv(source=i)%0A%0A        total_time = start_time - MPI.Wtime()%0A        write_results(results, total_time, processors=size)%0A    else:%0A        results = process_interval(rank, local_work, verbose=options.verbose)%0A        comm.send(results, dest=0)%0A        %0A    %0A        %0A    %0A%0A%0A%0A

add naive implementation