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


Java Factory.createSimpleCombinationGenerator方法代码示例

本文整理汇总了Java中org.paukov.combinatorics.Factory.createSimpleCombinationGenerator方法的典型用法代码示例。如果您正苦于以下问题:Java Factory.createSimpleCombinationGenerator方法的具体用法?Java Factory.createSimpleCombinationGenerator怎么用?Java Factory.createSimpleCombinationGenerator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.paukov.combinatorics.Factory的用法示例。


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

示例1: simple_combinations

import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
static void simple_combinations() {

        System.out.println("===== Simple Combinations: =====");

        // Create the initial vector
        ICombinatoricsVector<String> initialVector = Factory
                .createVector(new String[]{"red", "black", "white", "green",
                        "blue"});

        // Create a simple combination generator to generate 3-combinations of
        // the initial vector
        Generator<String> gen = Factory.createSimpleCombinationGenerator(
                initialVector, 3);

        // Print all possible combinations
        for (ICombinatoricsVector<String> combination : gen) {
            System.out.println(combination);
        }

    }
 
开发者ID:dpaukov,项目名称:combinatoricslib,代码行数:21,代码来源:Main.java

示例2: all_permutations_of_all_combination

import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
/**
 * This example recreates the issue 14.
 * https://code.google.com/p/combinatoricslib/issues/detail?id=14
 *
 * It generates all permutations of a given length where repetition is NOT allowed,
 * from a larger set of elements.
 */
static void all_permutations_of_all_combination() {

    System.out.println("===== All permutations of all combination: =====");

    // Create the initial vector of 4 elements (apple, orange, cherry, raspberry)
    ICombinatoricsVector<String> originalVector = Factory.createVector(
            new String[] { "apple", "orange", "cherry", "raspberry" }
    );

    // Create the combination generator by calling the appropriate method in the Factory class
    Generator<String> combinations = Factory.createSimpleCombinationGenerator(originalVector, 3);

    // Print all permutations for all simple 3-combinations
    for (ICombinatoricsVector<String> comb : combinations){
        Generator<String> permutations = Factory.createPermutationGenerator(comb);
        for(ICombinatoricsVector<String> perm : permutations){
            System.out.println(perm);
        }
    }
}
 
开发者ID:dpaukov,项目名称:combinatoricslib,代码行数:28,代码来源:Main.java

示例3: createInitialPairings

import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
/**
 * Creates the initial set of pairings between Player objects. These Player objects
 * are not the PlayerA and PlayerB child class objects created later. The number of
 * players is calculated by calculating the number of non-repeating combinations.
 * 
 * @param playersSet
 *            the players set
 * @return the hash map
 */
private HashMap<Long, List<Player>> createInitialPairings(final Set<Player> playersSet) {
	playerPairings = new HashMap<Long, List<Player>>();

	final Object[] playerArray = playersSet.toArray();
	// Create the initial vector
	final ICombinatoricsVector<Object> initialVector = Factory
			.createVector(playerArray);

	// Create a simple combination generator to generate 3-combinations of the initial
	// vector
	final Generator<Object> gen = Factory.createSimpleCombinationGenerator(
			initialVector, 2);

	// Print all possible combinations
	long i = 0;
	for (final ICombinatoricsVector<Object> combination : gen) {
		System.out.println(combination);

		Player playeraTemp = null;
		Player playerbTemp = null;

		final List<Object> cominationLst = combination.getVector();
		playeraTemp = (Player) cominationLst.get(0);
		playerbTemp = (Player) cominationLst.get(1);

		assert (playeraTemp != null && playerbTemp != null && playeraTemp != playerbTemp);

		final List<Player> newList = new ArrayList<Player>();
		newList.add(playeraTemp);
		newList.add(playerbTemp);
		playerPairings.put(i, newList);
		i++;
	}

	return playerPairings;
}
 
开发者ID:OpenSimulationSystems,项目名称:CABSF_Java,代码行数:46,代码来源:GameAdministrator.java

示例4: setUpWalkers

