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


Java AtomicDouble.addAndGet方法代码示例

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


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

示例1: visitCompressedTableEntries

import com.google.common.util.concurrent.AtomicDouble; //导入方法依赖的package包/类
private static void visitCompressedTableEntries(Expression compressedTableExpression, AtomicDouble count) {
	if (IfThenElse.isIfThenElse(compressedTableExpression)) {
		visitCompressedTableEntries(IfThenElse.thenBranch(compressedTableExpression), count);
		visitCompressedTableEntries(IfThenElse.elseBranch(compressedTableExpression), count);
	}
	else {
		// We are at a leaf node, therefore increment the count
		count.addAndGet(1);
	}
}
 
开发者ID:aic-sri-international,项目名称:aic-praise,代码行数:11,代码来源:UAIMARSolver.java

示例2: 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

示例3: getProjectionScore

import com.google.common.util.concurrent.AtomicDouble; //导入方法依赖的package包/类
public double getProjectionScore(TerminologyService referenceTerminology) {
	AtomicDouble sum = new AtomicDouble(0);
	AtomicDouble total = new AtomicDouble(0);
	List<Term> top100 = topN(100).collect(toList());
	for(Term docTerm :top100) {
		total.addAndGet(docTerm.getSpecificity());
		int baseRank = getBaseRankInRefTermino(referenceTerminology, docTerm);
		if(baseRank > 0 && baseRank < 500)
			sum.addAndGet(docTerm.getSpecificity());
	}
	return sum.doubleValue() / total.doubleValue();
}
 
开发者ID:termsuite,项目名称:termsuite-core,代码行数:13,代码来源:DocumentProjectionService.java

示例4: computeNonEdgeForces

import com.google.common.util.concurrent.AtomicDouble; //导入方法依赖的package包/类
/**
 * Compute non edge forces using barnes hut
 * @param pointIndex
 * @param theta
 * @param negativeForce
 * @param sumQ
 */
public void computeNonEdgeForces(int pointIndex, double theta, INDArray negativeForce, AtomicDouble sumQ) {
    // Make sure that we spend no time on empty nodes or self-interactions
    if (cumSize == 0 || (isLeaf() && size == 1 && index[0] == pointIndex))
        return;


    // Compute distance between point and center-of-mass
    buf.assign(data.slice(pointIndex)).subi(centerOfMass);

    double D = Nd4j.getBlasWrapper().dot(buf, buf);

    // Check whether we can use this node as a "summary"
    if (isLeaf || FastMath.max(boundary.getHh(), boundary.getHw()) / FastMath.sqrt(D) < theta) {

        // Compute and add t-SNE force between point and current node
        double Q = 1.0 / (1.0 + D);
        double mult = cumSize * Q;
        sumQ.addAndGet(mult);
        mult *= Q;
        negativeForce.addi(buf.mul(mult));

    } else {

        // Recursively apply Barnes-Hut to children
        northWest.computeNonEdgeForces(pointIndex, theta, negativeForce, sumQ);
        northEast.computeNonEdgeForces(pointIndex, theta, negativeForce, sumQ);
        southWest.computeNonEdgeForces(pointIndex, theta, negativeForce, sumQ);
        southEast.computeNonEdgeForces(pointIndex, theta, negativeForce, sumQ);
    }
}
 
开发者ID:deeplearning4j,项目名称:deeplearning4j,代码行数:38,代码来源:QuadTree.java

示例5: computeNonEdgeForces

import com.google.common.util.concurrent.AtomicDouble; //导入方法依赖的package包/类
/**
 * Compute non edge forces using barnes hut
 * @param pointIndex
 * @param theta
 * @param negativeForce
 * @param sumQ
 */
