use of common.datastore.PieceCounter in project solution-finder by knewjade.
the class PackSearcherComparingParityBasedOnDemandTest method compareCount.
private void compareCount(int width, int height, List<TestData> testDataList) throws InterruptedException, ExecutionException {
SizedBit sizedBit = new SizedBit(width, height);
SeparableMinos separableMinos = createSeparableMinos(sizedBit);
Predicate<ColumnField> bitCountPredicate = BasicSolutions.createBitCountPredicate(1);
OnDemandBasicSolutions onDemandBasicSolutions = new OnDemandBasicSolutions(separableMinos, sizedBit, bitCountPredicate);
for (TestData data : testDataList) {
// 準備
List<Piece> usingPieces = data.getPieces();
int popCount = usingPieces.size();
Field initField = createSquareEmptyField(height, popCount);
// packで探索
Set<PieceCounter> pieceCounters = Collections.singleton(new PieceCounter(usingPieces));
SolutionFilter solutionFilter = createUsingBlockAndValidKeyMementoFilter(initField, sizedBit, pieceCounters);
BasicSolutions basicSolutions = new FilterWrappedBasicSolutions(onDemandBasicSolutions, solutionFilter);
long packCounter = calculateSRSValidCount(sizedBit, basicSolutions, initField, solutionFilter);
System.out.println(usingPieces);
assertThat(packCounter).isEqualTo(data.getCount());
}
}
use of common.datastore.PieceCounter in project solution-finder by knewjade.
the class PackSearcherComparingParityBasedOnDemandTest method createUsingBlockAndValidKeyMementoFilter.
// パフェするまでに有効なブロック数を列挙する
private SolutionFilter createUsingBlockAndValidKeyMementoFilter(Field initField, SizedBit sizedBit, Set<PieceCounter> counters) {
HashSet<Long> validBlockCounters = new HashSet<>();
for (PieceCounter counter : counters) {
List<Piece> usingPieces = counter.getBlocks();
for (int size = 1; size <= usingPieces.size(); size++) {
CombinationIterable<Piece> combinationIterable = new CombinationIterable<>(usingPieces, size);
for (List<Piece> pieces : combinationIterable) {
PieceCounter newCounter = new PieceCounter(pieces);
validBlockCounters.add(newCounter.getCounter());
}
}
}
LockedReachableThreadLocal reachableThreadLocal = new LockedReachableThreadLocal(sizedBit.getHeight());
return new UsingBlockAndValidKeySolutionFilter(initField, validBlockCounters, reachableThreadLocal, sizedBit);
}
use of common.datastore.PieceCounter in project solution-finder by knewjade.
the class PackSearcherComparingParityBasedTest method createUsingBlockAndValidKeyMementoFilter.
// パフェするまでに有効なブロック数を列挙する
private SolutionFilter createUsingBlockAndValidKeyMementoFilter(Field initField, SizedBit sizedBit, Set<PieceCounter> counters) {
HashSet<Long> validBlockCounters = new HashSet<>();
for (PieceCounter counter : counters) {
List<Piece> usingPieces = counter.getBlocks();
for (int size = 1; size <= usingPieces.size(); size++) {
CombinationIterable<Piece> combinationIterable = new CombinationIterable<>(usingPieces, size);
for (List<Piece> pieces : combinationIterable) {
PieceCounter newCounter = new PieceCounter(pieces);
validBlockCounters.add(newCounter.getCounter());
}
}
}
LockedReachableThreadLocal reachableThreadLocal = new LockedReachableThreadLocal(sizedBit.getHeight());
return new UsingBlockAndValidKeySolutionFilter(initField, validBlockCounters, reachableThreadLocal, sizedBit);
}
Aggregations