Java 类gnu.trove.map.hash.TIntDoubleHashMap 实例源码

项目:DebugServerInfo    文件:ServerHelper.java   
public static Data getData()
{
    if (data != null) return data;

    MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();

    Integer[] dimsObj = DimensionManager.getIDs();
    TIntDoubleMap map = new TIntDoubleHashMap(dimsObj.length);

    for (Integer dim : dimsObj)
    {
        map.put(dim, mean(server.worldTickTimes.get(dim)) * 1.0E-6D);
    }

    double meanTickTime = mean(server.tickTimeArray) * 1.0E-6D;

    int total = (int) (Runtime.getRuntime().totalMemory() / 1024 / 1024);
    int max = (int) (Runtime.getRuntime().maxMemory() / 1024 / 1024);
    int free = (int) (Runtime.getRuntime().freeMemory() / 1024 / 1024);

    data = new Data(meanTickTime, map, free, total, max);
    return data;
}
项目:DynamicSurroundings    文件:ServiceManager.java   
/**
 * Collect tick performance data for the loaded dimensions and broadcast to
 * attached players.
 * 
 * @param event
 */
@SubscribeEvent
public void tickEvent(@Nonnull final TickEvent.ServerTickEvent event) {
    if (!ModOptions.reportServerStats || event.phase != Phase.END)
        return;

    // Spam once a second
    if ((++tpsCount % 20) != 0)
        return;

    MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();

    final TIntDoubleHashMap map = new TIntDoubleHashMap();
    for (Integer dim : DimensionManager.getIDs()) {
        map.put(dim.intValue(), mean((long[]) server.worldTickTimes.get(dim)) / 1000000D);
    }

    final double meanTickTime = mean(server.tickTimeArray) / 1000000D;
    final int total = (int) (Runtime.getRuntime().totalMemory() / 1024L / 1024L);
    final int max = (int) (Runtime.getRuntime().maxMemory() / 1024L / 1024L);
    final int free = (int) (Runtime.getRuntime().freeMemory() / 1024L / 1024L);

    final PacketServerData packet = new PacketServerData(map, meanTickTime, free, total, max);
    Network.sendToAll(packet);
}
项目:wikit    文件:ConceptVectorSimilarity.java   
/**
     * cosine similarity
     * @param v0
     * @param v1
     * @return
     */
    public double calcSimilarity(ConceptVector v0, ConceptVector v1) {
//        double sum = 0.0;
//        ConceptIterator it0 = v0.iterator();
//        while (it0.next()) {
//            double value1 = v1.get(it0.getId());
//            if (value1 > 0) {
//                sum +=  it0.getValue() * value1;
//            }
//        }
//
//        return sum / ( v0.getNorm2() *  v1.getNorm2());
        TIntDoubleMap X = new TIntDoubleHashMap();
        TIntDoubleMap Y = new TIntDoubleHashMap();
        ConceptIterator it = v0.iterator();
        while (it.next()) {
            X.put(it.getId(), it.getValue());
        }
        it = v1.iterator();
        while (it.next()) {
            Y.put(it.getId(), it.getValue());
        }
        return SimUtils.cosineSimilarity(X, Y);
    }
项目:wikit    文件:SimUtils.java   
/**
 * Normalize a vector to unit length.
 * @param X
 * @return
 */