import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
private List<RelevanceAutomatonWalker> setUpWalkers() {
	SortedSet<Character> alphabetWithoutWildcard = this.vacuAwaWildAuto.getAlphabetWithoutWildcard();
	int k = alphabetWithoutWildcard.size();

	Set<Character> taskIdentifiersInLog = this.logTranslationMap.keySet();
	
	if (taskIdentifiersInLog.size() < k) {
		throw new IllegalArgumentException("Not enough tasks in the log to instanciate the constraint");
	}

	ICombinatoricsVector<Character> initialVector =
			Factory.createVector(taskIdentifiersInLog.toArray(new Character[k+1]));
	Iterator<ICombinatoricsVector<Character>> combosPermIterator = null;
	Generator<Character>
		comboGen = Factory.createSimpleCombinationGenerator(initialVector, k),
		combosPermGen = null;
	ArrayList<RelevanceAutomatonWalker> walkers = new ArrayList<RelevanceAutomatonWalker>();
	List<Character> vectorOfChars = null;
	int i = 0;
	for (ICombinatoricsVector<Character> simpleCombo : comboGen) {
		combosPermGen = Factory.createPermutationGenerator(simpleCombo);
		combosPermIterator = combosPermGen.iterator();
		while (combosPermIterator.hasNext()) {
			vectorOfChars = combosPermIterator.next().getVector();
			walkers.add(i++, new RelevanceAutomatonWalker(
					vectorOfChars,
					alphabetWithoutWildcard,
					logTranslationMap,
					vacuAwaWildAuto.getInitialWildState()));
		}
	}

	return walkers;
}
 
开发者ID:cdc08x,项目名称:MINERful,代码行数:35,代码来源:RelevanceAutomatonMultiWalker.java

示例5: createAllMultiCharCombosExcludingOneTaskChar

import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
public SortedSet<TaskCharSet> createAllMultiCharCombosExcludingOneTaskChar(TaskChar excluded, int maxSizeOfCombos) {
	Collection<TaskChar> alphabet = taskCharArchive.getTaskChars();
	Collection<TaskChar> otherChrs = new ArrayList<TaskChar>(alphabet);
	if(excluded != null)
		otherChrs.remove(excluded);

	SortedSet<TaskCharSet> combos = new TreeSet<TaskCharSet>();
	
	if (otherChrs.size() < 1) {
		return combos;
	}
	// Create the initial vector
	ICombinatoricsVector<TaskChar> initialVector = Factory.createVector(otherChrs);
	Generator<TaskChar> gen = null;
	Iterator<ICombinatoricsVector<TaskChar>> combosIterator = null;
	
	if (maxSizeOfCombos < otherChrs.size()) {
		for (int k=1; k <= maxSizeOfCombos; k++) {
			// Create a simple combination generator to generate k-combinations of the initial vector
			gen = Factory.createSimpleCombinationGenerator(initialVector, k);
			combosIterator = gen.iterator();
			while (combosIterator.hasNext()) {
				combos.add(new TaskCharSet(combosIterator.next().getVector()));
			}
		}
	} else {
		Collection<TaskChar> auxComboVector = null;
		// Create an instance of the subset generator
		gen = Factory.createSubSetGenerator(initialVector);
		combosIterator = gen.iterator();
		while (combosIterator.hasNext()) {
			auxComboVector = combosIterator.next().getVector();
			if (	auxComboVector.size() > 0
				&&	auxComboVector.size() <= otherChrs.size()) {
				combos.add(new TaskCharSet(auxComboVector));
			}
		}
	}
	return combos;
}
 
开发者ID:cdc08x,项目名称:MINERful,代码行数:41,代码来源:TaskCharSetFactory.java

示例6: main

import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
public static void main(String [] args) throws Exception { 
	ICombinatoricsVector<Integer> originalVector = Factory.createVector(toneClasses);
	Generator<Integer> gen = Factory.createSimpleCombinationGenerator(originalVector, 3);
	for (ICombinatoricsVector<Integer> combination : gen) {
		System.out.println(combination);
	}
}
 
开发者ID:moxious,项目名称:theor,代码行数:8,代码来源:ChordGenerator.java

示例7: getColumnGroups

import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
public List<String[]> getColumnGroups(String[] fieldNames) {
    List<String[]> result = new ArrayList<String[]>();
    ICombinatoricsVector<String> initialVector = Factory.createVector(fieldNames);

    Generator<String> gen = Factory.createSimpleCombinationGenerator(initialVector, this.recordSize);

    for (ICombinatoricsVector<String> combination : gen) {
        String[] vector = new String[this.recordSize];
        vector = combination.getVector().toArray(vector);
        result.add(vector);
    }
    return result;
}
 
开发者ID:mkolisnyk,项目名称:aerial,代码行数:14,代码来源:NWiseDataTestingAlgorithm.java

示例8: combinaisonPairs2

