use of searcher.pack.SeparableMinos in project solution-finder by knewjade.
the class MappedBasicSolutionsFactoryTest method assertCache.
private void assertCache(SizedBit sizedBit, long expectedSolutions, long expectedSolutionItems) throws IOException {
SeparableMinos separableMinos = createSeparableMinos(sizedBit);
BasicSolutionsCalculator calculator = new BasicSolutionsCalculator(separableMinos, sizedBit);
Stopwatch stopwatch1 = Stopwatch.createStartedStopwatch();
Map<ColumnField, RecursiveMinoFields> calculate = calculator.calculate();
stopwatch1.stop();
System.out.println("create only: " + stopwatch1.toMessage(TimeUnit.MILLISECONDS));
AllPassedSolutionFilter solutionFilter = new AllPassedSolutionFilter();
MappedBasicSolutions solutions = new MappedBasicSolutions(calculate, solutionFilter);
assertThat(countValidKey(solutions)).isEqualTo(expectedSolutions);
assertThat(countValidItem(solutions)).isEqualTo(expectedSolutionItems);
}
use of searcher.pack.SeparableMinos in project solution-finder by knewjade.
the class MappedBasicSolutionsTest method get2x3.
@Test
void get2x3() throws Exception {
SizedBit sizedBit = new SizedBit(2, 3);
SeparableMinos separableMinos = createSeparableMinos(sizedBit);
BasicSolutionsCalculator calculator = new BasicSolutionsCalculator(separableMinos, sizedBit);
Map<ColumnField, RecursiveMinoFields> calculate = calculator.calculate();
BasicSolutions solutions = new MappedBasicSolutions(calculate);
MinoFields minoFields = solutions.parse(ColumnFieldFactory.createField());
Stream<? extends MinoField> stream = minoFields.stream();
assertThat(stream.count()).isEqualTo(78L);
}
use of searcher.pack.SeparableMinos in project solution-finder by knewjade.
the class MappedBasicSolutionsTest method get3x4.
@Test
void get3x4() throws Exception {
SizedBit sizedBit = new SizedBit(3, 4);
SeparableMinos separableMinos = createSeparableMinos(sizedBit);
BasicSolutionsCalculator calculator = new BasicSolutionsCalculator(separableMinos, sizedBit);
Map<ColumnField, RecursiveMinoFields> calculate = calculator.calculate();
BasicSolutions solutions = new MappedBasicSolutions(calculate);
MinoFields minoFields = solutions.parse(ColumnFieldFactory.createField());
Stream<? extends MinoField> stream = minoFields.stream();
assertThat(stream.count()).isEqualTo(8516L);
}
use of searcher.pack.SeparableMinos in project solution-finder by knewjade.
the class OnDemandBasicSolutionsFactoryTest method assertCache.
private void assertCache(SizedBit sizedBit, long expectedSolutions, long expectedSolutionItems) throws IOException {
SeparableMinos separableMinos = createSeparableMinos(sizedBit);
int minMemorizedBit = (int) (sizedBit.getMaxBitDigit() * 0.2);
Predicate<ColumnField> memorizedPredicate = BasicSolutions.createBitCountPredicate(minMemorizedBit);
OnDemandBasicSolutions solutions = new OnDemandBasicSolutions(separableMinos, sizedBit, memorizedPredicate);
Stopwatch stopwatch1 = Stopwatch.createStartedStopwatch();
LongStream.rangeClosed(0, sizedBit.getFillBoard()).parallel().boxed().sorted(Comparator.comparingLong(Long::bitCount).reversed()).map(ColumnFieldFactory::createField).forEach(solutions::parse);
stopwatch1.stop();
System.out.println("create only: " + stopwatch1.toMessage(TimeUnit.MILLISECONDS));
assertThat(countValidKey(solutions)).isEqualTo(expectedSolutions);
assertThat(countValidItem(solutions)).isEqualTo(expectedSolutionItems);
}
use of searcher.pack.SeparableMinos in project solution-finder by knewjade.
the class OnDemandBasicSolutionsTest method get3x5.
@Test
void get3x5() throws Exception {
assertTimeout(ofMinutes(1), () -> {
SizedBit sizedBit = new SizedBit(3, 5);
SeparableMinos separableMinos = createSeparableMinos(sizedBit);
Predicate<ColumnField> memorizedPredicate = columnField -> true;
OnDemandBasicSolutions solutions = new OnDemandBasicSolutions(separableMinos, sizedBit, memorizedPredicate);
Stream<? extends MinoField> stream = solutions.parse(ColumnFieldFactory.createField()).stream();
assertThat(stream.count()).isEqualTo(260179L);
});
}
Aggregations