public void computeNonEdgeForces(int pointIndex, double theta, INDArray negativeForce, AtomicDouble sumQ) {
    // Make sure that we spend no time on empty nodes or self-interactions
    if (cumSize == 0 || (isLeaf() && size == 1 && index[0] == pointIndex))
        return;


    // Compute distance between point and center-of-mass
    buf.assign(data.slice(pointIndex)).subi(centerOfMass);

    double D = Nd4j.getBlasWrapper().dot(buf, buf);
    // Check whether we can use this node as a "summary"
    double maxWidth = boundary.width().max(Integer.MAX_VALUE).getDouble(0);
    // Check whether we can use this node as a "summary"
    if (isLeaf() || maxWidth / Math.sqrt(D) < theta) {

        // Compute and add t-SNE force between point and current node
        double Q = 1.0 / (1.0 + D);
        double mult = cumSize * Q;
        sumQ.addAndGet(mult);
        mult *= Q;
        negativeForce.addi(buf.mul(mult));

    } else {

        // Recursively apply Barnes-Hut to children
        for (int i = 0; i < numChildren; i++) {
            children[i].computeNonEdgeForces(pointIndex, theta, negativeForce, sumQ);
        }

    }
}
 
开发者ID:deeplearning4j,项目名称:deeplearning4j,代码行数:39,代码来源:SpTree.java

示例6: test

import com.google.common.util.concurrent.AtomicDouble; //导入方法依赖的package包/类
@Test
public void test() {
	ChronoGraph g = new ChronoGraph("epcis");
	// g.getChronoVertexSet().parallelStream().forEach(v -> System.out.println(v));

	BsonArray contains = new BsonArray();
	contains.add(new BsonString("contains"));

	// 각 중요시간 마다 트럭 안에 있는 물건들의 리스트와 무게를 가져옴

	Iterator<Long> timeSet = g.getChronoVertex("urn:epc:id:sscc:0000001.0000000001")
			.getTimestamps(Direction.OUT, contains, 0l, AC.$gt).iterator();

	while (timeSet.hasNext()) {
		Long t = timeSet.next();
		System.out.println("at " + new Date(t));
		AtomicDouble totalK = new AtomicDouble();
		ConcurrentHashMap<String, String> map = new ConcurrentHashMap<String, String>();

		PipeFunction<EdgeEvent, Boolean> retainIfAdd = new PipeFunction<EdgeEvent, Boolean>() {

			@Override
			public Boolean compute(EdgeEvent ee) {
				if (ee.getProperty("action").equals(new BsonString("ADD"))) {
					return true;
				}
				return false;
			}
		};

		PipeFunction<VertexEvent, Object> listUpFreight = new PipeFunction<VertexEvent, Object>() {
			@Override
			public Object compute(VertexEvent ve) {
				BsonDouble kg = (BsonDouble) ve.getVertex().getProperty("urn:epc:cbv:mda:netWeight");
				totalK.addAndGet(kg.doubleValue());
				map.put(ve.getVertex().toString(), "1");
				return ve;
			}
		};

		TraversalEngine engine = new TraversalEngine(g,
				g.getChronoVertex("urn:epc:id:sscc:0000001.0000000001").setTimestamp(t), false, false,
				VertexEvent.class);
		engine.outEe(contains, TemporalType.TIMESTAMP, AC.$lte, null, null, null, null, null, null)
				.filter(retainIfAdd).inVe().sideEffect(listUpFreight).toList();

		// g.getChronoVertex("urn:epc:id:sscc:0000001.0000000001").getChronoEdgeSet(Direction.OUT,
		// contains)
		// .parallelStream().forEach(e -> {
		// // System.out.println(e);
		//
		// EdgeEvent ee = e.pickFloorTimestamp(t);
		// if (ee != null && ee.getProperty("action").equals(new BsonString("ADD"))) {
		// BsonDouble kg = (BsonDouble)
		// e.getInVertex().getProperty("urn:epc:cbv:mda:netWeight");
		// totalK.addAndGet(kg.doubleValue());
		// map.put(e.getInVertex().toString(), "1");
		// }
		// });

		System.out.println(map.keySet());
		System.out.println(totalK);
	}

	g.shutdown();
}
 
开发者ID:JaewookByun,项目名称:epcis,代码行数:67,代码来源:AggregationTest.java


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