Search in sources :

Example 6 with BasicSolutions

use of searcher.pack.calculator.BasicSolutions in project solution-finder by knewjade.

the class EasyPath method setUp.

public List<Result> setUp(String goalFieldMarks, Field initField, int width, int height) throws ExecutionException, InterruptedException {
    assert !initField.existsAbove(height);
    SizedBit sizedBit = new SizedBit(width, height);
    Field goalField = FieldFactory.createInverseField(goalFieldMarks);
    List<InOutPairField> inOutPairFields = InOutPairField.createInOutPairFields(sizedBit, goalField);
    // Create
    BasicSolutions basicSolutions = createMappedBasicSolutions(sizedBit);
    TaskResultHelper taskResultHelper = new Field4x10MinoPackingHelper();
    // Assert
    SolutionFilter solutionFilter = createSRSSolutionFilter(sizedBit, initField);
    // パフェ手順の列挙
    PerfectPackSearcher searcher = new PerfectPackSearcher(inOutPairFields, basicSolutions, sizedBit, solutionFilter, taskResultHelper);
    return searcher.toList();
}
Also used : ColumnField(core.column_field.ColumnField) InOutPairField(searcher.pack.InOutPairField) Field(core.field.Field) Field4x10MinoPackingHelper(searcher.pack.task.Field4x10MinoPackingHelper) SizedBit(searcher.pack.SizedBit) InOutPairField(searcher.pack.InOutPairField) SolutionFilter(searcher.pack.memento.SolutionFilter) SRSValidSolutionFilter(searcher.pack.memento.SRSValidSolutionFilter) PerfectPackSearcher(searcher.pack.task.PerfectPackSearcher) TaskResultHelper(searcher.pack.task.TaskResultHelper) MappedBasicSolutions(searcher.pack.solutions.MappedBasicSolutions) BasicSolutions(searcher.pack.calculator.BasicSolutions)

Example 7 with BasicSolutions

use of searcher.pack.calculator.BasicSolutions in project solution-finder by knewjade.

the class EasyPath method buildUp.

public Set<LongPieces> buildUp(String goalFieldMarks, Field initField, int width, int height) throws ExecutionException, InterruptedException {
    assert !initField.existsAbove(height);
    SizedBit sizedBit = new SizedBit(width, height);
    Field goalField = FieldFactory.createInverseField(goalFieldMarks);
    List<InOutPairField> inOutPairFields = InOutPairField.createInOutPairFields(sizedBit, goalField);
    // Create
    BasicSolutions basicSolutions = createMappedBasicSolutions(sizedBit);
    TaskResultHelper taskResultHelper = new Field4x10MinoPackingHelper();
    // Assert
    SolutionFilter solutionFilter = createSRSSolutionFilter(sizedBit, initField);
    // パフェ手順の列挙
    PerfectPackSearcher searcher = new PerfectPackSearcher(inOutPairFields, basicSolutions, sizedBit, solutionFilter, taskResultHelper);
    LockedReachableThreadLocal reachableThreadLocal = easyPool.getLockedReachableThreadLocal(height);
    List<Result> results = searcher.toList();
    return results.stream().map(Result::getMemento).map(memento -> {
        return memento.getSeparableMinoStream(width).map(SeparableMino::toMinoOperationWithKey).collect(Collectors.toList());
    }).map(operations -> new BuildUpStream(reachableThreadLocal.get(), height).existsValidBuildPattern(initField, operations)).flatMap(listStream -> {
        return listStream.map(operationWithKeys -> {
            Stream<Piece> blocks = operationWithKeys.stream().map(OperationWithKey::getPiece);
            return new LongPieces(blocks);
        });
    }).collect(Collectors.toSet());
}
Also used : TaskResultHelper(searcher.pack.task.TaskResultHelper) RecursiveMinoFields(searcher.pack.mino_fields.RecursiveMinoFields) BasicSolutionsCalculator(searcher.pack.solutions.BasicSolutionsCalculator) LongPieces(common.datastore.blocks.LongPieces) ColumnField(core.column_field.ColumnField) SizedBit(searcher.pack.SizedBit) MinoFactory(core.mino.MinoFactory) Map(java.util.Map) SeparableMinos(searcher.pack.SeparableMinos) FieldFactory(core.field.FieldFactory) BuildUpStream(common.buildup.BuildUpStream) PerfectPackSearcher(searcher.pack.task.PerfectPackSearcher) OperationWithKey(common.datastore.OperationWithKey) Field4x10MinoPackingHelper(searcher.pack.task.Field4x10MinoPackingHelper) MinoShifter(core.mino.MinoShifter) MappedBasicSolutions(searcher.pack.solutions.MappedBasicSolutions) Piece(core.mino.Piece) Result(searcher.pack.task.Result) InOutPairField(searcher.pack.InOutPairField) Set(java.util.Set) Collectors(java.util.stream.Collectors) ExecutionException(java.util.concurrent.ExecutionException) SolutionFilter(searcher.pack.memento.SolutionFilter) List(java.util.List) Field(core.field.Field) BasicSolutions(searcher.pack.calculator.BasicSolutions) Stream(java.util.stream.Stream) SeparableMino(searcher.pack.separable_mino.SeparableMino) SRSValidSolutionFilter(searcher.pack.memento.SRSValidSolutionFilter) LockedReachableThreadLocal(concurrent.LockedReachableThreadLocal) Field4x10MinoPackingHelper(searcher.pack.task.Field4x10MinoPackingHelper) SeparableMino(searcher.pack.separable_mino.SeparableMino) TaskResultHelper(searcher.pack.task.TaskResultHelper) LockedReachableThreadLocal(concurrent.LockedReachableThreadLocal) MappedBasicSolutions(searcher.pack.solutions.MappedBasicSolutions) BasicSolutions(searcher.pack.calculator.BasicSolutions) Result(searcher.pack.task.Result) ColumnField(core.column_field.ColumnField) InOutPairField(searcher.pack.InOutPairField) Field(core.field.Field) SizedBit(searcher.pack.SizedBit) InOutPairField(searcher.pack.InOutPairField) LongPieces(common.datastore.blocks.LongPieces) SolutionFilter(searcher.pack.memento.SolutionFilter) SRSValidSolutionFilter(searcher.pack.memento.SRSValidSolutionFilter) PerfectPackSearcher(searcher.pack.task.PerfectPackSearcher) BuildUpStream(common.buildup.BuildUpStream) Stream(java.util.stream.Stream) BuildUpStream(common.buildup.BuildUpStream)

