org.shapleyvalue.util.Powerset Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of shapley-value-core Show documentation
Show all versions of shapley-value-core Show documentation
Shapley value calculation in java
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