import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
/** @return all simple 2-combinaisons */
public static List<Pair<BrainRegion, BrainRegion>> combinaisonPairs2(
        Collection<BrainRegion> br) {

    List<Pair<BrainRegion, BrainRegion>> pairs = newArrayList();
    // we need at least 2 elems to find pairs
    if (br == null || br.size() < 2)
        return pairs;

    // Create the initial vector
    ICombinatoricsVector<BrainRegion> initialVector = Factory
            .createVector(br);

    // Create a simple combination generator to generate 2-combinations of
    // the initial vector
    Generator<BrainRegion> gen = Factory.createSimpleCombinationGenerator(
            initialVector, 2);

    // get all possible combinations
    for (ICombinatoricsVector<BrainRegion> combination : gen) {
        BrainRegion br1 = combination.getValue(0);
        BrainRegion br2 = combination.getValue(1);

        // filter if same text
        if (br1.getCoveredText().equals(br2.getCoveredText()))
            continue;

        pairs.add(new Pair<BrainRegion, BrainRegion>(br1, br2));
    }

    return pairs;
}
 
开发者ID:BlueBrain,项目名称:bluima,代码行数:33,代码来源:ExtractBrainregionsCoocurrences2.java

示例9: filtered_combinations

import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
/**
 * Print all 3-combinations of the set (apple, orange, cherry, melon) which
 * contains orange
 */
static void filtered_combinations() {

    System.out.println("===== Filtered Combinations: =====");

    // Create the initial set/vector of 3 elements (apple, orange, cherry,
    // melon)
    ICombinatoricsVector<String> originalVector = Factory
            .createVector(new String[]{"apple", "orange", "cherry",
                    "melon"});

    // Create the combination generator by calling the appropriate method in
    // the Factory class
    Generator<String> gen = Factory.createSimpleCombinationGenerator(
            originalVector, 3);

    // Create a filter and generate the results
    List<ICombinatoricsVector<String>> result = gen
            .generateFilteredObjects(new IFilter<ICombinatoricsVector<String>>() {

                // returns true if the value is accepted
                public boolean accepted(long index,
                                        ICombinatoricsVector<String> value) {
                    return value.contains("orange");
                }

            });

    // Print the result
    for (ICombinatoricsVector<String> perm : result)
        System.out.println(perm);

}
 
开发者ID:dpaukov,项目名称:combinatoricslib,代码行数:37,代码来源:Main.java

示例10: simpleEmptyCombinationTest

import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
@Test
public void simpleEmptyCombinationTest() {

	// create array of initial items
	List<String> array = new ArrayList<String>();
	array.add("red");

	// create combinatorics vector
	ICombinatoricsVector<String> initialVector = Factory
			.createVector(array);

	// create simple combination generator to generate 0-combination
	Generator<String> gen = Factory.createSimpleCombinationGenerator(
			initialVector, 0);

	// create iterator
	Iterator<ICombinatoricsVector<String>> itr = gen.iterator();

	// print the number of combinations
	assertEquals(1, gen.getNumberOfGeneratedObjects());

	// go through the iterator
	while (itr.hasNext()) {
		ICombinatoricsVector<String> combination = itr.next();
		System.out.println(combination);
	}

	List<ICombinatoricsVector<String>> list = gen.generateAllObjects();

	assertEquals(1, list.size());

	assertEquals("CombinatoricsVector=([], size=0)", list.get(0).toString());
}
 
开发者ID:dpaukov,项目名称:combinatoricslib,代码行数:34,代码来源:SimpleCombinationTest.java

示例11: simpleOneCombinationTest

import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
@Test
public void simpleOneCombinationTest() {

	// create array of initial items
	List<String> array = new ArrayList<String>();
	array.add("red");

	// create combinatorics vector
	ICombinatoricsVector<String> initialVector = Factory
			.createVector(array);

	// create simple combination generator to generate 1-combination
	Generator<String> gen = Factory.createSimpleCombinationGenerator(
			initialVector, 1);

	// create iterator
	Iterator<ICombinatoricsVector<String>> itr = gen.iterator();

	// print the number of combinations
	assertEquals(1, gen.getNumberOfGeneratedObjects());

	// go through the iterator
	while (itr.hasNext()) {
		ICombinatoricsVector<String> combination = itr.next();
		System.out.println(combination);
	}

	List<ICombinatoricsVector<String>> list = gen.generateAllObjects();

	assertEquals(1, list.size());

	assertEquals("CombinatoricsVector=([red], size=1)", list.get(0)
			.toString());
}
 
