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


Java TObjectDoubleMap类代码示例

本文整理汇总了Java中gnu.trove.map.TObjectDoubleMap的典型用法代码示例。如果您正苦于以下问题:Java TObjectDoubleMap类的具体用法?Java TObjectDoubleMap怎么用?Java TObjectDoubleMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: TObjectDoubleCustomHashMap

import gnu.trove.map.TObjectDoubleMap; //导入依赖的package包/类
/**
   * Creates a new <code>TObjectDoubleCustomHashMap</code> that contains the entries
   * in the map passed to it.
   *
   * @param map the <tt>TObjectDoubleMap</tt> to be copied.
   */
  public TObjectDoubleCustomHashMap( HashingStrategy<? super K> strategy,
TObjectDoubleMap<? extends K> map ) {
	
      this( strategy, map.size(), 0.5f, map.getNoEntryValue() );

      if ( map instanceof TObjectDoubleCustomHashMap ) {
          TObjectDoubleCustomHashMap hashmap = ( TObjectDoubleCustomHashMap ) map;
          this._loadFactor = hashmap._loadFactor;
          this.no_entry_value = hashmap.no_entry_value;
          this.strategy = hashmap.strategy;
          //noinspection RedundantCast
          if ( this.no_entry_value != ( double ) 0 ) {
              Arrays.fill( _values, this.no_entry_value );
          }
          setUp( (int) Math.ceil( DEFAULT_CAPACITY / _loadFactor ) );
      }
      putAll( map );
  }
 
开发者ID:JianpingZeng,项目名称:xcc,代码行数:25,代码来源:TObjectDoubleCustomHashMap.java

示例2: TObjectDoubleHashMap

import gnu.trove.map.TObjectDoubleMap; //导入依赖的package包/类
/**
 * Creates a new <code>TObjectDoubleHashMap</code> that contains the entries
 * in the map passed to it.
 *
 * @param map the <tt>TObjectDoubleMap</tt> to be copied.
 */
@SuppressWarnings("rawtypes")
public TObjectDoubleHashMap( TObjectDoubleMap<? extends K> map ) {
    this( map.size(), 0.5f, map.getNoEntryValue() );
    if ( map instanceof TObjectDoubleHashMap ) {
        TObjectDoubleHashMap hashmap = ( TObjectDoubleHashMap ) map;
        this._loadFactor = hashmap._loadFactor;
        this.no_entry_value = hashmap.no_entry_value;
        //noinspection RedundantCast
        if ( this.no_entry_value != ( double ) 0 ) {
            Arrays.fill( _values, this.no_entry_value );
        }
        setUp( (int) Math.ceil( DEFAULT_CAPACITY / _loadFactor ) );
    }
    putAll( map );
}
 
开发者ID:palantir,项目名称:trove-3.0.3,代码行数:22,代码来源:TObjectDoubleHashMap.java

示例3: TObjectDoubleCustomHashMap

import gnu.trove.map.TObjectDoubleMap; //导入依赖的package包/类
/**
   * Creates a new <code>TObjectDoubleCustomHashMap</code> that contains the entries
   * in the map passed to it.
   *
   * @param map the <tt>TObjectDoubleMap</tt> to be copied.
   */
  @SuppressWarnings({ "rawtypes", "unchecked" })
  public TObjectDoubleCustomHashMap( HashingStrategy<? super K> strategy,
TObjectDoubleMap<? extends K> map ) {
	
      this( strategy, map.size(), 0.5f, map.getNoEntryValue() );

      if ( map instanceof TObjectDoubleCustomHashMap ) {
          TObjectDoubleCustomHashMap hashmap = ( TObjectDoubleCustomHashMap ) map;
          this._loadFactor = hashmap._loadFactor;
          this.no_entry_value = hashmap.no_entry_value;
          this.strategy = hashmap.strategy;
          //noinspection RedundantCast
          if ( this.no_entry_value != ( double ) 0 ) {
              Arrays.fill( _values, this.no_entry_value );
          }
          setUp( (int) Math.ceil( DEFAULT_CAPACITY / _loadFactor ) );
      }
      putAll( map );
  }
 
开发者ID:palantir,项目名称:trove-3.0.3,代码行数:26,代码来源:TObjectDoubleCustomHashMap.java

示例4: fuseObjectsIntoSegments

import gnu.trove.map.TObjectDoubleMap; //导入依赖的package包/类
/**
 * Fuses the object scores into the segment scores by adding every object score to the scores of
 * its segments. If an object without any of its segments was found, the first segment gets added
 * and used instead.
 * Note that this method <i>modifies {@code scoreBySegmentId} in place without changing
 * {@code scoreByObjectId}</i>.
 *
 * @param scoreBySegmentId segment ids with their respective score
 * @param scoreByObjectId object ids with their respective score
 */
public static void fuseObjectsIntoSegments(TObjectDoubleMap<String> scoreBySegmentId,
    TObjectDoubleMap<String> scoreByObjectId) {
  SegmentLookup segmentLookup = new SegmentLookup();

  Set<String> objectIds = scoreByObjectId.keySet();
  ListMultimap<String, SegmentDescriptor> segmentsByObjectId =
      segmentLookup.lookUpSegmentsOfObjects(objectIds);
  for (String objectId : segmentsByObjectId.keySet()) {
    assert scoreByObjectId.containsKey(objectId);
    double objectScore = scoreByObjectId.get(objectId);
    List<SegmentDescriptor> segments = segmentsByObjectId.get(objectId);
    if (segments.isEmpty()) {
      logger.error("Object {} has no segments", objectId);
      continue;
    }
    fuseObjectScoreIntoSegments(scoreBySegmentId, objectScore, segments);
  }
  segmentLookup.close();
}
 
开发者ID:vitrivr,项目名称:cineast,代码行数:30,代码来源:ScoreFusion.java

示例5: fuseObjectScoreIntoSegments

import gnu.trove.map.TObjectDoubleMap; //导入依赖的package包/类
private static void fuseObjectScoreIntoSegments(TObjectDoubleMap<String> scoreBySegmentId,
    double objectScore, List<SegmentDescriptor> segments) {
  boolean objectSegmentsFoundInResults = false;
  for (SegmentDescriptor segment : segments) {
    boolean foundElement = scoreBySegmentId.adjustValue(segment.getSegmentId(), objectScore);
    if (foundElement) {
      objectSegmentsFoundInResults = true;
    }
  }

  if (!objectSegmentsFoundInResults) {
    SegmentDescriptor firstSegment = segments.get(0);
    String firstId = firstSegment.getSegmentId();
    scoreBySegmentId.put(firstId, objectScore);
  }
}
 
开发者ID:vitrivr,项目名称:cineast,代码行数:17,代码来源:ScoreFusion.java

示例6: TObjectDoubleCustomHashMap

import gnu.trove.map.TObjectDoubleMap; //导入依赖的package包/类
/**
 * Creates a new <code>TObjectDoubleCustomHashMap</code> that contains the entries
 * in the map passed to it.
 *
 * @param map the <tt>TObjectDoubleMap</tt> to be copied.
 */
public TObjectDoubleCustomHashMap( HashingStrategy<K> strategy, TObjectDoubleMap<K> map ) {
    this( strategy, map.size(), 0.5f, map.getNoEntryValue() );

    if ( map instanceof TObjectDoubleCustomHashMap ) {
        TObjectDoubleCustomHashMap hashmap = ( TObjectDoubleCustomHashMap ) map;
        this._loadFactor = hashmap._loadFactor;
        this.no_entry_value = hashmap.no_entry_value;
        this.strategy = hashmap.strategy;
        //noinspection RedundantCast
        if ( this.no_entry_value != ( double ) 0 ) {
            Arrays.fill( _values, this.no_entry_value );
        }
        setUp( (int) Math.ceil( DEFAULT_CAPACITY / _loadFactor ) );
    }
    putAll( map );
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:23,代码来源:TObjectDoubleCustomHashMap.java

示例7: main

import gnu.trove.map.TObjectDoubleMap; //导入依赖的package包/类
public static void main(String[] args) {
	Map<Integer, GraphColorNode> nodeIdToNode = initializeNodesOfPetersenGraph();

	List<Edge<Color, Color>> edges = initializeEdgesOfPetersenGraph(nodeIdToNode);

	inferenceOfMostProbableColorsOfNodes(edges);

	for (int i = 1; i <= 10; i++) {
		System.out.print(i);
		TObjectDoubleMap<Color> stateProbability = nodeIdToNode.get(i).getPosteriorProbabilities();
		for (Color state : stateProbability.keySet()) {
			System.out.print(String.format("\t %s = %.2f", state, stateProbability.get(state)));
		}
		System.out.println();
	}
}
 
开发者ID:lagodiuk,项目名称:java-belief-propagation,代码行数:17,代码来源:Coloring.java

示例8: updateMessagesNode2ToNode1

import gnu.trove.map.TObjectDoubleMap; //导入依赖的package包/类
/**
 * node2 -> node1
 */
public void updateMessagesNode2ToNode1() {
	TObjectDoubleMap<STATES_OF_NODE_2> node2StateToLogPriorProbabilityAndProductIncomingMessages =
			this.node2.getStateToLogPriorProbabilityAndProductIncomingMessages();

	for (STATES_OF_NODE_1 stateOfNode1 : this.node1.getStates()) {
		int i = 0;
		for (STATES_OF_NODE_2 stateOfNode2 : this.node2.getStates()) {

			double logPriorProbabilityAndProductIncomingMessages =
					node2StateToLogPriorProbabilityAndProductIncomingMessages.get(stateOfNode2)
							- this.getLogIncomingMessage(this.node2, stateOfNode2);

			this.bufferForUpdatingMessagesFromNode2[i] =
					this.potential.getLogValue(stateOfNode1, stateOfNode2)
							+ logPriorProbabilityAndProductIncomingMessages;

			i += 1;
		}
		this.logNode2ToNode1MessagesNew.put(stateOfNode1, logOfSum(this.bufferForUpdatingMessagesFromNode2));
	}
}
 
开发者ID:lagodiuk,项目名称:java-belief-propagation,代码行数:25,代码来源:Edge.java

示例9: updateMessagesNode1ToNode2

import gnu.trove.map.TObjectDoubleMap; //导入依赖的package包/类
/**
 * node1 -> node2
 */
public void updateMessagesNode1ToNode2() {
	TObjectDoubleMap<STATES_OF_NODE_1> node1StateToLogPriorProbabilityAndProductIncomingMessages =
			this.node1.getStateToLogPriorProbabilityAndProductIncomingMessages();

	for (STATES_OF_NODE_2 stateOfNode2 : this.node2.getStates()) {
		int i = 0;
		for (STATES_OF_NODE_1 stateOfNode1 : this.node1.getStates()) {

			double logPriorProbabilityAndProductIncomingMessages =
					node1StateToLogPriorProbabilityAndProductIncomingMessages.get(stateOfNode1)
							- this.getLogIncomingMessage(this.node1, stateOfNode1);

			this.bufferForUpdatingMessagesFromNode1[i] =
					this.potential.getLogValue(stateOfNode1, stateOfNode2)
							+ logPriorProbabilityAndProductIncomingMessages;

			i += 1;
		}
		this.logNode1ToNode2MessagesNew.put(stateOfNode2, logOfSum(this.bufferForUpdatingMessagesFromNode1));
	}
}
 
开发者ID:lagodiuk,项目名称:java-belief-propagation,代码行数:25,代码来源:Edge.java

示例10: testEquilibriumEvalutationMiniKuhn

import gnu.trove.map.TObjectDoubleMap; //导入依赖的package包/类
@Test
public void testEquilibriumEvalutationMiniKuhn() {
	Game miniKuhnGame = new Game();
	miniKuhnGame.createGameFromFileZerosumPackageFormat(TestConfiguration.zerosumGamesFolder + "mini_kuhn.txt");

	SequenceFormLPSolver solverP1 = new SequenceFormLPSolver(miniKuhnGame, 1);
	SequenceFormLPSolver solverP2 = new SequenceFormLPSolver(miniKuhnGame, 2);
	
	solverP1.solveGame();
	solverP2.solveGame();
	
	TObjectDoubleMap<String>[] strategyP1 = solverP1.getInformationSetActionProbabilities();
	TObjectDoubleMap<String>[] strategyP2 = solverP2.getInformationSetActionProbabilities();
	
	// get negated expected values
	double[] nodeEvaluationTable = miniKuhnGame.getExpectedValuesForNodes(strategyP1, strategyP2, true);

	// Compute the best strategy to commit to when the limited look-ahead player knows how much can be achieved from a node in (some) equilibrium
	LimitedLookAheadOpponentSolver solver = new LimitedLookAheadOpponentSolver(miniKuhnGame, 1, nodeEvaluationTable, 100);
	//solver.writeModelToFile(TestConfiguration.lpModelsFolder + "kuhnp1-limited-look-ahead.lp");
	solver.writeModelToFile(TestConfiguration.lpModelsFolder + "equilibrium-minikuhn-limited-look-ahead.lp");
	solver.solveGame();
	assertEquals(solverP1.getValueOfGame(), solver.getValueOfGame(), TestConfiguration.epsilon);
}
 
开发者ID:ChrKroer,项目名称:ExtensiveFormGames,代码行数:25,代码来源:TestLimitedLookAheadOpponentSolver.java

示例11: testEquilibriumEvalutationKuhn

import gnu.trove.map.TObjectDoubleMap; //导入依赖的package包/类
@Test
public void testEquilibriumEvalutationKuhn() {
	Game kuhnGame = new Game();
	kuhnGame.createGameFromFileZerosumPackageFormat(TestConfiguration.zerosumGamesFolder + "kuhn.txt");

	SequenceFormLPSolver solverP1 = new SequenceFormLPSolver(kuhnGame, 1);
	SequenceFormLPSolver solverP2 = new SequenceFormLPSolver(kuhnGame, 2);
	
	solverP1.solveGame();
	solverP2.solveGame();
	
	TObjectDoubleMap<String>[] strategyP1 = solverP1.getInformationSetActionProbabilities();
	TObjectDoubleMap<String>[] strategyP2 = solverP2.getInformationSetActionProbabilities();
	
	// get negated expected values
	double[] nodeEvaluationTable = kuhnGame.getExpectedValuesForNodes(strategyP1, strategyP2, true);
	System.out.println(Arrays.toString(nodeEvaluationTable));
	// Compute the best strategy to commit to when the limited look-ahead player knows how much can be achieved from a node in (some) equilibrium
	LimitedLookAheadOpponentSolver solver = new LimitedLookAheadOpponentSolver(kuhnGame, 1, nodeEvaluationTable, 1);
	//solver.writeModelToFile(TestConfiguration.lpModelsFolder + "kuhnp1-limited-look-ahead.lp");
	solver.writeModelToFile(TestConfiguration.lpModelsFolder + "equilibrium-kuhn-limited-look-ahead.lp");
	solver.solveGame();
	System.out.println(kuhnGame);
	solver.printStrategyVarsAndGameValue();
	assertEquals(solverP1.getValueOfGame(), solver.getValueOfGame(), TestConfiguration.epsilon);
}
 
开发者ID:ChrKroer,项目名称:ExtensiveFormGames,代码行数:27,代码来源:TestLimitedLookAheadOpponentSolver.java

示例12: testEquilibriumEvalutationKuhnP2

import gnu.trove.map.TObjectDoubleMap; //导入依赖的package包/类
@Test
public void testEquilibriumEvalutationKuhnP2() {
	Game kuhnGame = new Game();
	kuhnGame.createGameFromFileZerosumPackageFormat(TestConfiguration.zerosumGamesFolder + "kuhn.txt");

	SequenceFormLPSolver solverP1 = new SequenceFormLPSolver(kuhnGame, 1);
	SequenceFormLPSolver solverP2 = new SequenceFormLPSolver(kuhnGame, 2);
	
	solverP1.solveGame();
	solverP2.solveGame();
	
	TObjectDoubleMap<String>[] strategyP1 = solverP1.getInformationSetActionProbabilities();
	TObjectDoubleMap<String>[] strategyP2 = solverP2.getInformationSetActionProbabilities();
	
	// get negated expected values
	double[] nodeEvaluationTable = kuhnGame.getExpectedValuesForNodes(strategyP1, strategyP2, false);

	// Compute the best strategy to commit to when the limited look-ahead player knows how much can be achieved from a node in (some) equilibrium
	LimitedLookAheadOpponentSolver solver = new LimitedLookAheadOpponentSolver(kuhnGame, 2, nodeEvaluationTable, 1);
	//solver.writeModelToFile(TestConfiguration.lpModelsFolder + "kuhnp1-limited-look-ahead.lp");
	solver.writeModelToFile(TestConfiguration.lpModelsFolder + "equilibrium-kuhnp2-limited-look-ahead.lp");
	solver.solveGame();
	assertEquals(solverP2.getValueOfGame(), solver.getValueOfGame(), TestConfiguration.epsilon);
}
 
开发者ID:ChrKroer,项目名称:ExtensiveFormGames,代码行数:25,代码来源:TestLimitedLookAheadOpponentSolver.java

示例13: testEquilibriumEvalutationPrsl

import gnu.trove.map.TObjectDoubleMap; //导入依赖的package包/类
@Test
public void testEquilibriumEvalutationPrsl() {
	Game game = new Game();
	game.createGameFromFileZerosumPackageFormat(TestConfiguration.zerosumGamesFolder + "prsl.txt");

	SequenceFormLPSolver solverP1 = new SequenceFormLPSolver(game, 1);
	SequenceFormLPSolver solverP2 = new SequenceFormLPSolver(game, 2);
	
	solverP1.solveGame();
	solverP2.solveGame();
	
	TObjectDoubleMap<String>[] strategyP1 = solverP1.getInformationSetActionProbabilities();
	TObjectDoubleMap<String>[] strategyP2 = solverP2.getInformationSetActionProbabilities();
	
	// get negated expected values
	double[] nodeEvaluationTable = game.getExpectedValuesForNodes(strategyP1, strategyP2, true);

	// Compute the best strategy to commit to when the limited look-ahead player knows how much can be achieved from a node in (some) equilibrium
	LimitedLookAheadOpponentSolver solver = new LimitedLookAheadOpponentSolver(game, 1, nodeEvaluationTable, 100);
	//solver.writeModelToFile(TestConfiguration.lpModelsFolder + "kuhnp1-limited-look-ahead.lp");
	solver.writeModelToFile(TestConfiguration.lpModelsFolder + "equilibrium-prsl-limited-look-ahead.lp");
	solver.solveGame();
	assertEquals(solverP1.getValueOfGame(), solver.getValueOfGame(), TestConfiguration.epsilon);
}
 
开发者ID:ChrKroer,项目名称:ExtensiveFormGames,代码行数:25,代码来源:TestLimitedLookAheadOpponentSolver.java

示例14: testEquilibriumEvaluationLeducKJLa100

import gnu.trove.map.TObjectDoubleMap; //导入依赖的package包/类
@Test
public void testEquilibriumEvaluationLeducKJLa100() {
	Game leducGame = new Game();
	leducGame.createGameFromFileZerosumPackageFormat(TestConfiguration.zerosumGamesFolder + "leduc_KJ.txt");

	SequenceFormLPSolver solverP1 = new SequenceFormLPSolver(leducGame, 1);
	SequenceFormLPSolver solverP2 = new SequenceFormLPSolver(leducGame, 2);
	
	solverP1.solveGame();
	solverP2.solveGame();
	
	TObjectDoubleMap<String>[] strategyP1 = solverP1.getInformationSetActionProbabilities();
	TObjectDoubleMap<String>[] strategyP2 = solverP2.getInformationSetActionProbabilities();
	
	double[] nodeEvaluationTable = leducGame.getExpectedValuesForNodes(strategyP1, strategyP2);

	// Compute the best strategy to commit to when the limited look-ahead player knows how much can be achieved from a node in (some) equilibrium
	LimitedLookAheadOpponentSolver solver = new LimitedLookAheadOpponentSolver(leducGame, 1, nodeEvaluationTable, 100);
	solver.writeModelToFile(TestConfiguration.lpModelsFolder + "equilibrium-leducKJp1la1-limited-look-ahead.lp");
	solver.solveGame();
	System.out.println("Value of game: " + solver.getValueOfGame());
	assertEquals(solverP1.getValueOfGame(), solver.getValueOfGame(), TestConfiguration.epsilon);
}
 
开发者ID:ChrKroer,项目名称:ExtensiveFormGames,代码行数:24,代码来源:TestLimitedLookAheadOpponentSolver.java

示例15: testEquilibriumEvaluationLeducLa1

import gnu.trove.map.TObjectDoubleMap; //导入依赖的package包/类
public void testEquilibriumEvaluationLeducLa1() {
	Game leducGame = new Game();
	leducGame.createGameFromFileZerosumPackageFormat(TestConfiguration.zerosumGamesFolder + "leduc.txt");

	SequenceFormLPSolver solverP1 = new SequenceFormLPSolver(leducGame, 1);
	SequenceFormLPSolver solverP2 = new SequenceFormLPSolver(leducGame, 2);
	
	solverP1.solveGame();
	solverP2.solveGame();
	
	TObjectDoubleMap<String>[] strategyP1 = solverP1.getInformationSetActionProbabilities();
	TObjectDoubleMap<String>[] strategyP2 = solverP2.getInformationSetActionProbabilities();
	
	double[] nodeEvaluationTable = leducGame.getExpectedValuesForNodes(strategyP1, strategyP2);

	// Compute the best strategy to commit to when the limited look-ahead player knows how much can be achieved from a node in (some) equilibrium
	LimitedLookAheadOpponentSolver solver = new LimitedLookAheadOpponentSolver(leducGame, 1, nodeEvaluationTable, 1);
	solver.writeModelToFile(TestConfiguration.lpModelsFolder + "equilibrium-leducp1la2-limited-look-ahead.lp");
	solver.solveGame();
	System.out.println("Value of game: " + solver.getValueOfGame());
	assertTrue(solverP1.getValueOfGame() <= solver.getValueOfGame());
}
 
开发者ID:ChrKroer,项目名称:ExtensiveFormGames,代码行数:23,代码来源:TestLimitedLookAheadOpponentSolver.java


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