All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.shapleyvalue.util.Powerset Maven / Gradle / Ivy

The newest version!
package org.shapleyvalue.util;

import java.util.HashSet;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.common.collect.Sets;

public class Powerset {
	
	private static final Logger logger = LoggerFactory.getLogger(Powerset.class);
	
	public static final  Set nullSet = new HashSet();
	
	public static Set> calculate(int nbElements) {
		
		Set inputSet = new HashSet<>();
		for(int i=1; i<=nbElements; i++) inputSet.add(i);
		logger.debug("inputSet {}", inputSet);
		
		Set> result = Sets.powerSet(inputSet);
	    logger.debug("Powerset for {} element(s), result {}",nbElements, result.toArray());
		return result;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy