Skip to content

Instantly share code, notes, and snippets.

@pasindud
Created February 6, 2017 02:16
Show Gist options
  • Select an option

  • Save pasindud/7c35a737cee9831bd158918e209dc3e8 to your computer and use it in GitHub Desktop.

Select an option

Save pasindud/7c35a737cee9831bd158918e209dc3e8 to your computer and use it in GitHub Desktop.
from multiprocessing import Pool
import oct2py
import sys
from multiprocessing import Process
from multiprocessing import Queue
import matplotlib.pyplot as plt
import pprint
# N = [100];
# P = [2];
# cr = [0.0];
# mu = [0.0];
N =[100,1000,10000];
P = [2,10,50];
cr =[0.0 , 0.2 , 0.4 , 0.5 , 0.6];
mu =[0.0 , 0.1];
def printGraphSplit():
print("s")
def graphPartitioningGA1Split(A, N, P, cr, mu):
oc = oct2py.Oct2Py()
oc.addpath("/Users/Pasindu/Downloads/p2")
print(P, cr, mu)
[cut, soln] = oc.graphPartitioningGA1(A, P, 1,cr, mu)
def n3splitsplitMulti(q, local_epoch, A, N, P, cr, mu):
oc = oct2py.Oct2Py()
oc.addpath("/Users/Pasindu/Downloads/p2")
return q.put([oc.n3splitsplit(local_epoch, A, N, P, cr, mu)])
def n3splitsplit(epoch, A, N, P, cr, mu):
jobs = []
results = []
result_queue = Queue()
local_epoch = epoch * 1000 + 15
q = Queue()
for i in range(3):
local_epoch += 1
print("Running - " + str(local_epoch))
p = Process(target=n3splitsplitMulti, args=(q, local_epoch, A, N, P, cr, mu))
jobs.append(p)
p.start()
for proc in jobs:
proc.join()
for result in results:
print(result)
def n3split(epoch, A, N, P, cr, mu):
oc = oct2py.Oct2Py()
oc.addpath("/Users/Pasindu/Downloads/p2")
print (epoch, A, N, P, cr, mu)
oc.n3split(epoch, A, N, P, cr, mu)
def runN(N):
oc = oct2py.Oct2Py()
oc.addpath("/Users/Pasindu/Downloads/p2")
[A,t,x,y] = oc.makesp(N)
epoch = N
for j in P:
for k in cr:
for l in mu:
p = Process(target=n3splitsplit, args=(epoch, A, N, j, k, l))
p.start()
epoch += 1
def main(args):
p = Process(target=runN, args=(N[0],))
p.start()
p.join()
# print(p.map(runN, N))
if __name__ == "__main__":
main(sys.argv)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment