当前位置: 首页>>代码示例>>Java>>正文


Java AtomicDouble.get方法代码示例

本文整理汇总了Java中com.google.common.util.concurrent.AtomicDouble.get方法的典型用法代码示例。如果您正苦于以下问题:Java AtomicDouble.get方法的具体用法?Java AtomicDouble.get怎么用?Java AtomicDouble.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.util.concurrent.AtomicDouble的用法示例。


在下文中一共展示了AtomicDouble.get方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getValue

import com.google.common.util.concurrent.AtomicDouble; //导入方法依赖的package包/类
@Override
public double getValue() {
	final AtomicDouble logProbSum = new AtomicDouble(0);

	final ParallelThreadPool ptp = new ParallelThreadPool();
	for (final TreeNode<TSGNode> tree : treeCorpus) {
		for (final TreeNode<TSGNode> root : TSGNode.getAllRootsOf(tree)) {
			ptp.pushTask(new Runnable() {

				@Override
				public void run() {
					logProbSum
							.addAndGet(computeLog2PosteriorProbabilityOfRule(
									root, true));
				}

			});

		}
	}
	ptp.waitForTermination();

	return logProbSum.get();
}
 
开发者ID:mast-group,项目名称:codemining-treelm,代码行数:25,代码来源:ClassicTsgPosteriorComputer.java

示例2: calculateCorpusLogProb

import com.google.common.util.concurrent.AtomicDouble; //导入方法依赖的package包/类
/**
 * Calculate the log-probability of the whole corpus, given the TSG.
 *
 * @return
 */
protected SampleStats calculateCorpusLogProb() {
	final AtomicDouble logProbSum = new AtomicDouble(0.);
	final AtomicInteger nNodes = new AtomicInteger(0);
	final ParallelThreadPool ptp = new ParallelThreadPool();
	for (final TreeNode<TSGNode> tree : treeCorpus) {
		ptp.pushTask(new Runnable() {

			@Override
			public void run() {
				logProbSum
				.addAndGet(computePosteriorLog2ProbabilityForTree(tree));
				nNodes.addAndGet(tree.getTreeSize());
			}

		});

	}
	ptp.waitForTermination();
	return new SampleStats(logProbSum.get(), nNodes.get());
}
 
开发者ID:mast-group,项目名称:codemining-treelm,代码行数:26,代码来源:AbstractTSGSampler.java

示例3: getStatistics

import com.google.common.util.concurrent.AtomicDouble; //导入方法依赖的package包/类
private static Statistics getStatistics(Observable<CellValue> cells) {
    final AtomicDouble sum = new AtomicDouble(0);
    final AtomicDouble sumSquares = new AtomicDouble(0);
    log.info("calculating mean and sd");
    long count = cells
    // add to sum and sumSquares
            .doOnNext(new Action1<CellValue>() {
                @Override
                public void call(CellValue cell) {
                    sum.addAndGet(cell.getValue());
                    sumSquares.addAndGet(cell.getValue() * cell.getValue());
                }
            })
            // count
            .count()
            // block and get
            .toBlocking().single();
    double mean = sum.get() / count;
    double variance = sumSquares.get() / count - mean * mean;
    double sd = Math.sqrt(variance);
    log.info("calculated");
    Statistics stats = new Statistics(mean, sd, count);
    log.info(stats);
    return stats;
}
 
开发者ID:amsa-code,项目名称:risky,代码行数:26,代码来源:Renderer.java

示例4: evaluate

import com.google.common.util.concurrent.AtomicDouble; //导入方法依赖的package包/类
@Override
public double evaluate(IChromosome a_subject) {
	EditsChromosome ec = new EditsChromosome(a_subject);
	String key = ec.key();
	if (cache.containsKey(key))
		return cache.get(key);
	try {
		initializator.initialize(algorithm, ec);
		log.debug(AlgorithmInitializator.toString(algorithm));
		final AtomicDouble distd = new AtomicDouble(0);

		EditsThread<AnnotatedEntailmentPair> thread = new EditsThread<AnnotatedEntailmentPair>() {

			@Override
			public void process(AnnotatedEntailmentPair p) throws Exception {
				double score = Double.parseDouble(p.getAttributes().get("score"));
				double ns = 5 * (1 - algorithm.distance(p.getT().get(0), p.getH().get(0), p.getId()));
				distd.addAndGet(Math.abs(score - ns));
			}
		};

		thread.start(training.iterator());

		double dist = 5.0 - distd.get() / training.size();
		GeneticResult r = new GeneticResult(dist, ec);
		log.debug(r.getValue());
		if (result == null || result.getValue() < dist)
			result = r;
		cache.put(key, dist);
		results.add(r);
		return dist;
	} catch (Exception e1) {
		e1.printStackTrace();
		System.exit(1);
	}
	cache.put(key, 0.0);
	return 0;
}
 
