コード例 #1
0
ファイル: MCunc.py プロジェクト: taoyiliang/unc-quant
    for a, arg in enumerate(args):
        args[a] = float(arg)
    varDict[var] = Variable(var, path)
    varDict[var].setDist(dist, args)

converged = False
runDict = {}
datapts = []
totruns = 0
curTime = time.time()
x = []
y = []
print 'Running', totalSamples, 'histories...'

#sample extremum first
runFileName, cx, cy, kx, ky = ie.writeInput(templateFile, runDict, totruns)

runDict[varDict[varDict.keys()[1]].path] = varDict[varDict.keys()
                                                   [0]].sampleLow()
runDict[varDict[varDict.keys()[0]].path] = varDict[varDict.keys()
                                                   [0]].sampleLow()

while not converged:
    # build sample values
    #if totruns < 4: #do an extreme case
    #  if totruns == 0: #low,low
    #    runDict[varDict[varDict.keys()[0]].path]=varDict[varDict.keys()[0]].sampleLow()
    #    runDict[varDict[varDict.keys()[1]].path]=varDict[varDict.keys()[1]].sampleLow()
    #  elif totruns == 1:
    #    runDict[varDict[varDict.keys()[0]].path]=varDict[varDict.keys()[0]].sampleHi()
    #    runDict[varDict[varDict.keys()[1]].path]=varDict[varDict.keys()[1]].sampleLow()
コード例 #2
0
histories['soln'] = []
histories['vars'] = varDict.keys()
while not sampler.converged and total_runs < 20:
    total_runs += 1
    print 'run:', total_runs
    runDict = sampler.giveSample()
    histories['nRun'].append(total_runs)
    for key in runDict.keys():
        try:
            histories[key].append(runDict[key])
        except IndexError:
            histories[key] = [runDict[key]]
    histories['varVals'].append(runDict['varVals'])

    #get input file name, write input file
    inp_file = ie.writeInput(templateFile, runDict['varVals'], total_runs)

    #run file
    os.system('./TwoDProblem -i ' + inp_file + ' > /dev/null')
    os.system('rm ' + inp_file)
    histories['soln'].append(ie.storeOutput())

#build backend
backendTypes = input_file('Backend/active', '').split(' ')
for beType in backendTypes:
    if beType in ['plot2D']:
        backend = be.Plotter2D()
        cprvarsX = input_file('Output/Plot2D/xvars', '').split(' ')
        cprvarsY = input_file('Output/Plot2D/yvars', '').split(' ')
        for i in range(len(xvars)):
            backend.compareVars(cprvarsX[i], cprvarsY[i], histories)
コード例 #3
0
ファイル: MCunc.py プロジェクト: taoyiliang/unc-quant
  for a,arg in enumerate(args):
    args[a]=float(arg)
  varDict[var]=Variable(var,path)
  varDict[var].setDist(dist,args)

converged = False
runDict={}
datapts=[]
totruns=0
curTime=time.time()
x=[]
y=[]
print 'Running',totalSamples,'histories...'

#sample extremum first
runFileName,cx,cy,kx,ky = ie.writeInput(templateFile,runDict,totruns)

runDict[varDict[varDict.keys()[1]].path]=varDict[varDict.keys()[0]].sampleLow()
runDict[varDict[varDict.keys()[0]].path]=varDict[varDict.keys()[0]].sampleLow()

while not converged:
  # build sample values
  #if totruns < 4: #do an extreme case
  #  if totruns == 0: #low,low
  #    runDict[varDict[varDict.keys()[0]].path]=varDict[varDict.keys()[0]].sampleLow()
  #    runDict[varDict[varDict.keys()[1]].path]=varDict[varDict.keys()[1]].sampleLow()
  #  elif totruns == 1:
  #    runDict[varDict[varDict.keys()[0]].path]=varDict[varDict.keys()[0]].sampleHi()
  #    runDict[varDict[varDict.keys()[1]].path]=varDict[varDict.keys()[1]].sampleLow()
  #  elif totruns == 2:
  #    runDict[varDict[varDict.keys()[0]].path]=varDict[varDict.keys()[0]].sampleLow()