public static TIntDoubleMap normalizeVector(TIntDoubleMap X) {
    TIntDoubleHashMap Y = new TIntDoubleHashMap();
    double sumSquares = 0.0;
    for (double x : X.values()) {
        sumSquares += x * x;
    }
    if (sumSquares != 0.0) {
        double norm = Math.sqrt(sumSquares);
        for (int id : X.keys()) {
            Y.put(id, X.get(id) / norm);
        }
        return Y;
    }
    return X;
}
项目:Excitement-TDMLEDA    文件:GeneralElementSimilarityCalculator.java   
protected void writeSimnilarity(int element1Id, double element1Score, TIntObjectIterator<ElementSimilarityScoring> it, boolean bR2L) throws SerializationException, IOException, NoScoreFoundException {
    TIntDoubleMap elementsScores = new TIntDoubleHashMap();
    while (it.hasNext()) {
        it.advance();
        int element2Id = it.key();
        if (elementFilter == null || elementFilter.isRelevantElementForCalculation(element2Id)) {
            double element2Score = elementFeatureScoreStorage.getElementScore(element2Id);
            ElementSimilarityScoring similarityScoring = it.value();
            double similarityScore = bR2L ?
                        similarityScoring.getSimilarityScore(element2Score, element1Score) :
                        similarityScoring.getSimilarityScore(element1Score, element2Score);
            if (similarityScore > 0)
                elementsScores.put(element2Id, similarityScore);
        }
    }

    LinkedHashMap<Integer, Double> sortedElementScores = SortUtil.sortMapByValue(elementsScores,true);

    if (vectorTruncater != null) 
        sortedElementScores = vectorTruncater.truncate(sortedElementScores);

    if (bR2L)
        outR2LDevice.write(element1Id, sortedElementScores);
    else
        outL2RDevice.write(element1Id, sortedElementScores);
}
项目:MaxParser    文件:FeatureVector.java   
public double dotProduct(FeatureVector fv2){
    TIntDoubleHashMap hm1 = new TIntDoubleHashMap(this.size());
    addFeaturesToMap(hm1, false);
    hm1.compact();

    TIntDoubleHashMap hm2 = new TIntDoubleHashMap(fv2.size());
    fv2.addFeaturesToMap(hm2, false);
    hm2.compact();

    int[] keys = hm1.keys();

    double score = 0.0;
    for(int i = 0; i < keys.length; ++i){
        score += hm1.get(keys[i]) * hm2.get(keys[i]);
    }
    return score;
}
项目:MaxParser    文件:FeatureVector.java   
public void addFeaturesToMap(TIntDoubleHashMap map, boolean negate){
    if(subfv1 != null){
        subfv1.addFeaturesToMap(map, negate);
        if(subfv2 != null){
            subfv2.addFeaturesToMap(map, negate ^ negateSecondSubFV);
        }
    }
    for(Object b : this){
        Feature f = (Feature)(b);
        if(negate){
            if(!map.adjustValue(f.index, -f.value)){
                map.put(f.index, -f.value);
            }
        }
        else{
            if(!map.adjustValue(f.index, f.value)){
                map.put(f.index, f.value);
            }
        }
    }
}
项目:cl-esa    文件:CLESA.java   
public void makeVector() {
    TIntDoubleHashMap vecMapT = new TIntDoubleHashMap();    
    String fieldName = pair.getSecond().getIso639_1() + "TopicContent";
    TopScoreDocCollector docsCollector = searcher.search(pair.getFirst(), lucHits, fieldName, AnalyzerFactory.getAnalyzer(pair.getSecond()));           
    if(docsCollector == null) {
        vectorMapT.put(threadName, null); 
        return;             
    }   
    ScoreDoc[] scoreDocs = docsCollector.topDocs().scoreDocs;
    double score = 0.0;
    for(int i=0;i<scoreDocs.length;++i) {
        int docID = scoreDocs[i].doc;
        score = scoreDocs[i].score;
        vecMapT.put(docID, score);
    }       
    vectorMapT.put(threadName, vecMapT);
}
项目:cl-esa    文件:CLESA.java   
public static void main(String[] args) {
    String text1;
    String text2;       
    if(args.length==2){
         text1 = args[0];
         text2 = args[1];
    }       
    text1 = "computer";
    text2 = "science";
    Pair<String, Language> pair1 = new Pair<String, Language>(text1, Language.ENGLISH);
    Pair<String, Language> pair2 = new Pair<String, Language>(text2, Language.SPANISH);
    boolean onRAM = true;
    CLESA clesa = new CLESA(onRAM);
    double score = clesa.score(pair1, pair2);
    System.out.println(score);      

    TIntDoubleHashMap vector = clesa.getVector(pair1);
    Map<String, Double> uriVector = clesa.getURIVector(vector);
    for(String uri : uriVector.keySet())
        System.out.println(uri + "\t" + uriVector.get(uri)) ;

}
项目:olca-modules    文件:HashMatrix.java   
public CompressedRowMatrix compress() {
    CompressedRowMatrix c = new CompressedRowMatrix(rows, cols);
    int entryCount = getNumberOfEntries();
    c.columnIndices = new int[entryCount];
    c.values = new double[entryCount];
    int idx = 0;
    for (int row = 0; row < rows; row++) {
        c.rowPointers[row] = idx;
        TIntDoubleHashMap rowMap = data.get(row);
        if (rowMap == null)
            continue;
        TIntDoubleIterator it = rowMap.iterator();
        while (it.hasNext()) {
            it.advance();
            c.columnIndices[idx] = it.key();
            c.values[idx] = it.value();
            idx++;
        }
    }
    return c;
}
项目:morpheus-core    文件:SparseArrayOfDoubles.java   
/**
 * Constructor
 * @param length    the length for this array
 * @param defaultValue  the default value for array
 */
SparseArrayOfDoubles(int length, Double defaultValue) {
    super(Double.class, ArrayStyle.SPARSE, false);
    this.length = length;
    this.defaultValue = defaultValue != null ? defaultValue : Double.NaN;
    this.values = new TIntDoubleHashMap((int)Math.max(length * 0.5, 10d), 0.8f, -1, this.defaultValue);
}
项目:DynamicSurroundings    文件:PacketServerData.java   
public PacketServerData(@Nonnull final TIntDoubleHashMap tps, final double meanTickTime, final int memFree,
        int memTotal, int memMax) {
    this.meanTickTime = meanTickTime;
    this.tMap = tps;
    this.free = memFree;
    this.total = memTotal;
    this.max = memMax;
}
项目:DynamicSurroundings    文件:PacketServerData.java   
@Override
public void fromBytes(@Nonnull final ByteBuf buf) {
    this.meanTickTime = buf.readDouble();
    int len = buf.readInt();
    this.tMap = new TIntDoubleHashMap(len);
    while (len-- != 0) {
        this.tMap.put(buf.readInt(), buf.readDouble());
    }
    this.free = buf.readInt();
    this.total = buf.readInt();
    this.max = buf.readInt();
}
项目:DynamicSurroundings    文件:ServerDataEvent.java   
public ServerDataEvent(@Nonnull final TIntDoubleHashMap dimensionTps, final double meanTickTime, final int freeMemory, final int totalMemory, final int maxMemory) {
    this.dimTps = dimensionTps;
    this.meanTickTime = meanTickTime;
    this.free = freeMemory;
    this.total = totalMemory;
    this.max = maxMemory;
}
项目:monsoon    文件:MetricTable.java   
public MetricTable(int timestampsSize) {
    this.timestampsSize = timestampsSize;
    this.t_bool = new TIntByteHashMap(timestampsSize, 1, -1, (byte) -1);
    this.t_16bit = new TIntShortHashMap(timestampsSize, 1, -1, (short) -1);
    this.t_32bit = new TIntIntHashMap(timestampsSize, 1, -1, -1);
    this.t_64bit = new TIntLongHashMap(timestampsSize, 1, -1, -1);
    this.t_dbl = new TIntDoubleHashMap(timestampsSize, 1, -1, -1);
    this.t_str = new TIntIntHashMap(timestampsSize, 1, -1, -1);
    this.t_hist = new TIntObjectHashMap<>(timestampsSize, 1, -1);
    this.t_empty = new TIntHashSet(timestampsSize, 1, -1);
    this.t_other = new TIntObjectHashMap<>(timestampsSize, 1, -1);
}
项目:wikit    文件:TroveConceptVector.java   
public static void main(String[] args) {
    TIntDoubleHashMap map = new TIntDoubleHashMap();
    map.put(1, 1.0);
    map.put(2, 2.0);
    map.put(3, 3.0);

    NormProcedure n1 = new NormProcedure( 1 );
    map.forEachValue(n1);
    System.out.println(n1.getNorm());

    NormProcedure n2 = new NormProcedure( 2 );
    map.forEachValue(n2);
    System.out.println(n2.getNorm());
}
项目:wikit    文件:SimUtils.java   
public static Map sortByValue(TIntDoubleHashMap unsortMap) {
    if (unsortMap.isEmpty()) {
        return new HashMap();
    }
    HashMap<Integer, Double> tempMap = new HashMap<Integer, Double>();
    TIntDoubleIterator iterator = unsortMap.iterator();
    for ( int i = unsortMap.size(); i-- > 0; ) {
        iterator.advance();
        tempMap.put( iterator.key(), iterator.value() );
    }
    List<Map.Entry> list = new LinkedList<Map.Entry>(tempMap.entrySet());

    // sort list based on comparator
    Collections.sort(list, Collections.reverseOrder(new Comparator() {
        public int compare(Object o1, Object o2) {
            return ((Comparable) ((Map.Entry) (o1)).getValue())
                    .compareTo(((Map.Entry) (o2)).getValue());
        }
    }));

    Map sortedMap = new LinkedHashMap();
    for (Iterator it = list.iterator(); it.hasNext();) {
        Map.Entry entry = (Map.Entry) it.next();
        sortedMap.put(entry.getKey(), entry.getValue());
    }
    return sortedMap;
}
项目:Excitement-TDMLEDA    文件:MemoryBasedElementSimilarityCombiner.java   
protected TIntObjectMap<TIntDoubleMap> device2map(PersistenceDevice device) throws Exception {
    TIntObjectMap<TIntDoubleMap> ret = new TIntObjectHashMap<TIntDoubleMap>();
    Pair<Integer, Serializable> pair = null;
    while ((pair = device.read()) != null) {
        TIntDoubleMap map = new TIntDoubleHashMap();
        @SuppressWarnings("unchecked")
        LinkedHashMap<Integer, Double> linkedhashmap = (LinkedHashMap<Integer,Double>)pair.getSecond();
        for (Entry<Integer,Double> entry : linkedhashmap.entrySet())
            map.put(entry.getKey(), entry.getValue());
        ret.put(pair.getFirst(),map);
    }
    return ret;
}
项目:LaToe    文件:SegmentCRF.java   
public double segmentMarginalProbabilities(DataSequence dataSequence, TIntDoubleHashMap segmentMarginals[][], TIntDoubleHashMap edgeMarginals[][][]) {
        if (trainer==null) {
            trainer = getTrainer();
            trainer.init(this,null,lambda);
        }
        return -1*((SegmentTrainer)trainer).sumProductInner(dataSequence,featureGenerator,lambda,null,false, -1, null,segmentMarginals,edgeMarginals);
}
项目:LaToe    文件:SegmentCRF.java   
public double[] marginalProbsOfSegmentation(DataSequence dataSequence, Segmentation segmentation) {
    TIntDoubleHashMap segMargs[][] = new TIntDoubleHashMap[numY][dataSequence.length()];
    for (int i = segmentation.numSegments()-1; i >= 0; i--) {
        segMargs[segmentation.segmentLabel(i)][segmentation.segmentStart(i)] = new TIntDoubleHashMap();
        segMargs[segmentation.segmentLabel(i)][segmentation.segmentStart(i)].put(segmentation.segmentEnd(i), 0);
    }
    segmentMarginalProbabilities(dataSequence, segMargs, null);
    double margPr[]=new double[segmentation.numSegments()];
    for (int i = segmentation.numSegments()-1; i >= 0; i--) {
        margPr[i] = segMargs[segmentation.segmentLabel(i)][segmentation.segmentStart(i)].get(segmentation.segmentEnd(i));
    }
    return margPr;
}
项目:DemigodsRPG    文件:PlayerModel.java   
@SuppressWarnings("deprecation")
public PlayerModel(OfflinePlayer player) {
    mojangId = player.getUniqueId().toString();
    lastKnownName = player.getName();
    lastLoginTime = System.currentTimeMillis();

    experience = new TIntDoubleHashMap(1);

    // Debug data
    if (Setting.DEBUG_DATA) {
        handleDemo();
    } else {
        // Neutral faction
        family = Family.NEUTRAL;

        // Empty deities
        primary = Optional.empty();
        secondary = Optional.empty();
    }

    maxHealth = 20.0;

    favor = 700.0;
    level = 0;

    canPvp = true;
    adminMode = false;

    kills = 0;
    deaths = 0;
    teamKills = 0;
}
项目:dis-timeintervaldataanalyzer    文件:EventTable.java   
/**
 * Creates a sorted map of the best fitting values
 * 
 * @param eventTables
 *            the list of tables to be compared
 * @param dt
 *            the distance type to use
 * 
 * @return the sorted map
 */
