@Before
 public void setUp() {
   solutionDao = createSolutionDao();
   File dataDir = solutionDao.getDataDir();
   if (!dataDir.exists()) {
     throw new IllegalStateException(
         "The directory dataDir ("
             + dataDir.getAbsolutePath()
             + ") does not exist."
             + " The working directory should be set to the directory that contains the data directory."
             + " This is different in a git clone (optaplanner/optaplanner-examples)"
             + " and the release zip (examples).");
   }
 }
 protected static Collection<Object[]> getUnsolvedDataFilesAsParameters(SolutionDao solutionDao) {
   List<Object[]> filesAsParameters = new ArrayList<Object[]>();
   File dataDir = solutionDao.getDataDir();
   File unsolvedDataDir = new File(dataDir, "unsolved");
   if (!unsolvedDataDir.exists()) {
     throw new IllegalStateException(
         "The directory unsolvedDataDir ("
             + unsolvedDataDir.getAbsolutePath()
             + ") does not exist.");
   } else {
     List<File> unsolvedFileList =
         Arrays.asList(unsolvedDataDir.listFiles(new SolutionFileFilter(solutionDao)));
     Collections.sort(unsolvedFileList);
     for (File unsolvedFile : unsolvedFileList) {
       filesAsParameters.add(new Object[] {unsolvedFile});
     }
   }
   return filesAsParameters;
 }
 @Test
 public void runFastAndFullAssert() {
   checkRunTurtleTests();
   SolverFactory solverFactory = buildSolverFactory();
   Solution planningProblem = solutionDao.readSolution(unsolvedDataFile);
   // Specifically use NON_INTRUSIVE_FULL_ASSERT instead of FULL_ASSERT to flush out bugs hidden by
   // intrusiveness
   // 1) NON_INTRUSIVE_FULL_ASSERT ASSERT to find CH bugs (but covers little ground)
   planningProblem =
       buildAndSolve(
           solverFactory, EnvironmentMode.NON_INTRUSIVE_FULL_ASSERT, planningProblem, 2L);
   // 2) FAST_ASSERT to run past CH into LS to find easy bugs (but covers much ground)
   planningProblem =
       buildAndSolve(solverFactory, EnvironmentMode.FAST_ASSERT, planningProblem, 5L);
   // 3) NON_INTRUSIVE_FULL_ASSERT ASSERT to find LS bugs (but covers little ground)
   planningProblem =
       buildAndSolve(
           solverFactory, EnvironmentMode.NON_INTRUSIVE_FULL_ASSERT, planningProblem, 3L);
 }
 private void writeNQueens(int n) {
   String outputFileName = n + "queens.xml";
   File outputFile = new File(outputDir, outputFileName);
   NQueens nQueens = createNQueens(n);
   solutionDao.writeSolution(nQueens, outputFile);
 }
Esempio n. 5
0
 public void generate() {
   String inputId = "munich-7teams";
   File outputFile = new File(outputDir, inputId + ".xml");
   TennisSolution tennisSolution = createTennisSolution(inputId);
   solutionDao.writeSolution(tennisSolution, outputFile);
 }
Esempio n. 6
0
 public TennisGenerator() {
   solutionDao = new TennisDao();
   outputDir = new File(solutionDao.getDataDir(), "unsolved");
 }