Esempio n. 1
0
    drugv = cmb.combination(drugv)
    if drugv == False:
        break
    i = i + 1
drugv = (df_drug.as_matrix()).astype(np.int32)

outsize = 7
thlen = len(faultv) / 2
kernel = kernel % {"outsize": outsize}
mod = compiler.SourceModule(kernel)
results = mod.get_function("encode")
for i in range(len(drugv)):
    print "Drug vector:", i + 1, list(drugv[i]), "started."
    for j in range(len(faultv)):
        outlist = [0, 0, 0, 0, 0, 0, 0]
        drugpath.pathway(faultv[j], drugv[i], inpv, pathv, outlist)
        outv[j] = outlist
        inpv = [0, 0, 0, 0, 1]
    output_drugthree.loc[i] = " ".join(map(str, drugv[i]))
    outv_gpu = gpuarray.to_gpu((np.array(outv[:thlen])).astype(np.int32))
    env_gpu = gpuarray.empty(thlen, np.int32)
    results(outv_gpu, env_gpu, block=(thlen, 1, 1))
    output_drugthree.iloc[i, 1:thlen + 1] = env_gpu.get()
    outv_gpu = gpuarray.to_gpu((np.array(outv[thlen:])).astype(np.int32))
    env_gpu = gpuarray.empty(thlen, np.int32)
    results(outv_gpu, env_gpu, block=(thlen, 1, 1))
    output_drugthree.iloc[i, thlen + 1:] = env_gpu.get()
    print "Drug vector:", i + 1, list(drugv[i]), "ended."

ofile = "outs/output_drugthree_p.csv"
output_drugthree.to_csv(ofile)
Esempio n. 2
0
df_drug.columns=["drugs"]
df_drug["values"]=[0] * len(df_drug.index)

drugv=list(df_drug["values"])

#creating output file
cols=["drug vector"] + [i for i in range(28)]
output_drugone=pd.DataFrame(columns=cols)

j=0
start_time=time.clock()
while True:
    encoded=[]
    print("Drug scenario:",drugv,"starts")
    for i in range(28):
        drugpath.pathway([i],drugv,inpv,pathv,outv)
        encoded.append(float(en.encode(outv)))
        inpv=unq
    print("%0.3f"%(time.clock()-start_time),"Drug scenario:",drugv,"ends")
    output_drugone.loc[j,"drug vector"]=' '.join(map(str,drugv))
    output_drugone.iloc[j,1:]=encoded
    drugv=cmb.combination(drugv)
    if drugv==False:
        break
    j=j+1

print("Execution time: ","%0.3f"%(time.clock()-start_time)," seconds")
#print(output_drugone)

#write to output_drugone.csv
output_drugone.to_csv("outs/output_drugone.csv")