def __init__(self, domain, ce_params): super().__init__(domain) self.alpha = ce_params.alpha self.thres = ce_params.thres self.cont_buckets = ce_params.cont.buckets self.cont_dist = ce_params.cont.dist self.disc_dist = ce_params.disc.dist self.cont_ce = lambda domain: ContinuousCrossEntropySampler( domain=domain, buckets=self.cont_buckets, dist=self.cont_dist, alpha=self.alpha, thres=self.thres) self.disc_ce = lambda domain: DiscreteCrossEntropySampler( domain=domain, dist=self.disc_dist, alpha=self.alpha, thres=self.thres) partition = ((lambda d: d.standardizedDimension > 0, self.cont_ce), (lambda d: d.standardizedIntervals, self.disc_ce)) self.split_sampler = SplitSampler.fromPartition( domain, partition, RandomSampler) self.cont_sampler, self.disc_sampler = None, None self.rand_sampler = None for subsampler in self.split_sampler.samplers: if isinstance(subsampler, ContinuousCrossEntropySampler): assert self.cont_sampler is None self.cont_sampler = subsampler elif isinstance(subsampler, DiscreteCrossEntropySampler): assert self.disc_sampler is None self.disc_sampler = subsampler else: assert isinstance(subsampler, RandomSampler) assert self.rand_sampler is None self.rand_sampler = subsampler
def makeDomainSampler(domain): return SplitSampler.fromPredicate( domain, lambda d: d.standardizedDimension > 0, lambda domain: SimulatedAnnealingSampler(domain=domain, sa_params=sa_params), makeRandomSampler)
def makeDomainSampler(domain): return SplitSampler.fromPredicate( domain, lambda d: d.isStandardizable, lambda domain: GridSampler(domain=domain, grid_params=grid_params), makeRandomSampler)
def makeDomainSampler(domain): return SplitSampler.fromPredicate( domain, lambda d: d.standardizedDimension > 0, lambda domain: HaltonSampler(domain=domain, halton_params=halton_params), makeRandomSampler)
def makeDomainSampler(domain): return SplitSampler.fromPredicate( domain, lambda d: d.standardizedDimension > 0, lambda domain: BayesOptSampler(domain=domain, BO_params=BO_params), makeRandomSampler)
def __init__(self, domain, ce_params): super().__init__(domain) self.f = ce_params.f self.alpha = ce_params.alpha self.thres = ce_params.thres self.cont_buckets = ce_params.cont.buckets self.cont_dist = ce_params.cont.dist self.disc_dist = ce_params.disc.dist self.cont_ce = lambda domain: ContinuousCrossEntropySampler( domain=domain, buckets=self.cont_buckets, dist=self.cont_dist, alpha=self.alpha) self.disc_ce = lambda domain: DiscreteCrossEntropySampler( domain=domain, dist=self.disc_dist, alpha=self.alpha) partition = ((lambda d: d.standardizedDimension, self.cont_ce), (lambda d: d.standardizedIntervals, self.disc_ce)) self.split_sampler = SplitSampler.fromPartition( domain, partition, RandomSampler)
def __init__(self, domain, grid_params=None): if grid_params is None: grid_params = {} self.cont_N = grid_params.get('N', 21) repeat = grid_params.get('repeat', False) super().__init__(domain, repeat=repeat) cont_grid = lambda domain: ContinuousGridSampler(domain=domain, N=self.cont_N) disc_grid = lambda domain: DiscreteGridSampler(domain=domain) partition = ( (lambda d: d.standardizedDimension >= 0, cont_grid), (lambda d: d.standardizedIntervals, disc_grid) ) self.split_sampler = SplitSampler.fromPartition(domain, partition) self.cont_sampler, self.disc_sampler = \ self.split_sampler.samplersForPredicates