當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。