本文整理汇总了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();
}
示例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());
}
示例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;
}
示例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;
}
示例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();
}
示例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();
}
示例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();
}
};
}
示例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);
}