it.unimi.dsi.fastutil.ints.Int2IntSortedMap Java Examples

The following examples show how to use it.unimi.dsi.fastutil.ints.Int2IntSortedMap. 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: DenseModule.java    From jstarcraft-ai with Apache License 2.0 6 votes vote down vote up
@Override
public void associateInstance(Int2IntSortedMap qualityFeatures, Int2FloatSortedMap quantityFeatures, int qualityMark, float quantityMark, float weight) {
    if (capacity == size) {
        throw new DataCapacityException();
    }
    if (!qualityFeatures.isEmpty() && (qualityFeatures.firstIntKey() < 0 || qualityFeatures.lastIntKey() >= qualityOrder)) {
        throw new DataException();
    }
    if (!quantityFeatures.isEmpty() && (quantityFeatures.firstIntKey() < 0 || quantityFeatures.lastIntKey() >= quantityOrder)) {
        throw new DataException();
    }
    assert qualityOrder == qualityFeatures.size();
    assert quantityOrder == quantityFeatures.size();
    for (Int2IntMap.Entry term : qualityFeatures.int2IntEntrySet()) {
        qualityValues[term.getIntKey()].associateData(term.getIntValue());
    }
    for (Int2FloatMap.Entry term : quantityFeatures.int2FloatEntrySet()) {
        quantityValues[term.getIntKey()].associateData(term.getFloatValue());
    }
    qualityMarks.associateData(qualityMark);
    quantityMarks.associateData(quantityMark);
    weights.associateData(weight);
    size++;
}
 
Example #2
Source File: ReferenceModuleTestCase.java    From jstarcraft-ai with Apache License 2.0 6 votes vote down vote up
private DataModule getDataModule() {
    List<KeyValue<KeyValue<String, Boolean>, Integer>> moduleDefinition = new LinkedList<>();
    for (int index = 0; index < order; index++) {
        moduleDefinition.add(new KeyValue<>(new KeyValue<>("quality", true), 1));
        moduleDefinition.add(new KeyValue<>(new KeyValue<>("ontinuous", false), 1));
    }
    DataModule module = new SparseModule(moduleName, moduleDefinition, instanceCapacity);
    Int2IntSortedMap qualityFeatures = new Int2IntAVLTreeMap();
    Int2FloatSortedMap quantityFeatures = new Int2FloatAVLTreeMap();
    for (int index = 0; index < instanceCapacity; index++) {
        qualityFeatures.clear();
        qualityFeatures.put(index, index);
        module.associateInstance(qualityFeatures, quantityFeatures);
    }
    return module;
}
 
Example #3
Source File: DataSorterTestCase.java    From jstarcraft-ai with Apache License 2.0 6 votes vote down vote up
private DataModule getDataModule() {
    List<KeyValue<KeyValue<String, Boolean>, Integer>> moduleDefinition = new LinkedList<>();
    for (int index = 0; index < order; index++) {
        moduleDefinition.add(new KeyValue<>(new KeyValue<>("quality", true), 1));
        moduleDefinition.add(new KeyValue<>(new KeyValue<>("ontinuous", false), 1));
    }
    DataModule module = new SparseModule(moduleName, moduleDefinition, instanceCapacity);
    Int2IntSortedMap qualityFeatures = new Int2IntAVLTreeMap();
    Int2FloatSortedMap quantityFeatures = new Int2FloatAVLTreeMap();
    for (int index = 0; index < instanceCapacity; index++) {
        qualityFeatures.clear();
        qualityFeatures.put(0, index);
        module.associateInstance(qualityFeatures, quantityFeatures);
    }
    return module;
}
 
Example #4
Source File: DataSplitterTestCase.java    From jstarcraft-ai with Apache License 2.0 6 votes vote down vote up
private DataModule getDataModule() {
    List<KeyValue<KeyValue<String, Boolean>, Integer>> moduleDefinition = new LinkedList<>();
    for (int index = 0; index < order; index++) {
        moduleDefinition.add(new KeyValue<>(new KeyValue<>("quality", true), 1));
        moduleDefinition.add(new KeyValue<>(new KeyValue<>("ontinuous", false), 1));
    }
    DataModule module = new SparseModule(moduleName, moduleDefinition, instanceCapacity);
    Int2IntSortedMap qualityFeatures = new Int2IntAVLTreeMap();
    Int2FloatSortedMap quantityFeatures = new Int2FloatAVLTreeMap();
    for (int index = 0; index < instanceCapacity; index++) {
        qualityFeatures.clear();
        qualityFeatures.put(0, index);
        module.associateInstance(qualityFeatures, quantityFeatures);
    }
    return module;
}
 
Example #5
Source File: DataSelectorTestCase.java    From jstarcraft-ai with Apache License 2.0 6 votes vote down vote up
private DataModule getDataModule() {
    List<KeyValue<KeyValue<String, Boolean>, Integer>> moduleDefinition = new LinkedList<>();
    for (int index = 0; index < order; index++) {
        moduleDefinition.add(new KeyValue<>(new KeyValue<>("quality", true), 1));
        moduleDefinition.add(new KeyValue<>(new KeyValue<>("ontinuous", false), 1));
    }
    DataModule module = new SparseModule(moduleName, moduleDefinition, instanceCapacity);
    Int2IntSortedMap qualityFeatures = new Int2IntAVLTreeMap();
    Int2FloatSortedMap quantityFeatures = new Int2FloatAVLTreeMap();
    for (int index = 0; index < instanceCapacity; index++) {
        qualityFeatures.clear();
        qualityFeatures.put(0, index);
        module.associateInstance(qualityFeatures, quantityFeatures);
    }
    return module;
}
 
Example #6
Source File: MovieService.java    From jstarcraft-example with Apache License 2.0 5 votes vote down vote up
@LockableMethod(strategy = HashLockableStrategy.class)
public void click(@LockableParameter int userIndex, int itemIndex, float score) {
    Int2IntSortedMap qualityFeatures = new Int2IntRBTreeMap();
    qualityFeatures.put(userDimension, userIndex);
    qualityFeatures.put(itemDimension, itemIndex);
    Int2FloatSortedMap quantityFeatures = new Int2FloatRBTreeMap();
    quantityFeatures.put(scoreDimension, score);
    dataModule.associateInstance(qualityFeatures, quantityFeatures, 5F);
}
 
Example #7
Source File: ReferenceModuleTestCase.java    From jstarcraft-ai with Apache License 2.0 5 votes vote down vote up
@Test
public void testAssociateInstance() {
    DataModule module = getDataModule();
    IntegerArray references = new IntegerArray(instanceCapacity, instanceCapacity);
    module = new ReferenceModule(references, module);
    Assert.assertEquals(0, module.getSize());

    try {
        Int2IntSortedMap qualityFeatures = new Int2IntAVLTreeMap();
        Int2FloatSortedMap quantityFeatures = new Int2FloatAVLTreeMap();
        module.associateInstance(qualityFeatures, quantityFeatures);
        Assert.fail();
    } catch (UnsupportedOperationException exception) {
    }
}
 
Example #8
Source File: ReferenceModule.java    From jstarcraft-ai with Apache License 2.0 4 votes vote down vote up
@Override
public void associateInstance(Int2IntSortedMap qualityFeatures, Int2FloatSortedMap quantityFeatures, int qualityMark, float quantityMark, float weight) {
    throw new UnsupportedOperationException();
}
 
Example #9
Source File: DataModule.java    From jstarcraft-ai with Apache License 2.0 2 votes vote down vote up
/**
 * 关联实例
 * 
 * @param qualityFeatures
 * @param quantityFeatures
 * @param qualityMark
 * @param quantityMark
 * @param weight
 */
void associateInstance(Int2IntSortedMap qualityFeatures, Int2FloatSortedMap quantityFeatures, int qualityMark, float quantityMark, float weight);
 
Example #10
Source File: DataModule.java    From jstarcraft-ai with Apache License 2.0 2 votes vote down vote up
/**
 * 关联实例
 * 
 * @param qualityFeatures
 * @param quantityFeatures
 * @param qualityMark
 * @param weight
 */
default void associateInstance(Int2IntSortedMap qualityFeatures, Int2FloatSortedMap quantityFeatures, int qualityMark, float weight) {
    associateInstance(qualityFeatures, quantityFeatures, qualityMark, DataInstance.defaultFloat, weight);
}
 
Example #11
Source File: DataModule.java    From jstarcraft-ai with Apache License 2.0 2 votes vote down vote up
/**
 * 关联实例
 * 
 * @param qualityFeatures
 * @param quantityFeatures
 * @param quantityMark
 * @param weight
 */
default void associateInstance(Int2IntSortedMap qualityFeatures, Int2FloatSortedMap quantityFeatures, float quantityMark, float weight) {
    associateInstance(qualityFeatures, quantityFeatures, DataInstance.defaultInteger, quantityMark, weight);
}
 
Example #12
Source File: DataModule.java    From jstarcraft-ai with Apache License 2.0 2 votes vote down vote up
/**
 * 关联实例
 * 
 * @param qualityFeatures
 * @param quantityFeatures
 * @param qualityMark
 */
default void associateInstance(Int2IntSortedMap qualityFeatures, Int2FloatSortedMap quantityFeatures, int qualityMark) {
    associateInstance(qualityFeatures, quantityFeatures, qualityMark, DataInstance.defaultFloat, DataInstance.defaultWeight);
}
 
Example #13
Source File: DataModule.java    From jstarcraft-ai with Apache License 2.0 2 votes vote down vote up
/**
 * 关联实例
 * 
 * @param qualityFeatures
 * @param quantityFeatures
 * @param quantityMark
 */
default void associateInstance(Int2IntSortedMap qualityFeatures, Int2FloatSortedMap quantityFeatures, float quantityMark) {
    associateInstance(qualityFeatures, quantityFeatures, DataInstance.defaultInteger, quantityMark, DataInstance.defaultWeight);
}
 
Example #14
Source File: DataModule.java    From jstarcraft-ai with Apache License 2.0 2 votes vote down vote up
/**
 * 关联实例
 * 
 * @param qualityFeatures
 * @param quantityFeatures
 */
default void associateInstance(Int2IntSortedMap qualityFeatures, Int2FloatSortedMap quantityFeatures) {
    associateInstance(qualityFeatures, quantityFeatures, DataInstance.defaultInteger, DataInstance.defaultFloat, DataInstance.defaultWeight);
}
 
Example #15
Source File: LunarDate.java    From jstarcraft-core with Apache License 2.0 2 votes vote down vote up
/**
 * 获取指定范围的闰年
 * 
 * @param from
 * @param to
 * @return
 */
public static Int2IntSortedMap getLeapYears(int from, int to) {
    return leaps.subMap(from, to);
}