• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java RandomAdaptor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.commons.math3.random.RandomAdaptor的典型用法代码示例。如果您正苦于以下问题:Java RandomAdaptor类的具体用法?Java RandomAdaptor怎么用?Java RandomAdaptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RandomAdaptor类属于org.apache.commons.math3.random包,在下文中一共展示了RandomAdaptor类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: makeCircles

import org.apache.commons.math3.random.RandomAdaptor; //导入依赖的package包/类
public static List<Vector2D> makeCircles(int samples, boolean shuffle, double noise, double factor, final RandomGenerator random) {
    if (factor < 0 || factor > 1) {
        throw new IllegalArgumentException();
    }
    
    NormalDistribution dist = new NormalDistribution(random, 0.0, noise, 1e-9);

    List<Vector2D> points = new ArrayList<Vector2D>();
    double range = 2.0 * FastMath.PI;
    double step = range / (samples / 2.0 + 1);
    for (double angle = 0; angle < range; angle += step) {
        Vector2D outerCircle = new Vector2D(FastMath.cos(angle), FastMath.sin(angle));
        Vector2D innerCircle = outerCircle.scalarMultiply(factor);
        
        points.add(outerCircle.add(generateNoiseVector(dist)));
        points.add(innerCircle.add(generateNoiseVector(dist)));
    }
    
    if (shuffle) {
        Collections.shuffle(points, new RandomAdaptor(random));
    }

    return points;
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:25,代码来源:ClusterAlgorithmComparison.java


示例2: makeMoons

import org.apache.commons.math3.random.RandomAdaptor; //导入依赖的package包/类
public static List<Vector2D> makeMoons(int samples, boolean shuffle, double noise, RandomGenerator random) {
    NormalDistribution dist = new NormalDistribution(random, 0.0, noise, 1e-9);

    int nSamplesOut = samples / 2;
    int nSamplesIn = samples - nSamplesOut;
    
    List<Vector2D> points = new ArrayList<Vector2D>();
    double range = FastMath.PI;
    double step = range / (nSamplesOut / 2.0);
    for (double angle = 0; angle < range; angle += step) {
        Vector2D outerCircle = new Vector2D(FastMath.cos(angle), FastMath.sin(angle));
        points.add(outerCircle.add(generateNoiseVector(dist)));
    }

    step = range / (nSamplesIn / 2.0);
    for (double angle = 0; angle < range; angle += step) {
        Vector2D innerCircle = new Vector2D(1 - FastMath.cos(angle), 1 - FastMath.sin(angle) - 0.5);
        points.add(innerCircle.add(generateNoiseVector(dist)));
    }
    
    if (shuffle) {
        Collections.shuffle(points, new RandomAdaptor(random));
    }

    return points;
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:27,代码来源:ClusterAlgorithmComparison.java


示例3: CMParameters

import org.apache.commons.math3.random.RandomAdaptor; //导入依赖的package包/类
/**
 * Constructs a new <code>CMParameters</code> configured from the given <code>MergeContext</code>.
 *
 * @param context
 *         the <code>MergeContext</code> to use
 */
public CMParameters(MergeContext context) {
    setNoMatchWeight(context.getWn());
    setRenamingWeight(context.getWr());
    setAncestryViolationWeight(context.getWa());
    setSiblingGroupBreakupWeight(context.getWs());
    setOrderingWeight(context.getWo());
    rng = new RandomAdaptor(context.getSeed().map(Well19937c::new).orElse(new Well19937c()));
    assignDist = new PascalDistribution(rng, 1, context.getpAssign());
    setPAssign(context.getpAssign());
    setFixLower(context.getFixLower());
    setFixUpper(context.getFixUpper());
    setBeta(30);
    setParallel(context.isCmMatcherParallel());
    setFixRandomPercentage(context.isCmMatcherFixRandomPercentage());
    lcaCache = new ConcurrentHashMap<>();
    siblingCache = new ConcurrentHashMap<>();
    otherSiblingsCache = new ConcurrentHashMap<>();
    exactContainsCache = new ConcurrentHashMap<>();
    boundContainsCache = new ConcurrentHashMap<>();
}
 
开发者ID:se-passau,项目名称:jdime,代码行数:27,代码来源:CMParameters.java


示例4: handleEvent

import org.apache.commons.math3.random.RandomAdaptor; //导入依赖的package包/类
@Override
public void handleEvent(@Nullable Event event) {
  checkNotNull(event);
  final Iterator<Point> points = measureString(
      ((Text) event.widget).getText(), 30, 30d, 0).iterator();
  final List<Vehicle> vs = newArrayList(vehicles);
  if (event.type == SWT.DefaultSelection) {
    Collections.shuffle(vs, new RandomAdaptor(rng));
  }
  for (final Vehicle v : vs) {
    if (points.hasNext()) {
      v.setDestination(points.next());
    } else {
      v.setInactive();
    }
  }
}
 
开发者ID:JDevlieghere,项目名称:MAS,代码行数:18,代码来源:SwarmDemo.java


示例5: AuctionCommModel

import org.apache.commons.math3.random.RandomAdaptor; //导入依赖的package包/类
AuctionCommModel(AuctionStopCondition<T> sc, Clock c, long maxAuctDurMs,
    @Nullable RandomGenerator r) {
  stopCondition = sc;
  parcelAuctioneerMap = new LinkedHashMap<>();
  maxAuctionDurationMs = maxAuctDurMs;
  rng = r == null ? null : new RandomAdaptor(r);

  eventDispatcher = new EventDispatcher(EventType.values());
  if (c instanceof RealtimeClockController) {
    clock = (RealtimeClockController) c;
  } else {
    clock = null;
  }

  numAuctions = new AtomicInteger();
}
 
开发者ID:rinde,项目名称:RinLog,代码行数:17,代码来源:AuctionCommModel.java


示例6: makeBlobs

import org.apache.commons.math3.random.RandomAdaptor; //导入依赖的package包/类
public static List<Vector2D> makeBlobs(int samples, int centers, double clusterStd,
                                       double min, double max, boolean shuffle, RandomGenerator random) {

    NormalDistribution dist = new NormalDistribution(random, 0.0, clusterStd, 1e-9);

    double range = max - min;
    Vector2D[] centerPoints = new Vector2D[centers];
    for (int i = 0; i < centers; i++) {
        double x = random.nextDouble() * range + min;
        double y = random.nextDouble() * range + min;
        centerPoints[i] = new Vector2D(x, y);
    }
    
    int[] nSamplesPerCenter = new int[centers];
    int count = samples / centers;
    Arrays.fill(nSamplesPerCenter, count);
    
    for (int i = 0; i < samples % centers; i++) {
        nSamplesPerCenter[i]++;
    }
    
    List<Vector2D> points = new ArrayList<Vector2D>();
    for (int i = 0; i < centers; i++) {
        for (int j = 0; j < nSamplesPerCenter[i]; j++) {
            Vector2D point = new Vector2D(dist.sample(), dist.sample());
            points.add(point.add(centerPoints[i]));
        }
    }
    
    if (shuffle) {
        Collections.shuffle(points, new RandomAdaptor(random));
    }

    return points;
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:36,代码来源:ClusterAlgorithmComparison.java


示例7: testRandom

import org.apache.commons.math3.random.RandomAdaptor; //导入依赖的package包/类
@Test
public void testRandom() {
    final List<Decimal> original = new ArrayList<Decimal>();
    original.add(Decimal.TWO);
    original.add(Decimal.THREE);
    original.add(Decimal.ONE);
    original.add(Decimal.TEN);
    original.add(Decimal.FIVE);
    original.add(Decimal.MINUS_THREE);

    for (int i = 0; i < 10000; i++) {
        final List<Decimal> input = new ArrayList<Decimal>(original);
        final RandomGenerator random = RandomGenerators.newDefaultRandom();
        Collections.shuffle(input, new RandomAdaptor(random));
        final List<Decimal> sorted = new BisectSortedList<Decimal>(Decimal.COMPARATOR);
        //            System.out.println("----------------"); //SUPPRESS CHECKSTYLE single line
        for (final Decimal in : input) {
            final boolean add0 = random.nextBoolean();
            if (add0) {
                sorted.add(0, in);
                //                    System.out.println("sorted.add(0, new Decimal(\"" + in + "\"));"); //SUPPRESS CHECKSTYLE single line
            } else {
                sorted.add(in);
                //                    System.out.println("sorted.add(new Decimal(\"" + in + "\"));"); //SUPPRESS CHECKSTYLE single line
            }
            Decimal.COMPARATOR.assertOrder(sorted, true);
        }
    }
}
 
开发者ID:subes,项目名称:invesdwin-util,代码行数:30,代码来源:BisectSortedListTest.java


示例8: testRandom

import org.apache.commons.math3.random.RandomAdaptor; //导入依赖的package包/类
@Test
public void testRandom() {
    final List<Decimal> original = new ArrayList<Decimal>();
    original.add(Decimal.TWO);
    original.add(Decimal.THREE);
    original.add(Decimal.ONE);
    original.add(Decimal.TEN);
    original.add(Decimal.FIVE);
    original.add(Decimal.MINUS_THREE);

    for (int i = 0; i < 10000; i++) {
        final List<Decimal> input = new ArrayList<Decimal>(original);
        final RandomGenerator random = RandomGenerators.newDefaultRandom();
        Collections.shuffle(input, new RandomAdaptor(random));
        final List<Decimal> sorted = new SortedList<Decimal>(Decimal.COMPARATOR);
        //            System.out.println("----------------"); //SUPPRESS CHECKSTYLE single line
        for (final Decimal in : input) {
            final boolean add0 = random.nextBoolean();
            if (add0) {
                sorted.add(0, in);
                //                    System.out.println("sorted.add(0, new Decimal(\"" + in + "\"));"); //SUPPRESS CHECKSTYLE single line
            } else {
                sorted.add(in);
                //                    System.out.println("sorted.add(new Decimal(\"" + in + "\"));"); //SUPPRESS CHECKSTYLE single line
            }
            Decimal.COMPARATOR.assertOrder(sorted, true);
        }
    }
}
 
开发者ID:subes,项目名称:invesdwin-util,代码行数:30,代码来源:SortedListTest.java


示例9: RandomRoutePlanner

import org.apache.commons.math3.random.RandomAdaptor; //导入依赖的package包/类
/**
 * Creates a random route planner using the specified random seed.
 * @param seed The random seed.
 */
public RandomRoutePlanner(long seed) {
  LOGGER.info("constructor {}", seed);
  assignedParcels = LinkedHashMultiset.create();
  current = Optional.absent();
  rng = new RandomAdaptor(new MersenneTwister(seed));
}
 
开发者ID:rinde,项目名称:RinLog,代码行数:11,代码来源:RandomRoutePlanner.java


示例10: sampleUniqueUsingShuffle

import org.apache.commons.math3.random.RandomAdaptor; //导入依赖的package包/类
private static <T> Iterable<T> sampleUniqueUsingShuffle(final Iterable<? extends T> elements, final int n,
                                                        final RandomGenerator rng) {
    final List<T> in = Lists.newArrayList(elements);
    Collections.shuffle(in, new RandomAdaptor(rng));
    return in.subList(0, n);
}
 
开发者ID:asoem,项目名称:greyfish,代码行数:7,代码来源:Samplings.java


示例11: randomize

import org.apache.commons.math3.random.RandomAdaptor; //导入依赖的package包/类
@Override
public Iterator<E> randomize(final RandomGenerator random) {
    final List<E> sampleCopy = new ArrayList<E>(sample);
    Collections.shuffle(sampleCopy, new RandomAdaptor(random));
    return sampleCopy.iterator();
}
 
开发者ID:subes,项目名称:invesdwin-util,代码行数:7,代码来源:ShuffleRandomizer.java


示例12: shuffle

import org.apache.commons.math3.random.RandomAdaptor; //导入依赖的package包/类
public void shuffle(RandomGenerator randomGenerator)
{
	Collections.shuffle(results, RandomAdaptor.createAdaptor(randomGenerator));
}
 
开发者ID:aherbert,项目名称:GDSC-SMLM,代码行数:5,代码来源:TurboListPeakResultStore.java


示例13: opt2

import org.apache.commons.math3.random.RandomAdaptor; //导入依赖的package包/类
static <C, T> ImmutableList<ImmutableList<T>> opt2(
    ImmutableList<ImmutableList<T>> schedule,
    IntList startIndices,
    C context,
    RouteEvaluator<C, T> evaluator,
    boolean depthFirst,
    Optional<RandomGenerator> rng,
    Optional<? extends ProgressListener<T>> listener)
        throws InterruptedException {

  checkArgument(schedule.size() == startIndices.size());

  final Schedule<C, T> baseSchedule = Schedule.create(context, schedule,
    startIndices, evaluator);

  final Object2DoubleLinkedOpenHashMap<ImmutableList<T>> routeCostCache =
    new Object2DoubleLinkedOpenHashMap<>(CACHE_SIZE);

  for (int i = 0; i < baseSchedule.routes.size(); i++) {
    routeCostCache.put(baseSchedule.routes.get(i),
      baseSchedule.objectiveValues.getDouble(i));
  }

  Schedule<C, T> bestSchedule = baseSchedule;
  boolean isImproving = true;
  while (isImproving) {
    isImproving = false;

    final Schedule<C, T> curBest = bestSchedule;
    Iterator<Swap<T>> it = swapIterator(curBest);
    if (depthFirst) {
      // randomize ordering of swaps
      final List<Swap<T>> swaps = newArrayList(it);
      Collections.shuffle(swaps, new RandomAdaptor(rng.get()));
      it = swaps.iterator();
    }

    while (it.hasNext()) {
      if (Thread.interrupted()) {
        throw new InterruptedException();
      }
      final Swap<T> swapOperation = it.next();
      final Optional<Schedule<C, T>> newSchedule = swap(curBest,
        swapOperation,
        bestSchedule.objectiveValue - curBest.objectiveValue,
        routeCostCache);

      if (newSchedule.isPresent()) {
        isImproving = true;
        bestSchedule = newSchedule.get();

        if (listener.isPresent()) {
          listener.get().notify(bestSchedule.routes,
            bestSchedule.objectiveValue);
        }
        if (depthFirst) {
          // first improving swap is chosen as new starting point (depth
          // first).
          break;
        }
      }
    }
  }
  return bestSchedule.routes;
}
 
开发者ID:rinde,项目名称:RinLog,代码行数:66,代码来源:Swaps.java



注:本文中的org.apache.commons.math3.random.RandomAdaptor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SpringSecurityLdapTemplate类代码示例发布时间:2022-05-22
下一篇:
Java TextureMetadataSectionSerializer类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap