gnu.trove.list.array.TIntArrayList Java Examples
The following examples show how to use
gnu.trove.list.array.TIntArrayList.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractTapChanger.java From powsybl-core with Mozilla Public License 2.0 | 6 votes |
protected AbstractTapChanger(Ref<? extends VariantManagerHolder> network, H parent, int lowTapPosition, List<S> steps, TerminalExt regulationTerminal, int tapPosition, boolean regulating, double targetDeadband, String type) { this.network = network; this.parent = parent; this.lowTapPosition = lowTapPosition; this.steps = steps; steps.forEach(s -> s.setParent(this)); this.regulationTerminal = regulationTerminal; int variantArraySize = network.get().getVariantManager().getVariantArraySize(); this.tapPosition = new TIntArrayList(variantArraySize); this.regulating = new TBooleanArrayList(variantArraySize); this.targetDeadband = new TDoubleArrayList(variantArraySize); for (int i = 0; i < variantArraySize; i++) { this.tapPosition.add(tapPosition); this.regulating.add(regulating); this.targetDeadband.add(targetDeadband); } this.type = Objects.requireNonNull(type); }
Example #2
Source File: ConfiguredBusImpl.java From powsybl-core with Mozilla Public License 2.0 | 6 votes |
ConfiguredBusImpl(String id, String name, boolean fictitious, VoltageLevelExt voltageLevel) { super(id, name, fictitious, voltageLevel); network = voltageLevel.getNetwork().getRef(); int variantArraySize = network.get().getVariantManager().getVariantArraySize(); terminals = new ArrayList<>(variantArraySize); v = new TDoubleArrayList(variantArraySize); angle = new TDoubleArrayList(variantArraySize); connectedComponentNumber = new TIntArrayList(variantArraySize); synchronousComponentNumber = new TIntArrayList(variantArraySize); for (int i = 0; i < variantArraySize; i++) { terminals.add(new ArrayList<>()); v.add(Double.NaN); angle.add(Double.NaN); connectedComponentNumber.add(-1); synchronousComponentNumber.add(-1); } }
Example #3
Source File: ModularSequence.java From clearvolume with GNU Lesser General Public License v3.0 | 6 votes |
public static TIntArrayList computeGapList(int n, int k, int m) { final boolean[] lBinaryMap = generateBinaryMap(n, k, m); final TIntArrayList lGapList = new TIntArrayList(); int last = 0; for (int i = 1; i < n; i++) { if (lBinaryMap[i]) { lGapList.add(i - last); last = i; } } lGapList.add(n - last); return lGapList; }
Example #4
Source File: SortedNeighborhoodBlocking.java From JedAIToolkit with Apache License 2.0 | 6 votes |
protected int[] getMixedSortedEntities(String[] sortedTerms) { int datasetLimit = entityProfilesD1.size(); final TIntList sortedEntityIds = new TIntArrayList(); for (String blockingKey : sortedTerms) { final TIntList sortedIds = new TIntArrayList(); final TIntList d1EntityIds = invertedIndexD1.get(blockingKey); if (d1EntityIds != null) { sortedIds.addAll(d1EntityIds); } final TIntList d2EntityIds = invertedIndexD2.get(blockingKey); if (d2EntityIds != null) { for (TIntIterator iterator = d2EntityIds.iterator(); iterator.hasNext();) { sortedIds.add(datasetLimit + iterator.next()); } } sortedIds.shuffle(random); sortedEntityIds.addAll(sortedIds); } return sortedEntityIds.toArray(); }
Example #5
Source File: BlockFiltering.java From JedAIToolkit with Apache License 2.0 | 6 votes |
protected List<AbstractBlock> restructureUnilateraBlocks(List<AbstractBlock> blocks) { final List<AbstractBlock> newBlocks = new ArrayList<>(); blocks.stream().map((block) -> (UnilateralBlock) block).forEachOrdered((oldBlock) -> { final TIntList retainedEntities = new TIntArrayList(); for (int entityId : oldBlock.getEntities()) { if (counterD1[entityId] < limitsD1[entityId]) { retainedEntities.add(entityId); } } if (1 < retainedEntities.size()) { for (TIntIterator iterator = retainedEntities.iterator(); iterator.hasNext();) { counterD1[iterator.next()]++; } newBlocks.add(new UnilateralBlock(oldBlock.getEntropy(), retainedEntities.toArray())); } }); return newBlocks; }
Example #6
Source File: SDRClassifierTest.java From htm.java with GNU Affero General Public License v3.0 | 6 votes |
@Test /** * Test missing record edge TestCase * Test an edge case in the classifier initialization when there is a * missing record in the first n records, where n is the # of prediction steps. */ public void testMissingRecordInitialization() { classifier = new SDRClassifier(new TIntArrayList(new int[] { 2 }), 0.1, 0.1, 0); int recordNum = 0; Map<String, Object> classification = new HashMap<String, Object>(); classification.put("bucketIdx", 0); classification.put("actValue", 34.7); classifier.compute(recordNum, classification, new int[] { 1, 5, 9 }, true, true); recordNum = 2; classification.put("bucketIdx", 0); classification.put("actValue", 34.7); Classification<Double> result = classifier.compute(recordNum, classification, new int[] { 1, 5, 9 }, true, true); assertTrue(Arrays.equals(new int[] { 2 }, result.stepSet())); assertEquals(1, result.getStepCount()); assertEquals(34.7, result.getActualValue(0), 0.01); }
Example #7
Source File: QuestEngine.java From aion-germany with GNU General Public License v3.0 | 6 votes |
public boolean onEnterZone(QuestEnv env, ZoneName zoneName) { try { TIntArrayList lists = getOnEnterZoneQuests(zoneName); for (int index = 0; index < lists.size(); index++) { QuestHandler questHandler = getQuestHandlerByQuestId(lists.get(index)); if (questHandler != null) { env.setQuestId(lists.get(index)); questHandler.onEnterZoneEvent(env, zoneName); } } } catch (Exception ex) { log.error("[QuestEngine] exception in onEnterZone - QuestId: " + env.getQuestId() + " Error: ", ex); return false; } return true; }
Example #8
Source File: SDRClassifierTest.java From htm.java with GNU Affero General Public License v3.0 | 6 votes |
@Test public void testComputeCategory2() { classifier = new SDRClassifier(new TIntArrayList(new int[] { 1 }), 0.1, 0.1, 0); int recordNum = 0; Map<String, Object> classification = new HashMap<String, Object>(); classification.put("bucketIdx", 4); classification.put("actValue", "D"); classifier.compute(recordNum, classification, new int[] { 1, 5, 9 }, true, true); recordNum += 1; classification.put("bucketIdx", 4); classification.put("actValue", "E"); Classification<String> result = classifier.compute(recordNum, classification, new int[] { 1, 5, 9 }, true, true); assertTrue(Arrays.equals(new int[] { 1 }, result.stepSet())); assertEquals("D", result.getActualValue(4)); }
Example #9
Source File: QuestEngine.java From aion-germany with GNU General Public License v3.0 | 6 votes |
public HandlerResult onItemUseEvent(QuestEnv env, Item item) { try { TIntArrayList lists = getItemRelatedQuests(item.getItemTemplate().getTemplateId()); for (int index = 0; index < lists.size(); index++) { QuestHandler questHandler = getQuestHandlerByQuestId(lists.get(index)); if (questHandler != null) { env.setQuestId(lists.get(index)); HandlerResult result = questHandler.onItemUseEvent(env, item); // allow other quests to process, the same item can be used not in one quest if (result != HandlerResult.UNKNOWN) { return result; } } } return HandlerResult.UNKNOWN; } catch (Exception ex) { log.error("[QuestEngine] exception in onItemUseEvent - QuestId: " + env.getQuestId() + " Error: ", ex); return HandlerResult.FAILED; } }
Example #10
Source File: SDRClassifierTest.java From htm.java with GNU Affero General Public License v3.0 | 6 votes |
@Test public void testComputeCategory() { classifier = new SDRClassifier(new TIntArrayList(new int[] { 1 }), 0.1, 0.1, 0); int recordNum = 0; Map<String, Object> classification = new HashMap<String, Object>(); classification.put("bucketIdx", 4); classification.put("actValue", "D"); classifier.compute(recordNum, classification, new int[] { 1, 5, 9 }, true, true); recordNum += 1; classification.put("bucketIdx", 4); classification.put("actValue", "D"); Classification<String> result = classifier.compute(recordNum, classification, new int[] { 1, 5, 9 }, true, true); assertTrue(Arrays.equals(new int[] { 1 }, result.stepSet())); assertEquals("D", result.getActualValue(4)); recordNum += 1; classification.put("bucketIdx", 5); classification.put("actValue", null); Classification<String> predictResult = classifier.compute(recordNum, classification, new int[] { 1, 5, 9 }, true, true); for(int i = 0; i < predictResult.getActualValueCount(); i++) { assertTrue(predictResult.getActualValue(i) == null || predictResult.getActualValue(i).getClass().equals(String.class)); } }
Example #11
Source File: DefaultReconfigurationProblem.java From scheduler with GNU Lesser General Public License v3.0 | 6 votes |
private void addContinuousResourceCapacities() { TIntArrayList cUse = new TIntArrayList(); List<IntVar> iUse = new ArrayList<>(); for (int j = 0; j < getVMs().size(); j++) { VMTransition a = vmActions.get(j); if (a.getDSlice() != null) { iUse.add(csp.intVar(1)); } if (a.getCSlice() != null) { cUse.add(1); } } ChocoView v = getView(Cumulatives.VIEW_ID); if (v == null) { throw SchedulerModelingException.missingView(model, Cumulatives.VIEW_ID); } ((Cumulatives) v).addDim(getNbRunningVMs(), cUse.toArray(), iUse.toArray(new IntVar[iUse.size()])); }
Example #12
Source File: Convert.java From paintera with GNU General Public License v2.0 | 6 votes |
/** * @param vertices vertices * @param triangleVertexLUT triangleVertexLUT * * @return vertices */ public static float[] convertFromLUT( final TFloatArrayList vertices, final ArrayList<TIntArrayList> triangleVertexLUT) { final float[] export = new float[triangleVertexLUT.size() * 9]; int t = -1; for (final TIntArrayList triangleVertices : triangleVertexLUT) { final TIntArrayList vertexIndices = triangleVertices; for (int i = 0; i < vertexIndices.size(); ++i) { int vertexIndex = vertexIndices.get(i) * 3; export[++t] = vertices.get(vertexIndex); export[++t] = vertices.get(++vertexIndex); export[++t] = vertices.get(++vertexIndex); } } return export; }
Example #13
Source File: Similarity.java From fnlp with GNU Lesser General Public License v3.0 | 6 votes |
public void similarity() throws InterruptedException { System.out.println("相似度"); ThreadPoolExecutor pool = new ThreadPoolExecutor(numThreads, numThreads, 1000, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(capacity )); similarityMap = new TIntIntHashMap[docs.size()]; Iterator<Entry<String, TIntArrayList>> iterator = locationMap.entrySet().iterator(); while(iterator.hasNext()) { if(pool.getQueue().remainingCapacity()==0){ Thread.sleep(10); continue; } Entry<String, TIntArrayList> entry = iterator.next(); TIntArrayList al = entry.getValue(); CalcSimilarity cs = new CalcSimilarity(al); pool.execute(cs); } while(pool.getActiveCount()>0){ Thread.sleep(10); } pool.shutdown(); }
Example #14
Source File: PhysicsObject.java From Valkyrien-Skies with Apache License 2.0 | 6 votes |
public PhysicsObject(PhysicsWrapperEntity host) { this.wrapperEntity = host; if (host.world.isRemote) { this.shipRenderer = new PhysObjectRenderManager(this); } // We need safe access to this across multiple threads. this.blockPositions = ConcurrentHashMap.newKeySet(); this.shipBoundingBox = Entity.ZERO_AABB; this.watchingPlayers = new ArrayList<>(); this.shipSubspace = new ImplSubspace(this); this.physicsControllers = Sets.newConcurrentHashSet(); this.physicsControllersImmutable = Collections.unmodifiableSet(this.physicsControllers); this.blockPositionsGameTick = new TIntArrayList(); this.cachedSurroundingChunks = new SurroundingChunkCacheController(this); this.voxelFieldAABBMaker = null; }
Example #15
Source File: AbstractSparseBinaryMatrixTest.java From htm.java with GNU Affero General Public License v3.0 | 6 votes |
@Test public void testAny() { AbstractSparseBinaryMatrix matrix = getTestMatrix(); AbstractSparseBinaryMatrix matrix2 = getTestMatrix(); assertFalse(matrix.any(matrix2)); boolean isTest = true; matrix2.set(new int[] { 0, 1 }, new int[] { 1, 1 }, isTest); assertFalse(matrix.any(matrix2)); // Now with trove matrix = getTestMatrix(); matrix2 = getTestMatrix(); assertFalse(matrix.any(matrix2)); matrix2.set(new int[] { 0, 1 }, new int[] { 1, 1 }, isTest); TIntArrayList tl = new TIntArrayList(); tl.add(1); assertFalse(matrix.any(tl)); assertTrue(matrix2.any(tl)); int[] onBits = { 0 }; assertFalse(matrix.any(onBits)); assertTrue(matrix2.any(onBits)); }
Example #16
Source File: ShuntCompensatorImpl.java From powsybl-core with Mozilla Public License 2.0 | 6 votes |
ShuntCompensatorImpl(Ref<? extends VariantManagerHolder> network, String id, String name, boolean fictitious, ShuntCompensatorModelWrapper model, int sectionCount, TerminalExt regulatingTerminal, boolean voltageRegulatorOn, double targetV, double targetDeadband) { super(id, name, fictitious); this.network = network; this.model = attach(model); this.regulatingTerminal = regulatingTerminal; int variantArraySize = network.get().getVariantManager().getVariantArraySize(); this.sectionCount = new TIntArrayList(variantArraySize); this.voltageRegulatorOn = new TBooleanArrayList(variantArraySize); this.targetV = new TDoubleArrayList(variantArraySize); this.targetDeadband = new TDoubleArrayList(variantArraySize); for (int i = 0; i < variantArraySize; i++) { this.sectionCount.add(sectionCount); this.voltageRegulatorOn.add(voltageRegulatorOn); this.targetV.add(targetV); this.targetDeadband.add(targetDeadband); } }
Example #17
Source File: StaticVarCompensatorImpl.java From powsybl-core with Mozilla Public License 2.0 | 6 votes |
StaticVarCompensatorImpl(String id, String name, boolean fictitious, double bMin, double bMax, double voltageSetPoint, double reactivePowerSetPoint, RegulationMode regulationMode, TerminalExt regulatingTerminal, Ref<? extends VariantManagerHolder> ref) { super(id, name, fictitious); this.bMin = bMin; this.bMax = bMax; int variantArraySize = ref.get().getVariantManager().getVariantArraySize(); this.voltageSetPoint = new TDoubleArrayList(variantArraySize); this.reactivePowerSetPoint = new TDoubleArrayList(variantArraySize); this.regulationMode = new TIntArrayList(variantArraySize); this.regulatingTerminal = regulatingTerminal; for (int i = 0; i < variantArraySize; i++) { this.voltageSetPoint.add(voltageSetPoint); this.reactivePowerSetPoint.add(reactivePowerSetPoint); this.regulationMode.add(regulationMode.ordinal()); } }
Example #18
Source File: AbstractSparseBinaryMatrixTest.java From htm.java with GNU Affero General Public License v3.0 | 6 votes |
@Test public void testOr() { AbstractSparseBinaryMatrix matrix2 = getTestMatrix(); boolean isTest = true; matrix2.set(new int[] { 1 }, new int[] { 1 }, isTest); AbstractSparseBinaryMatrix matrix = getTestMatrix(); assertEquals(0, matrix.getTrueCount(1)); assertEquals(0, matrix.getSparseIndices().length); matrix.or(matrix2); assertEquals(1, matrix.getTrueCount(1)); assertEquals(7, matrix.getSparseIndices().length); // Now for trove collection matrix = getTestMatrix(); assertEquals(0, matrix.getTrueCount(1)); assertEquals(0, matrix.getSparseIndices().length); TIntArrayList tl = new TIntArrayList(); tl.add(1); matrix.or(tl); assertEquals(1, matrix.getTrueCount(1)); assertEquals(7, matrix.getSparseIndices().length); }
Example #19
Source File: Graph.java From ambiverse-nlu with Apache License 2.0 | 6 votes |
public Graph(String name, int nodesCount, double alpha) { this.name = name; this.nodesCount = nodesCount; this.alpha = alpha; nodes = new GraphNode[nodesCount]; mentionNodesIds = new TObjectIntHashMap<Mention>(); entityNodesIds = new TIntIntHashMap(); localSimilarities = new HashMap<Mention, TIntDoubleHashMap>(); mentionPriorSimL1 = new TIntDoubleHashMap(50, 0.5f, -1, -1.0); isRemoved = new boolean[nodesCount]; Arrays.fill(isRemoved, false); nodesOutdegrees = new int[nodesCount]; Arrays.fill(nodesOutdegrees, 0); nodesWeightedDegrees = new double[nodesCount]; Arrays.fill(nodesWeightedDegrees, 0); removalSteps = new TIntArrayList(); }
Example #20
Source File: GraphConfidenceEstimator.java From ambiverse-nlu with Apache License 2.0 | 6 votes |
/** * Will return numElements integers from the input elements. If numElements * is larger than elements.size(), everything will be returned. * * @param elements Elements to choose from. * @param numElements Number of elements to choose. * @return numElement random integers from elements. */ private TIntSet getRandomElements(TIntSet elements, int numElements) { TIntList source = new TIntArrayList(elements.toArray()); TIntSet randomElements = new TIntHashSet(); for (int i = 0; i < numElements; ++i) { if (source.size() == 0) { break; } // TODO: this is not efficient, as deleting from the ArrayList // will copy ... make this more efficient when necessary. int elementPosition = random_.nextInt(source.size()); int element = source.get(elementPosition); source.remove(element); randomElements.add(element); } return randomElements; }
Example #21
Source File: SpatialPooler.java From htm.java with GNU Affero General Public License v3.0 | 6 votes |
/** * Removes the set of columns who have never been active from the set of * active columns selected in the inhibition round. Such columns cannot * represent learned pattern and are therefore meaningless if only inference * is required. This should not be done when using a random, unlearned SP * since you would end up with no active columns. * * @param activeColumns An array containing the indices of the active columns * @return a list of columns with a chance of activation */ public int[] stripUnlearnedColumns(Connections c, int[] activeColumns) { TIntHashSet active = new TIntHashSet(activeColumns); TIntHashSet aboveZero = new TIntHashSet(); int numCols = c.getNumColumns(); double[] colDutyCycles = c.getActiveDutyCycles(); for(int i = 0;i < numCols;i++) { if(colDutyCycles[i] <= 0) { aboveZero.add(i); } } active.removeAll(aboveZero); TIntArrayList l = new TIntArrayList(active); l.sort(); return Arrays.stream(activeColumns).filter(i -> c.getActiveDutyCycles()[i] > 0).toArray(); }
Example #22
Source File: StrictHackathonAlgorithm.java From htm.java-examples with GNU Affero General Public License v3.0 | 5 votes |
/** * Returns the randomly culled array whose entries are equal * to {@link #SPARSITY} * * @param input the int array to ensure proper sparsity for. * @return */ int[] subsample(int[] input) { double sparsity = getSparsity(input); if(sparsity > 0.02) { input = sample((int)(SDR_WIDTH * SPARSITY) + 1, new TIntArrayList(input), rng); } return input; }
Example #23
Source File: GroundTruthIndex.java From JedAIToolkit with Apache License 2.0 | 5 votes |
public TIntList getCommonBlockIndices(int blockIndex, Comparison comparison) { final int[] blocks1 = entityBlocks[comparison.getEntityId1()]; final int[] blocks2 = entityBlocks[comparison.getEntityId2() + datasetLimit]; boolean firstCommonIndex = false; int noOfBlocks1 = blocks1.length; int noOfBlocks2 = blocks2.length; final TIntList indices = new TIntArrayList(); for (int item : blocks1) { for (int value : blocks2) { if (value < item) { continue; } if (item < value) { break; } if (item == value) { if (!firstCommonIndex) { firstCommonIndex = true; if (item != blockIndex) { return null; } } indices.add(item); } } } return indices; }
Example #24
Source File: MultiVariantExtensionTest.java From powsybl-core with Mozilla Public License 2.0 | 5 votes |
LoadExt(Load load, int value) { super(load); int variantArraySize = getVariantManagerHolder().getVariantManager().getVariantArraySize(); this.values = new TIntArrayList(variantArraySize); for (int i = 0; i < variantArraySize; i++) { this.values.add(value); } }
Example #25
Source File: ByteBufUtils.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
public static TIntList readIntList(PacketBuffer buf) { TIntArrayList intArrayList = new TIntArrayList(); int amount = buf.readVarInt(); for (int i = 0; i < amount; i++) { intArrayList.add(buf.readVarInt()); } return intArrayList; }
Example #26
Source File: QuestEngine.java From aion-germany with GNU General Public License v3.0 | 5 votes |
public void registerOnBonusApply(int questId, BonusType bonusType) { if (!questOnBonusApply.containsKey(bonusType)) { TIntArrayList onBonusApplyQuests = new TIntArrayList(); onBonusApplyQuests.add(questId); questOnBonusApply.put(bonusType, onBonusApplyQuests); } else { questOnBonusApply.get(bonusType).add(questId); } }
Example #27
Source File: Util.java From PE-HFT-Java with GNU General Public License v3.0 | 5 votes |
public static TIntArrayList getHours(TLongArrayList t){ TIntArrayList hour= new TIntArrayList(t.size()); for(int i=0; i<t.size();i++) hour.add( (int) (t.getQuick(i)/3600000L) ); return hour; }
Example #28
Source File: SDRClassifierTest.java From htm.java with GNU Affero General Public License v3.0 | 5 votes |
/** * Send same value 10 times and expect 100% likelihood for prediction. */ @Test public void testSingleValue() { classifier = new SDRClassifier(new TIntArrayList(new int[] { 1 }), 1.0, 0.3, 0); // Enough times to perform Inference and expect high likelihood for prediction. Classification<Double> retVal = null; for(int recordNum = 0; recordNum < 10; recordNum++) { retVal = compute(classifier, recordNum, new int[] {1, 5}, 0, 10); } assertEquals(10.0, retVal.getActualValue(0), 0.0); assertEquals(1.0, retVal.getStat(1, 0), 0.1); }
Example #29
Source File: SFMDemo.java From COMP3204 with BSD 3-Clause "New" or "Revised" License | 5 votes |
FeatureTable filterNonTracked(FeatureTable ft) { final int nFrames = ft.features.size(); final TIntArrayList tracksToRemove = new TIntArrayList(); for (int i = 0; i < ft.nFeatures; i++) { int sum = 0; for (int f = 1; f < nFrames; f++) { sum += ft.features.get(f).get(i).val; } if (sum != 0) { tracksToRemove.add(i); } } final FeatureTable filtered = new FeatureTable(ft.nFeatures - tracksToRemove.size()); for (int f = 0; f < nFrames; f++) { final FeatureList fl = new FeatureList(filtered.nFeatures); for (int i = 0, j = 0; i < ft.nFeatures; i++) { if (!tracksToRemove.contains(i)) fl.features[j++] = ft.features.get(f).get(i); } filtered.storeFeatureList(fl, f); } return filtered; }
Example #30
Source File: UndirectedGraphImpl.java From powsybl-core with Mozilla Public License 2.0 | 5 votes |
/** * {@inheritDoc}. * * This method allocates a {@link List} of {@link TIntArrayList} to store the paths, a {@link BitSet} to store the encountered vertices * and calls {@link #findAllPaths(int, Function, Function, TIntArrayList, BitSet, List)}. */ @Override public List<TIntArrayList> findAllPaths(int from, Function<V, Boolean> pathComplete, Function<E, Boolean> pathCancelled) { Objects.requireNonNull(pathComplete); List<TIntArrayList> paths = new ArrayList<>(); BitSet encountered = new BitSet(vertices.size()); TIntArrayList path = new TIntArrayList(1); findAllPaths(from, pathComplete, pathCancelled, path, encountered, paths); // sort paths by size paths.sort((o1, o2) -> o1.size() - o2.size()); return paths; }