开发者ID:dpaukov,项目名称:combinatoricslib,代码行数:35,代码来源:SimpleCombinationTest.java

示例12: simpleOneTwoCombinationTest

import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
@Test
public void simpleOneTwoCombinationTest() {

	// create array of initial items
	List<String> array = new ArrayList<String>();
	array.add("red");

	// create combinatorics vector
	ICombinatoricsVector<String> initialVector = Factory
			.createVector(array);

	// create simple combination generator to generate 2-combination of 1
	Generator<String> gen = Factory.createSimpleCombinationGenerator(
			initialVector, 2);

	// create iterator
	Iterator<ICombinatoricsVector<String>> itr = gen.iterator();

	// print the number of combinations
	assertEquals(0, gen.getNumberOfGeneratedObjects());

	// go through the iterator
	assertEquals(false, itr.hasNext());

	List<ICombinatoricsVector<String>> list = gen.generateAllObjects();
	assertEquals(0, list.size());

}
 
开发者ID:dpaukov,项目名称:combinatoricslib,代码行数:29,代码来源:SimpleCombinationTest.java

示例13: simpleTwoTwoCombinationTest

import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
@Test
public void simpleTwoTwoCombinationTest() {

	// create combinatorics vector
	ICombinatoricsVector<String> initialVector = Factory
			.createVector(new String[] { "red", "green" });

	// create simple combination generator to generate 2-combination of 2
	Generator<String> gen = Factory.createSimpleCombinationGenerator(
			initialVector, 2);

	// create iterator
	Iterator<ICombinatoricsVector<String>> itr = gen.iterator();

	// print the number of combinations
	assertEquals(1, gen.getNumberOfGeneratedObjects());

	// go through the iterator
	while (itr.hasNext()) {
		ICombinatoricsVector<String> combination = itr.next();
		System.out.println(combination);
	}

	List<ICombinatoricsVector<String>> list = gen.generateAllObjects();

	assertEquals(1, list.size());

	assertEquals("CombinatoricsVector=([red, green], size=2)", list.get(0)
			.toString());

}
 
开发者ID:dpaukov,项目名称:combinatoricslib,代码行数:32,代码来源:SimpleCombinationTest.java

示例14: simpleObjectsCombinationTest

import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
@Test
public void simpleObjectsCombinationTest() {

	// create combinatorics vector
	ICombinatoricsVector<Apple> initialVector = Factory.createVector();
	
	// Add 3 apples
	initialVector.addValue(new Apple("red"));
	initialVector.addValue(new Apple("green"));
	initialVector.addValue(new Apple("yellow"));

	// create simple combination generator to generate 2-combination of 3 apples
	Generator<Apple> gen = Factory.createSimpleCombinationGenerator(
			initialVector, 2);

	// create iterator
	Iterator<ICombinatoricsVector<Apple>> itr = gen.iterator();

	// print the number of combinations
	assertEquals(3, gen.getNumberOfGeneratedObjects());

	// go through the iterator
	while (itr.hasNext()) {
		ICombinatoricsVector<Apple> combination = itr.next();
		System.out.println(combination);
	}

	List<ICombinatoricsVector<Apple>> list = gen.generateAllObjects();

	assertEquals(3, list.size());

	assertEquals("CombinatoricsVector=([(Apple: red), (Apple: green)], size=2)", list.get(0)
			.toString());
	assertEquals("CombinatoricsVector=([(Apple: red), (Apple: yellow)], size=2)", list.get(1)
			.toString());
	assertEquals("CombinatoricsVector=([(Apple: green), (Apple: yellow)], size=2)", list.get(2)
			.toString());

}
 
开发者ID:dpaukov,项目名称:combinatoricslib,代码行数:40,代码来源:SimpleCombinationTest.java

示例15: genAttrCombs

import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
private List<AttrComb> genAttrCombs(int setSize){
  
  List<AttrComb> attrCombs = new ArrayList<AttrComb>();
  
  // Create the initial vector
   ICombinatoricsVector<Attribute> initialVector = Factory.createVector(filteredAttrs);

  // Create a simple combination generator to generate 3-combinations of the initial vector
  Generator<Attribute> gen = Factory.createSimpleCombinationGenerator(initialVector, setSize);

  // Print all possible combinations
  for (ICombinatoricsVector<Attribute> combination : gen) {
     attrCombs.add(new AttrComb(combination));
  }
  
  return attrCombs;
  
}
 
开发者ID:saikatgomes,项目名称:CS784-Data_Integration,代码行数:19,代码来源:AttributeSelector.java


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