Example 8 with BasicSolutions

use of searcher.pack.calculator.BasicSolutions in project solution-finder by knewjade.

the class MappedBasicSolutionsTest method get3x5.

@Test
void get3x5() throws Exception {
    SizedBit sizedBit = new SizedBit(3, 5);
    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(260179L);
}
Also used : RecursiveMinoFields(searcher.pack.mino_fields.RecursiveMinoFields) MinoFields(searcher.pack.mino_fields.MinoFields) SeparableMinos(searcher.pack.SeparableMinos) SizedBit(searcher.pack.SizedBit) ColumnField(core.column_field.ColumnField) RecursiveMinoFields(searcher.pack.mino_fields.RecursiveMinoFields) BasicSolutions(searcher.pack.calculator.BasicSolutions) Test(org.junit.jupiter.api.Test)

Example 9 with BasicSolutions

use of searcher.pack.calculator.BasicSolutions in project solution-finder by knewjade.

the class MappedBasicSolutionsTest method get2x4.

@Test
void get2x4() throws Exception {
    SizedBit sizedBit = new SizedBit(2, 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(1239L);
}
Also used : RecursiveMinoFields(searcher.pack.mino_fields.RecursiveMinoFields) MinoFields(searcher.pack.mino_fields.MinoFields) SeparableMinos(searcher.pack.SeparableMinos) SizedBit(searcher.pack.SizedBit) ColumnField(core.column_field.ColumnField) RecursiveMinoFields(searcher.pack.mino_fields.RecursiveMinoFields) BasicSolutions(searcher.pack.calculator.BasicSolutions) Test(org.junit.jupiter.api.Test)

Example 10 with BasicSolutions

use of searcher.pack.calculator.BasicSolutions in project solution-finder by knewjade.

the class MappedBasicSolutionsTest method get2x5.

@Test
void get2x5() throws Exception {
    SizedBit sizedBit = new SizedBit(2, 5);
    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(19375L);
}
Also used : RecursiveMinoFields(searcher.pack.mino_fields.RecursiveMinoFields) MinoFields(searcher.pack.mino_fields.MinoFields) SeparableMinos(searcher.pack.SeparableMinos) SizedBit(searcher.pack.SizedBit) ColumnField(core.column_field.ColumnField) RecursiveMinoFields(searcher.pack.mino_fields.RecursiveMinoFields) BasicSolutions(searcher.pack.calculator.BasicSolutions) Test(org.junit.jupiter.api.Test)

Aggregations

BasicSolutions (searcher.pack.calculator.BasicSolutions)15 ColumnField (core.column_field.ColumnField)14 SizedBit (searcher.pack.SizedBit)13 SeparableMinos (searcher.pack.SeparableMinos)10 InOutPairField (searcher.pack.InOutPairField)9 SolutionFilter (searcher.pack.memento.SolutionFilter)9 Field (core.field.Field)8 RecursiveMinoFields (searcher.pack.mino_fields.RecursiveMinoFields)8 Test (org.junit.jupiter.api.Test)6 MinoFields (searcher.pack.mino_fields.MinoFields)6 MappedBasicSolutions (searcher.pack.solutions.MappedBasicSolutions)6 Piece (core.mino.Piece)5 SRSValidSolutionFilter (searcher.pack.memento.SRSValidSolutionFilter)5 BuildUpStream (common.buildup.BuildUpStream)4 PatternGenerator (common.pattern.PatternGenerator)4 OnDemandBasicSolutions (searcher.pack.solutions.OnDemandBasicSolutions)4 TaskResultHelper (searcher.pack.task.TaskResultHelper)4 LongPieces (common.datastore.blocks.LongPieces)3 ColumnSmallField (core.column_field.ColumnSmallField)3 MinoFactory (core.mino.MinoFactory)3