public LinkedHashMap<EventTable, Double> createCompareList(
        final List<EventTable> eventTables, final DistanceType dt) {

    // calculate the distances
    final TIntDoubleHashMap distances = new TIntDoubleHashMap();
    for (int i = 0; i < eventTables.size(); i++) {
        final double val = this.distance(eventTables.get(i), dt);
        distances.put(i, val);
    }

    // find the top ten
    final TreeMap<Integer, Double> sorted = new TreeMap<Integer, Double>(
            new Comparator<Integer>() {

                @Override
                public int compare(final Integer o1, final Integer o2) {
                    return distances.get(o1) < distances.get(o2) ? -1 : 1;
                }
            });
    distances.forEachEntry(new TIntDoubleProcedure() {

        @Override
        public boolean execute(final int a, final double b) {
            sorted.put(a, b);
            return true;
        }
    });

    final LinkedHashMap<EventTable, Double> result = new LinkedHashMap<EventTable, Double>();
    for (final int pos : sorted.keySet()) {
        result.put(eventTables.get(pos), distances.get(pos));
    }

    return result;
}
项目:cl-esa    文件:CLESA.java   
public double score(Pair<String, Language> pair1, Pair<String, Language> pair2) {
    String phrase1 = normalize(pair1.getFirst(), pair1.getSecond());
    String phrase2 = normalize(pair2.getFirst(), pair2.getSecond());
    pair1 = new Pair<String, Language>(phrase1, pair1.getSecond());
    pair2 = new Pair<String, Language>(phrase2, pair2.getSecond());     
    Map<String, TIntDoubleHashMap> vectorMap = new HashMap<String, TIntDoubleHashMap>();
    Barrier barrier = new Barrier(2);
    new TopicVectorThread("vector1", barrier, vectorMap, pair1, searcher).start();
    new TopicVectorThread("vector2", barrier, vectorMap, pair2, searcher).start();
    barrier.barrierWait();      
    TIntDoubleHashMap vector1 = vectorMap.get("vector1");
    TIntDoubleHashMap vector2 = vectorMap.get("vector2");               
    return TroveVectorUtils.cosineProduct(vector1, vector2);    
}
项目:cl-esa    文件:CLESA.java   
public double scoreAgainstVector(Pair<String, Language> pair1, TIntDoubleHashMap vector2) {
    String phrase1 = normalize(pair1.getFirst(), pair1.getSecond());
    pair1 = new Pair<String, Language>(phrase1, pair1.getSecond());
    Map<String, TIntDoubleHashMap> vectorMap = new HashMap<String, TIntDoubleHashMap>();
    Barrier barrier = new Barrier(1);
    new TopicVectorThread("vector1", barrier, vectorMap, pair1, searcher).start();
    barrier.barrierWait();      
    TIntDoubleHashMap vector1 = vectorMap.get("vector1");
    return TroveVectorUtils.cosineProduct(vector1, vector2);    
}
项目:cl-esa    文件:CLESA.java   
public Map<String, Double> getURIVector(TIntDoubleHashMap docIdScoreVector) {
    Map<String, Double> uriScoreVec = new HashMap<String, Double>();
    int[] keys = docIdScoreVector.keys();
    for(int key : keys){
        Document doc = searcher.getDocumentWithDocID(key);
        String uri = doc.get("URI_EN");
        uriScoreVec.put(uri, docIdScoreVector.get(key));
    }
    return uriScoreVec;
}
项目:cl-esa    文件:CLESA.java   
public TIntDoubleHashMap getVector(Pair<String, Language> pair) {
    String phrase = normalize(pair.getFirst(), pair.getSecond());
    pair = new Pair<String, Language>(phrase, pair.getSecond());        
    Map<String, TIntDoubleHashMap> vectorMap = new HashMap<String, TIntDoubleHashMap>();        
    Barrier barrier = new Barrier(1);
    new TopicVectorThread("vector", barrier, vectorMap, pair, searcher).start();
    barrier.barrierWait();      
    return vectorMap.get("vector");
}
项目:cl-esa    文件:CLESA.java   
public TopicVectorThread(String threadName, Barrier barrier, Map<String, TIntDoubleHashMap> vectorMapT, Pair<String, Language> pair, Searcher searcher){
    super(threadName);      
    this.threadName = threadName;
    this.barrier = barrier;
    this.vectorMapT = vectorMapT;
    this.searcher = searcher;
    this.pair = pair;
}
项目:cl-esa    文件:TroveVectorUtils.java   
public static double cosineProduct(TIntDoubleHashMap map1, TIntDoubleHashMap map2){
    if(map1 == null || map2 == null)
        return 0.0;     
    double magnitudeVector1 = 0.0;
    double magnitudeVector2 = 0.0;
    double dotProduct = 0.0;                    
    TIntDoubleHashMap iteratingMap = null;
    TIntDoubleHashMap secMap = null;        
    if(map1.size() >= map2.size()){
        iteratingMap = map1;
        secMap = map2;
    }
    else {
        iteratingMap = map2;
        secMap = map1;
    }       
    int[] secKeys = secMap.keys();
    int i = 0;      
    for(int unitVector : iteratingMap.keys()){
        double score1 =  iteratingMap.get(unitVector);
        double score2 = 0.0;
        if(secMap.containsKey(unitVector)){
            score2 = secMap.get(unitVector);
            dotProduct = dotProduct + score1*score2;
        }
        if(i < secKeys.length){
            score2 = secMap.get(secKeys[i++]);
            magnitudeVector2 = magnitudeVector2 + score2 * score2;          
        }       
        magnitudeVector1 = magnitudeVector1 + score1*score1;
    }

    if((magnitudeVector1 > 0.0)&&(magnitudeVector2 > 0.0))
        dotProduct = dotProduct /((Math.sqrt(magnitudeVector1) * Math.sqrt(magnitudeVector2)));
    else
        dotProduct = 0;

    return dotProduct;
}
项目:olca-modules    文件:HashMatrix.java   
@Override
public double get(int row, int col) {
    TIntDoubleHashMap rowMap = data.get(row);
    if (rowMap == null)
        return 0;
    return rowMap.get(col);
}
项目:olca-modules    文件:HashMatrix.java   
/**
 * Iterates over the non-zero values in this matrix.
 */
