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