def test_nested_mapper(self): # Tests for nested mapping. Setting up the system (some arbitrary values, here) wexploreMapper = WExploreBinMapper(n_regions=[4,4,4], d_cut=[2, .75, 0.25], dfunc=dfunc) wexploreMapper.centers = [[2.5, 7.0]] wexploreMapper.add_bin(None, 0) outerMapper = FuncBinMapper(fn2,2) recurseMapper = RecursiveBinMapper(outerMapper) RectiMapper = RectilinearBinMapper([[10.00, float('inf')], [0.0, float('inf')]]) recurseMapper.add_mapper(wexploreMapper, [9.9, 0]) recurseMapper.add_mapper(RectiMapper, [10, 0]) bin_mapper = recurseMapper # Now, begin testing setup... assert bin_mapper.nbins == 2 wexploreMappers = [] for key,i in bin_mapper.mapper_list.iteritems(): if isinstance(i['base_mapper'], WExploreBinMapper) == True: wexploreMappers.append(i) self.wexploreMappers = wexploreMappers wexploreMappers[0]['base_mapper'].add_bin(0,1) bin_mapper.refresh_mappers() assert bin_mapper.nbins == 3
class System(WESTSystem): def initialize(self): self.pcoord_ndim = 2 self.pcoord_len = 2 self.pcoord_dtype = numpy.float32 minfrag = 90 outer_mapper = RectilinearBinMapper([[0, minfrag - 0.5, float('inf')], [0, float('inf')]]) binbounds1 = [1.0 * i - 0.5 for i in xrange(minfrag, 121)] + [float('inf')] binbounds2 = [15.0 * i * (i - 1) / 2 for i in xrange(1, 20)] + [float('inf')] self.bin_mapper = RecursiveBinMapper(outer_mapper) self.bin_mapper.add_mapper( RectilinearBinMapper([binbounds1, binbounds2]), [minfrag, 1]) self.bin_target_counts = numpy.empty((self.bin_mapper.nbins, ), numpy.int) self.bin_target_counts[...] = 4 #this is intended to change the bins where distance < 200 A to 16 simulations per bin for q1 in xrange(minfrag, 121): for q2 in [0.5 + 15.0 * i * (i - 1) / 2 for i in xrange(1, 8)]: print(q1, q2) bin = self.bin_mapper.assign(numpy.array([(q1, q2)])) #tuple? self.bin_target_counts[bin] = 16
class System(WESTSystem): def initialize(self): self.pcoord_ndim = 2 self.pcoord_len = 11 self.pcoord_dtype = numpy.float32 self.dist_binbounds = [10.00,float('inf')] self.rmsd_bounds = [0.0, float('inf')] self.wexploreMapper = wexplore.WExploreBinMapper(n_regions=[4,4,4], d_cut=[2, .75, 0.25], dfunc=dfunc) self.wexploreMapper.centers = [[2.5, 7.0]] self.wexploreMapper.add_bin(None, 0) self.wexploreMapper.mask = np.array([[True, False]]) self.wexploreMapper.bin_target_counts = 64 self.initialize_mappers(self.wexploreMapper) self.max_replicas = 64 self.bin_mapper.centers = [[2.5, 7.0]] self.tstates = ['unbound,10.0,1.0'] self.n_regions = [6,4,4] def initialize_mappers(self,wexploreMapper): self.outerMapper = FuncBinMapper(fn2,2) self.recurseMapper = RecursiveBinMapper(self.outerMapper) self.RectiMapper = RectilinearBinMapper([self.dist_binbounds, self.rmsd_bounds]) self.RectiMapper.bin_target_counts = 3 self.recurseMapper.add_mapper(wexploreMapper, [4.99, 0]) self.recurseMapper.add_mapper(self.RectiMapper, [10, 0]) self.bin_mapper = self.recurseMapper self.bin_target_counts = numpy.empty((self.bin_mapper.nbins,), numpy.int) self.bin_target_counts[...] = 64 return self.bin_mapper
class SDASystem(WESTSystem): ''' Class specify binning schemes, walker counts, and other core weighted ensemble parameters. ''' def initialize(self): # pcoord dimensionality and length. This should match your outside bin self.pcoord_ndim = 2 self.pcoord_len = pcoordlength self.pcoord_dtype = pcoord_dtype # These are your "outer" bins in both dimensions outer_mapper = RectilinearBinMapper([[0.00, numpy.inf], [0.00, 8.00, numpy.inf]]) # These define the "inner" adaptive bins. Each one indicates an independent # adaptive binning scheme. Copy for more. Respects the parameters at the start. adaptive_mapper0 = FuncBinMapper(function_map, prod(binsperdim) + numberofdim * (2 + 2 * splitIsolated) + activetarget, kwargs={"multi_idx": 0}) # Bottom bin adaptive_mapper1 = FuncBinMapper(function_map, prod(binsperdim) + numberofdim * (2 + 2 * splitIsolated) + activetarget, kwargs={"multi_idx": 1}) # Top bin # These are the bins where you'll place each adaptive scheme. self.bin_mapper = RecursiveBinMapper(outer_mapper) self.bin_mapper.add_mapper(adaptive_mapper0, [5, 1]) #Bottom mapper self.bin_mapper.add_mapper(adaptive_mapper1, [5, 10]) #Top mapper ######################### JL ########################################## # This is the what the example looks like. # # inf -------------------------------------------------------- # | | # | adaptive_mapper1 | # | | # 8 -------------------------------------------------------- # D2 | | | # | TARGET | adaptive_mapper0 | # | STATE | | # 0 -------------------------------------------------------- # 3.5(soft bound via mincap) inf # Dimension 1 of pcoord # ####################################################################### self.bin_target_counts = numpy.empty((self.bin_mapper.nbins, ), dtype=numpy.int) # Number of walkers per bin self.bin_target_counts[...] = bintargetcount
def initialize_mappers(self,wexploreMapper): self.outerMapper = FuncBinMapper(fn2,2) self.recurseMapper = RecursiveBinMapper(self.outerMapper) self.RectiMapper = RectilinearBinMapper([self.dist_binbounds, self.rmsd_bounds]) self.RectiMapper.bin_target_counts = 3 self.recurseMapper.add_mapper(wexploreMapper, [4.99, 0]) self.recurseMapper.add_mapper(self.RectiMapper, [10, 0]) self.bin_mapper = self.recurseMapper self.bin_target_counts = numpy.empty((self.bin_mapper.nbins,), numpy.int) self.bin_target_counts[...] = 64 return self.bin_mapper