public void iterate(MatrixIterator it) {
    for (int row : data.keys()) {
        TIntDoubleHashMap rowMap = data.get(row);
        if (rowMap == null)
            continue;
        for (int col : rowMap.keys()) {
            double val = rowMap.get(col);
            if (Numbers.isZero(val))
                continue;
            it.next(row, col, val);
        }
    }
}
项目:olca-modules    文件:HashMatrix.java   
public int getNumberOfEntries() {
    int entryCount = 0;
    for (int row = 0; row < rows; row++) {
        TIntDoubleHashMap rowMap = data.get(row);
        if (rowMap == null)
            continue;
        entryCount += rowMap.size();
    }
    return entryCount;
}
项目:jbosen    文件:SparseDoubleColumnMap.java   
/**
 * Construct a new object, this object initially contains no columns.
 */
public SparseDoubleColumnMap() {
    this.values = new TIntDoubleHashMap();
}
项目:wikit    文件:TroveConceptVector.java   
public TroveConceptVector(int size ) {
    this.size = size;
    valueMap = new TIntDoubleHashMap(size);     
}
项目:wikit    文件:TroveConceptVectorOrderedIterator.java   
public TroveConceptVectorOrderedIterator( TIntDoubleHashMap valueMap ) {
    index = valueMap.keys();
    values = valueMap.values();
    HeapSort.heapSort(values, index);
    reset();
}
项目:ExtensiveFormGames    文件:SequenceFormLPSolver.java   
/**
 * Initializes the arrays and other data structure objects that we use.
 */
