Package ai.domain.boxes

Examples of ai.domain.boxes.IntegerBoxes


  @Override
  public IntegerBoxes createInitialValue(List<Map<Variable, Interval>> parsedDescription) {
    if (parsedDescription.size() == 0)
      return IntegerBoxes.getInitialValue();
    IntegerBoxes result = IntegerBoxes.BOTTOM;
    for(Map<Variable, Interval> item: parsedDescription) {
      NonRelationalDomain<Interval> parsedItem = intvParser.createInitialValue(item);
      result = result.join(IntegerBoxesHelper.fromIntervalBox(parsedItem));
    }
    return result;
  }
View Full Code Here


    final CommentBoxes domain = (CommentBoxes) domains.get("boxes");
    Utils.walkGraph(graph, new ControlFlowGraphVisitor() {
      @Override
      public boolean visitVertice(CFGVertice vertice) {
        // verify values
        IntegerBoxes analysisResult = result.get(vertice);
        domain.compareResult(vertice, analysisResult);
        return true;
      }

      @Override
View Full Code Here

  protected void testBooleansAndBoxes(MethodControlFlowGraph cfg) {
    TestCommentData commentData = TestCommentData.parseComments(cfg);
    IntegerBoxesSemantics as = new IntegerBoxesSemantics("");

    NonRelationalDomain<Bool> initialBools = commentData.getInitialBools();
    IntegerBoxes initialBoxes = commentData.getInitialBoxes();

    ProductDomain<NonRelationalDomain<Bool>, IntegerBoxes> initialValue = as.getInitialValue();

    if (initialBools != null)
      initialValue = initialValue.setLeft(initialBools);
    if (initialBoxes != null)
      initialValue = initialValue.setRight(initialBoxes);

    Map<CFGVertice, ProductDomain<NonRelationalDomain<Bool>, IntegerBoxes>> result = Interpreter
        .analyse(cfg, as, initialValue, new StopCondition.NoStopCondition());

    NonRelationalDomain<Bool> boolsBottom = NonRelationalDomain.getStaticBottom();
    IntegerBoxes boxesBottom = IntegerBoxes.BOTTOM;
    commentData.matchBools(cfg, makeMap1(result, boolsBottom));
    commentData.matchBoxes(cfg, makeMap2(result, boxesBottom));
  }
View Full Code Here

    }
    if (boxes.isBottom()) {
      cr.boxesBetter(vertice);
      return;
    }
    IntegerBoxes intvBox = IntegerBoxesHelper.fromIntervalBox(boolIntv.getRight());
    IntegerBoxes boxesBox = boxes.getRight();
    // compare
    if (boxesBox.equals(intvBox)) {
      cr.equal(vertice);
      return;
    }
    if (boxesBox.leq(intvBox)) {
      cr.boxesBetter(vertice);
      return;
    }

    if (intvBox.leq(boxesBox)) {
View Full Code Here

    return res;
  }

  private IntegerBoxes getSingleBoxAndVerify(IntervalValue... data) {
    NonRelationalDomain<Interval> input = prepareBox(data);
    IntegerBoxes i = IntegerBoxesHelper.fromIntervalBox(input);

    List<NonRelationalDomain<Interval>> output = IntegerBoxesHelper.split(i);
    org.junit.Assert.assertEquals(output.size(), 1);
    org.junit.Assert.assertEquals(output.get(0), input);
    return i;
View Full Code Here

  }

  @Test
  public void joinOneDimension() {
    // 1 dimension
    IntegerBoxes first = getSingleBoxAndVerify(new IntervalValue(1, 2));
    IntegerBoxes second = getSingleBoxAndVerify(new IntervalValue(2, 4));
    verifyResult(first.join(second), prepareBox(new IntervalValue(1, 4)));
    verifyResult(second.join(first), prepareBox(new IntervalValue(1, 4)));

    first = getSingleBoxAndVerify(new IntervalValue(1, 2));
    second = getSingleBoxAndVerify(new IntervalValue(3, 4));
    verifyResult(first.join(second), prepareBox(new IntervalValue(1, 4)));
    verifyResult(second.join(first), prepareBox(new IntervalValue(1, 4)));

    first = getSingleBoxAndVerify(new IntervalValue(1, 2));
    second = getSingleBoxAndVerify(new IntervalValue(4, 5));
    verifyResult(first.join(second), prepareBox(new IntervalValue(1, 2)), prepareBox(new IntervalValue(4, 5)));
    verifyResult(second.join(first), prepareBox(new IntervalValue(1, 2)), prepareBox(new IntervalValue(4, 5)));

    first = first.join(second);
    second = getSingleBoxAndVerify(new IntervalValue(3, Double.POSITIVE_INFINITY));
    verifyResult(first.join(second), prepareBox(new IntervalValue(1, Double.POSITIVE_INFINITY)));
    verifyResult(second.join(first), prepareBox(new IntervalValue(1, Double.POSITIVE_INFINITY)));
  }
View Full Code Here

  }

  @Test
  public void meetOneDimension() {
    // 1 dimension
    IntegerBoxes first = getSingleBoxAndVerify(new IntervalValue(1, 2));
    IntegerBoxes second = getSingleBoxAndVerify(new IntervalValue(2, 4));
    verifyResult(first.meet(second), prepareBox(new IntervalValue(2, 2)));
    verifyResult(second.meet(first), prepareBox(new IntervalValue(2, 2)));

    first = getSingleBoxAndVerify(new IntervalValue(1, 2));
    second = getSingleBoxAndVerify(new IntervalValue(3, 4));
    verifyResult(first.meet(second));
    verifyResult(second.meet(first));

    first = getSingleBoxAndVerify(new IntervalValue(1, 7));
    second = getSingleBoxAndVerify(new IntervalValue(4, 5));
    verifyResult(first.meet(second), prepareBox(new IntervalValue(4, 5)));
    verifyResult(second.meet(first), prepareBox(new IntervalValue(4, 5)));
  }
