-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathfastgwr_mpi.py
60 lines (46 loc) · 1.65 KB
/
fastgwr_mpi.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#FastGWR MPI Script
#Author: Ziqi Li
#Email: [email protected]
import argparse
import numpy as np
from mpi4py import MPI
from FastGWR import FastGWR
from FastMGWR import FastMGWR
#Direct Example Call:
#You can direct call this script by:
#mpiexec -np 4 python fastgwr_mpi.py -data ../Zillow-test-dataset/zillow_1k.csv
#mpiexec -np 4 python fastgwr_mpi.py -data ../Zillow-test-dataset/zillow_1k.csv -mgwr -c
if __name__ == "__main__":
#Initializing MPI
comm = MPI.COMM_WORLD
rank = comm.Get_rank()
size = comm.Get_size()
#Parsing arguments
parser = argparse.ArgumentParser()
parser.add_argument("-data")
parser.add_argument("-out",default="fastgwr_rslt.csv")
parser.add_argument("-bw")
parser.add_argument("-minbw")
parser.add_argument("-chunks",default=1)
parser.add_argument('-estonly',action='store_true')
parser.add_argument('-mgwr',action='store_true')
parser.add_argument('-f','--fixed',action='store_true')
parser.add_argument('-a','--adaptive',action='store_true')
parser.add_argument('-c','--constant',action='store_true')
#Timing starts
t1 = MPI.Wtime()
n_chunks = parser.parse_args().chunks
#Fitting MGWR model, if mgwr in the arguments
if parser.parse_args().mgwr:
mgwr_model = FastMGWR(comm,parser)
mgwr_model.backfitting()
mgwr_model.mgwr_fit(int(n_chunks))
#Fitting GWR model
else:
FastGWR(comm,parser).fit()
#Timing ends
t_last = MPI.Wtime()
wt = comm.gather(t_last-t1, root=0)
if rank ==0:
print("Total Time Elapsed:",np.round(max(wt),2),"seconds")
print("-"*60)