Changeset 8338
- Timestamp:
- Feb 15, 2012, 12:18:12 PM (13 years ago)
- Location:
- trunk/anuga_work/development/mem_time_tests/linearregression/area
- Files:
-
- 1 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_work/development/mem_time_tests/linearregression/area/main.py
r8332 r8338 6 6 import csv 7 7 import os 8 import numpy 8 9 import time 9 10 import liststore … … 21 22 final = 'final.csv' 22 23 final_path = os.path.join(scenariodir, final) 24 equation = 'equation.csv' 25 equation_path = os.path.join(scenariodir, equation) 23 26 27 #------------------------------------------------------------------------------ 28 # MAIN LOOP 24 29 # this is the main loops that assigns the maximum triangle area (m) and the map side length(l) 25 30 #------------------------------------------------------------------------------ 26 31 n = 1 #number of processors to use 27 32 for seed in range(0,30): … … 57 62 58 63 # time step experiment 59 60 64 if (host == 'cyclone.agso.gov.au'): 61 65 subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/lnrrun.machines_cyclone', '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py',str(vartimestep),str(stdtimelength),str(stdsidelength)]) … … 69 73 print 'Done' 70 74 75 #------------------------------------------------------------------------------ 76 # LOG ANALYSE 77 # and the Linear Regression 78 #------------------------------------------------------------------------------ 79 71 80 #get the important data for the experiments from the anuga experiments 72 81 analyse_log(scenariodir, os.path.join(scenariodir,'metalog.csv')) … … 75 84 metalog = csv.reader(open(meta_path,'rb')) 76 85 final = csv.writer(open(final_path,'wb')) 86 eq = csv.writer(open(equation_path,'wb')) 77 87 78 #list stores the index of the values requird88 #lists used to condense the metalog file and the regression equation 79 89 indexlist = [] 90 triangles = [] 91 trianglessquared = [] 92 timelength = [] 93 filewrites = [] 94 timelist = [] 95 space = [] 80 96 81 97 #read in the first row … … 103 119 indexlist.append(firstrow.index("numberofcpus")) 104 120 indexlist.append(firstrow.index("host")) 105 106 107 121 108 122 #write the header for the final csv … … 137 151 row[(indexlist[15])],row[(indexlist[16])], 138 152 row[(indexlist[17])],row[(indexlist[18])]]) 153 154 #make a list of all the data points, to be used in the regression 155 timelist.append(float(taken)) 156 space.append(float(row[(indexlist[7])])) 157 triangles.append(float(row[(indexlist[8])])) 158 trianglessquared.append(float(row[(indexlist[8])])**2) 159 timelength.append(float(row[(indexlist[9])])) 160 filewrites.append(float(row[(indexlist[9])])/float(row[(indexlist[10])])) 139 161 140 subprocess.call(['python','pmain.py']) 162 #convert these lists to arrays 163 spa = numpy.asarray(space) 164 tim = numpy.asarray(timelist) 165 tri = numpy.asarray(triangles) 166 trisq = numpy.asarray(trianglessquared) 167 timlen = numpy.asarray(timelength) 168 filwrit = numpy.asarray(filewrites) 169 170 #manipulate the arrays, to stack them into one array that will work the way we want for regression 171 multivariatearray = numpy.column_stack([tri.flat,trisq.flat,timlen.flat,filwrit.flat, numpy.ones(90,float)]) 172 multivariatearrayspace = numpy.column_stack([tri.flat, numpy.ones(90,float)]) 173 174 #get the equations for both time and memory 175 timequation = numpy.linalg.lstsq(multivariatearray,tim)[0] 176 spaequation = numpy.linalg.lstsq(multivariatearrayspace,spa)[0] 177 178 #calculate the R squared values for each equation 179 resid1 = numpy.linalg.lstsq(multivariatearray,tim)[1] 180 resid2 = numpy.linalg.lstsq(multivariatearrayspace,spa)[1] 181 r2 = 1 - resid1 / (tim.size * tim.var()) 182 r3 = 1 - resid2 / (spa.size * spa.var()) 183 184 #write these values back to lists 185 listtime = timequation.tolist() 186 listspace = spaequation.tolist() 187 188 #write the equation data to file 189 eq.writerow(['Dependent Variable', 'Number of Triangles','Number of Triangles Squared','Time Length','File Writes','Constant', 'R Squared']) 190 eq.writerow(['Time']+listtime + r2.tolist()) 191 eq.writerow(['Dependent Variable', 'Number of Triangles','Constant', 'R Squared']) 192 eq.writerow(['Space']+listspace + r3.tolist()) 193 194 -
trunk/anuga_work/development/mem_time_tests/linearregression/area/pmain.py
r8332 r8338 7 7 import os 8 8 import time 9 import liststore10 9 from anuga.abstract_2d_finite_volumes.util import add_directories 11 10 from anuga.utilities.log_analyser import analyse_log … … 22 21 final_path = os.path.join(scenariodir, final) 23 22 23 #------------------------------------------------------------------------------ 24 # MAIN LOOP 24 25 # this is the main loops that assigns the maximum triangle area (m) and the map side length(l) 25 26 #------------------------------------------------------------------------------ 26 27 27 28 for n in range(0,24): … … 42 43 print 'Done' 43 44 45 #------------------------------------------------------------------------------ 46 # LOG ANALYSE 47 # and the Linear Regression (This has not been implemented as the nature of the 48 # relationship between the number of cpus and time as well as memory) 49 #------------------------------------------------------------------------------ 50 44 51 #get the important data for the experiments from the anuga experiments 45 52 analyse_log(scenariodir, os.path.join(scenariodir,'metalog.csv')) … … 49 56 final = csv.writer(open(final_path,'wb')) 50 57 51 #list stores the index of the values requird58 #lists used to condense the metalog file 52 59 indexlist = [] 53 60 … … 75 82 indexlist.append(firstrow.index("percentageofwatercover")) 76 83 indexlist.append(firstrow.index("numberofcpus")) 84 indexlist.append(firstrow.index("myid")) 77 85 indexlist.append(firstrow.index("host")) 78 79 80 86 81 87 #write the header for the final csv … … 88 94 firstrow[(indexlist[13])],firstrow[(indexlist[14])], 89 95 firstrow[(indexlist[15])],firstrow[(indexlist[16])], 90 firstrow[(indexlist[17])],firstrow[(indexlist[18])]]) 96 firstrow[(indexlist[17])],firstrow[(indexlist[18])]], 97 firstrow[(indexlist[19])]]) 91 98 92 99 #write the data for each column in the final csv … … 109 116 row[(indexlist[13])],row[(indexlist[14])], 110 117 row[(indexlist[15])],row[(indexlist[16])], 111 row[(indexlist[17])],row[(indexlist[18])]]) 112 118 row[(indexlist[17])],row[(indexlist[18])]], 119 row[(indexlist[19])]]) 120 -
trunk/anuga_work/development/mem_time_tests/linearregression/area/pruncairns.py
r8332 r8338 5 5 import time 6 6 import sys 7 import liststore8 7 import anuga 9 8 from anuga_parallel import distribute, numprocs, myid … … 37 36 log.timingInfo(msg=('numberofcpus,'+str(numprocs))) #write the variable to be measured to file 38 37 log.timingInfo(msg=('host,'+str(os.getenv('HOST')))) #write the variable to be measured to file 39 38 log.timingInfo(msg=('myid,'+str(myid)) #write the variable to be measured to file 40 39 41 40 log.timingInfo(msg=('beforetime,'+str(log.TimeStamp()))) #get the time at the beginning of the simulation
Note: See TracChangeset
for help on using the changeset viewer.