开发者ID:kouylekov,项目名称:edits,代码行数:39,代码来源:OptimizeDistance.java

示例5: getIndexHitRate

import com.google.common.util.concurrent.AtomicDouble; //导入方法依赖的package包/类
public Double getIndexHitRate() {
    final AtomicDouble hitRate = new AtomicDouble();
    selectWithConnection(PgStatusQueries.INDEX_HIT_RATE,(rs, cnt)-> {
        hitRate.set(rs.getDouble("rate"));
    });
    return hitRate.get();
}
 
开发者ID:johnewart,项目名称:kensho,代码行数:8,代码来源:PgStatus.java

示例6: getTableHitRate

import com.google.common.util.concurrent.AtomicDouble; //导入方法依赖的package包/类
public Double getTableHitRate() {
    final AtomicDouble hitRate = new AtomicDouble();
    selectWithConnection(PgStatusQueries.TABLE_HIT_RATE,(rs, cnt)-> {
        hitRate.set(rs.getDouble("rate"));
    });
    return hitRate.get();
}
 
开发者ID:johnewart,项目名称:kensho,代码行数:8,代码来源:PgStatus.java

示例7: make

import com.google.common.util.concurrent.AtomicDouble; //导入方法依赖的package包/类
public static MetricListener<Double> make(final AtomicDouble value) {
  return new MetricListener<Double>() {
    @Override
    public Double value() {
      return value.get();
    }
  };
}
 
开发者ID:matttproud,项目名称:groningen,代码行数:9,代码来源:Metric.java

示例8: getValueGradient

import com.google.common.util.concurrent.AtomicDouble; //导入方法依赖的package包/类
@Override
public void getValueGradient(final double[] gradients) {
	final AtomicDouble concentrationGradient = new AtomicDouble(0);
	final AtomicDouble geometricGradient = new AtomicDouble(0);

	final ParallelThreadPool ptp = new ParallelThreadPool();

	for (final TreeNode<TSGNode> tree : treeCorpus) {
		for (final TreeNode<TSGNode> subTree : TSGNode
				.getAllRootsOf(tree)) {
			ptp.pushTask(new Runnable() {
				@Override
				public void run() {
					final double nRulesCommonRoot = grammar
							.countTreesWithRoot(subTree.getData()) - 1;
					final double nRulesInGrammar = grammar
							.countTreeOccurences(subTree) - 1;

					checkArgument(nRulesCommonRoot >= nRulesInGrammar,
							"Counts are not correct");

					final int treeSize = subTree.getTreeSize();
					final double logRuleMLE = prior
							.getTreeCFLog2Probability(subTree);

					final double geometricLogProb = GeometricDistribution
							.getLog2Prob(treeSize, geometricProbability);

					final double priorLog2Prob = geometricLogProb
							+ logRuleMLE
							+ DoubleMath.log2(concentrationParameter);

					final double log2denominator = StatsUtil
							.log2SumOfExponentials(
									DoubleMath.log2(nRulesInGrammar),
									priorLog2Prob);
					concentrationGradient.addAndGet(Math.pow(2,
							geometricLogProb + logRuleMLE
									- log2denominator)
							- 1.
							/ (nRulesCommonRoot + concentrationParameter));

					final double geomGradient = Math.pow(
							1 - geometricProbability, treeSize - 1)
							- (treeSize - 1.)
							* geometricProbability
							* Math.pow(1 - geometricProbability,
									treeSize - 2);

					geometricGradient.addAndGet(concentrationParameter
							* Math.pow(2, logRuleMLE - log2denominator)
							* geomGradient);
				}

			});
		}
	}

	ptp.waitForTermination();

	gradients[0] = concentrationGradient.get() / Math.log(2);
	gradients[1] = geometricGradient.get() / Math.log(2);
}
 
开发者ID:mast-group,项目名称:codemining-treelm,代码行数:64,代码来源:ClassicTsgPosteriorComputer.java


注:本文中的com.google.common.util.concurrent.AtomicDouble.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。