@SuppressWarnings("unchecked")
private void initializeDataStructures() {
    int numInformationSets = 0;
    //int numDualInformationSets = 0;


    if (playerToSolveFor == 1) {
        numInformationSets = game.getNumInformationSetsPlayer1();
        //numDualInformationSets = game.getNumInformationSetsPlayer2();
    } else {
        numInformationSets = game.getNumInformationSetsPlayer2();
        //numDualInformationSets = game.getNumInformationSetsPlayer1();
    }
    this.strategyVarsByInformationSet = (HashMap<String, IloNumVar>[]) new HashMap[numInformationSets+1];
    for (int i = 0; i <= numInformationSets; i++) {
        this.strategyVarsByInformationSet[i] = new HashMap<String, IloNumVar>();
    }


    numPrimalSequences = playerToSolveFor == 1 ? game.getNumSequencesP1() : game.getNumSequencesP2();
    numDualSequences = playerNotToSolveFor == 1 ? game.getNumSequencesP1() : game.getNumSequencesP2();
    sequenceFormDualMatrix = new TIntList[numDualSequences];
    for (int i = 0; i < numDualSequences; i++) {
        sequenceFormDualMatrix[i] =  new TIntArrayList();
    }
    numPrimalInformationSets = playerToSolveFor == 1 ? game.getNumInformationSetsPlayer1() : game.getNumInformationSetsPlayer2();
    numDualInformationSets = playerNotToSolveFor == 1 ? game.getNumInformationSetsPlayer1() : game.getNumInformationSetsPlayer2();

    dualSequenceNames = new String[numDualSequences];
    primalSequenceNames = new String[numPrimalSequences];

    dualPayoffMatrix = new TIntDoubleHashMap[numDualSequences];
    for (int i = 0; i < numDualSequences; i++) {
        dualPayoffMatrix[i] = new TIntDoubleHashMap();
    }

    // ensure that we have a large enough array for both the case where information sets start at 1 and 0
    sequenceIdByInformationSetAndActionP1 = new TObjectIntMap[game.getNumInformationSetsPlayer1()+1];
    sequenceIdByInformationSetAndActionP2 = new TObjectIntMap[game.getNumInformationSetsPlayer2()+1];
    for (int i = 0; i <= game.getNumInformationSetsPlayer1(); i++) {
        sequenceIdByInformationSetAndActionP1[i] = new TObjectIntHashMap<String>();
    }
    for (int i = 0; i <= game.getNumInformationSetsPlayer2(); i++) {
        sequenceIdByInformationSetAndActionP2[i] = new TObjectIntHashMap<String>();
    }

    if (playerToSolveFor == 1) {
        strategyVarsBySequenceId = new IloNumVar[game.getNumSequencesP1()];
    } else {
        strategyVarsBySequenceId = new IloNumVar[game.getNumSequencesP2()];
    }

    primalConstraints = new TIntObjectHashMap<IloConstraint>();
    dualConstraints = new TIntObjectHashMap<IloRange>();
    nodeNatureProbabilities = new double[game.getNumNodes()+1]; // Use +1 to be robust for non-zero indexed nodes
    sequenceIdForNodeP1 = new int[game.getNumNodes()+1];
    sequenceIdForNodeP2 = new int[game.getNumNodes()+1];

}
项目:LaToe    文件:LogSparseDoubleMatrix1D.java   
LogSparseDoubleMatrix1DOld(int numY) {
    super(numY);
    elementsZ = new TIntDoubleHashMap();
}
项目:LaToe    文件:OptimizedSparseDoubleMatrix1D.java   
public OptimizedSparseDoubleMatrix1D(int capacity){
    applyNonZero = null;
    values = new TIntDoubleHashMap(capacity);
}
项目:LaToe    文件:BSegmentCRF.java   
public double segmentMarginalProbabilities(DataSequence dataSequence, TIntDoubleHashMap segmentMarginals[][], TIntDoubleHashMap edgeMarginals[][][]) {
    System.err.println("Not yet implemented for this CRF--use SegmentCRF");
    System.exit(-1);
    return 0;
}
项目:DemigodsRPG    文件:PlayerModel.java   
@SuppressWarnings("unchecked")
public PlayerModel(String mojangId, DataSection conf) {
    this.mojangId = mojangId;
    lastKnownName = conf.getString("last_known_name");
    lastLoginTime = conf.getLong("last_login_time");
    aspects.addAll(conf.getStringList("aspects"));
    if (conf.getStringList("shrine_warps") != null) {
        shrineWarps.addAll(conf.getStringList("shrine_warps"));
    }
    primary = Optional.ofNullable(DGData.getDeity(conf.getStringNullable("primary")));
    secondary = Optional.ofNullable(DGData.getDeity(conf.getStringNullable("secondary")));
    for (Object contractName : conf.getList("contracts", new ArrayList<>())) {
        Deity contract = DGData.getDeity(contractName.toString());
        if (contract != null) {
            contracts.add(contract);
        }
    }
    family = DGData.getFamily(conf.getStringNullable("faction"));
    if (family == null) {
        family = Family.NEUTRAL;
    }
    Map binds = conf.isSection("binds") ? conf.getSectionNullable("binds") : null;
    if (binds != null) {
        this.binds.putAll(binds);
    }
    maxHealth = conf.getDouble("max_health", 20.0);
    favor = conf.getDouble("favor", 20.0);
    experience = new TIntDoubleHashMap(1);
    boolean expError = false;
    for (Map.Entry<String, Object> entry : conf.getSectionNullable("devotion").entrySet()) {
        try {
            experience.put(Integer.valueOf(entry.getKey()), Double.valueOf(entry.getValue().toString()));
        } catch (Exception ignored) {
            expError = true;
        }
    }
    if (expError) {
        DGData.CONSOLE.warning("There was an error loading devotion data for " + lastKnownName + ".");
    }
    level = conf.getInt("level");
    canPvp = conf.getBoolean("can_pvp", true);
    adminMode = conf.getBoolean("admin_mode", false);
    kills = conf.getInt("kills");
    deaths = conf.getInt("deaths");
    teamKills = conf.getInt("team_kills");
}
项目:olca-modules    文件:HashMatrix.java   
public boolean hasEntry(int row, int col) {
    TIntDoubleHashMap rowMap = data.get(row);
    if (rowMap == null)
        return false;
    return rowMap.get(col) != 0;
}