View Full Code Here

  }

  @Test
  public void leqOneDimension() {
    // 1 dimension
    IntegerBoxes first = getSingleBoxAndVerify(new IntervalValue(1, 2));
    IntegerBoxes second = getSingleBoxAndVerify(new IntervalValue(2, 4));
    org.junit.Assert.assertFalse(first.leq(second));
    org.junit.Assert.assertFalse(second.leq(first));

    first = getSingleBoxAndVerify(new IntervalValue(1, 7));
    second = getSingleBoxAndVerify(new IntervalValue(3, 4));
    org.junit.Assert.assertFalse(first.leq(second));
    org.junit.Assert.assertTrue(second.leq(first));

    first = getSingleBoxAndVerify(new IntervalValue(1, 7));
    second = getSingleBoxAndVerify(new IntervalValue(4, 5));
    verifyResult(first.meet(second), prepareBox(new IntervalValue(4, 5)));
    verifyResult(second.meet(first), prepareBox(new IntervalValue(4, 5)));
  }
View Full Code Here

  }

  @Test
  public void leqTwoDimensionsWithVarRemoval() {
    // 1 dimension
    IntegerBoxes first = IntegerBoxesHelper.join(
        getSingleBoxAndVerify(new IntervalValue(0,2), new IntervalValue(0, 2)),
        getSingleBoxAndVerify(new IntervalValue(5,6), new IntervalValue(5, 6)));
    IntegerBoxes second = IntegerBoxesHelper.join(
        getSingleBoxAndVerify(new IntervalValue(0, 1)),
        getSingleBoxAndVerify(new IntervalValue(6, 6)));
    org.junit.Assert.assertFalse(first.leq(second));
    org.junit.Assert.assertTrue(second.leq(first));
  }
View Full Code Here

    org.junit.Assert.assertTrue(second.leq(first));
  }

  @Test
  public void leqTwoDimensionsWithoutVarRemoval01() {
    IntegerBoxes first = IntegerBoxesHelper.join(
        getSingleBoxAndVerify(new IntervalValue(0,2), new IntervalValue(0, 2)),
        getSingleBoxAndVerify(new IntervalValue(5,6), new IntervalValue(5, 6)));
    IntegerBoxes second = IntegerBoxesHelper.join(
        getSingleBoxAndVerify(new IntervalValue(0, 1), new IntervalValue(1,2)),
        getSingleBoxAndVerify(new IntervalValue(6, 6), new IntervalValue(5,5)));
    org.junit.Assert.assertFalse(first.leq(second));
    org.junit.Assert.assertTrue(second.leq(first));
  }
View Full Code Here

TOP

Related Classes of ai.domain.boxes.IntegerBoxes

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.