示例#1
0
  @Test
  public void metadataConversion() {
    // metadata wasn't set
    Solution solution = new Solution(problem);
    Element solutionElm = converter.export(solution);
    Solution extracted = converter.extract(solutionElm);

    assertNull(extracted.getMetadata());

    // metadata was set
    SolutionMetadata metadata = new SolutionMetadata();
    metadata.setDescription("Test solution.");
    solution.setMetadata(metadata);

    solutionElm = converter.export(solution);
    extracted = converter.extract(solutionElm);

    assertNotNull(extracted.getMetadata());
  }
示例#2
0
  @Test
  public void conversion() {
    List<Pattern> patterns = new ArrayList<Pattern>();

    Pattern pattern;

    // valid solution
    pattern = new Pattern(problem);
    pattern.addCut(orders.get(0), 0);
    pattern.addCut(orders.get(1), 1);
    pattern.addCut(orders.get(2), 1);
    pattern.setRoll(roll1);
    patterns.add(pattern);

    pattern = new Pattern(problem);
    pattern.addCut(orders.get(0), 1);
    pattern.addCut(orders.get(1), 2);
    pattern.addCut(orders.get(2), 2);
    pattern.setRoll(roll2);
    patterns.add(pattern);

    Solution solution = new Solution(problem, patterns);
    assertTrue(solution.isFeasible());

    Element solutionElm = converter.export(solution);
    Solution extracted = converter.extract(solutionElm);

    assertEquals(solution.getPatterns().size(), extracted.getPatterns().size());
    assertEquals(
        solution.getMetricProvider().getUniquePatternsCount(),
        extracted.getMetricProvider().getUniquePatternsCount());

    for (Order order : orders) {
      assertEquals(
          solution.getProductionLengthForOrder(order),
          extracted.getProductionLengthForOrder(order),
          DELTA);
    }

    assertEquals(solution.isOrdersFulfilled(), extracted.isOrdersFulfilled());
    assertEquals(solution.isFeasible(), extracted.isFeasible());
  }