本文整理匯總了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);
}