コード例 #1
0
ファイル: KG.py プロジェクト: toscanosaul/SBO
    def optVOInoParal(self,i):
	n1=self._n1
	args3=self.getParametersOptVoi(i)
	Xst=self.Obj.sampleFromX(1)
	st=Xst[0:1,:]
	args3['start']=st
	self.optRuns.append(misc.VOIOptWrapper(self,**args3))
	fl.writeNewPointKG(self,self.optRuns[0])
	
        self.optRuns=[]
        self.optPointsArray=[]
コード例 #2
0
ファイル: KG.py プロジェクト: toscanosaul/SBO
    def optVOIParal(self,i,nStart,numProcesses=None):
        try:
            n1=self._n1
          #  n2=self._dimW
         #   dim=self.dimension
	    args3=self.getParametersOptVoi(i)
	    Xst=self.Obj.sampleFromX(nStart)
            jobs = []
            pool = mp.Pool(processes=numProcesses)
            for j in range(nStart):
                st=Xst[j:j+1,:]
		args2=args3.copy()
                args2['start']=st
                job = pool.apply_async(misc.VOIOptWrapper, args=(self,), kwds=args2)
                jobs.append(job)
            
            pool.close()  # signal that no more data coming in
            pool.join()  # wait for all the tasks to complete
        except KeyboardInterrupt:
            print "Ctrl+c received, terminating and joining pool."
            pool.terminate()
            pool.join()

        numStarts=nStart
     #   print jobs[0].get()
        for j in range(numStarts):
            try:
                self.optRuns.append(jobs[j].get())
            except Exception as e:
                print "Error optimizing VOI"
                
        if len(self.optRuns):
            j = np.argmax([o.fOpt for o in self.optRuns])
	    fl.writeNewPointKG(self,self.optRuns[j])
        self.optRuns=[]
        self.optPointsArray=[]