@Test
  public void testCost3() throws Exception {

    String q1 =
        "" //
            + "SELECT ?f ?m ?d ?e ?l ?c " //
            + "{" //
            + "  Filter(?f > \"5\")." //
            + "  Filter(?e > \"6\")." //
            + "  ?f a ?m ." //
            + "  ?e a ?l ." //
            + "  ?d <uri:talksTo> ?f . " //
            + "  ?c <uri:talksTo> ?e . " //
            + "  ?m <http://www.w3.org/2000/01/rdf-schema#label> ?d ." //
            + "  ?l <http://www.w3.org/2000/01/rdf-schema#label> ?c ." //
            + "}"; //

    String q2 =
        "" //
            + "SELECT ?s ?t ?u " //
            + "{" //
            + "  ?s a ?t ." //
            + "  ?t <http://www.w3.org/2000/01/rdf-schema#label> ?u ." //
            + "  ?u <uri:talksTo> ?s . " //
            + "}"; //

    SPARQLParser parser = new SPARQLParser();

    ParsedQuery pq1 = parser.parseQuery(q1, null);
    ParsedQuery pq2 = parser.parseQuery(q2, null);

    SimpleExternalTupleSet sep = new SimpleExternalTupleSet((Projection) pq2.getTupleExpr());
    List<ExternalTupleSet> eList = Lists.newArrayList();
    eList.add(sep);

    final TupleExpr te = pq1.getTupleExpr().clone();
    final PCJOptimizer pcj = new PCJOptimizer(eList, false);
    pcj.optimize(te, null, null);

    ThreshholdPlanSelector tps = new ThreshholdPlanSelector(pq1.getTupleExpr());
    double cost = tps.getCost(te, .4, .3, .3);
    Assert.assertEquals(.575, cost, .0001);
  }
  @Test
  public void testCost2() throws Exception {

    String q1 =
        "" //
            + "SELECT ?f ?m ?d ?e ?l ?c " //
            + "{" //
            + "  ?f a ?m ." //
            + "  ?e a ?l ." //
            + "  ?d <uri:talksTo> ?f . " //
            + "  ?c <uri:talksTo> ?e . " //
            + "  ?m <http://www.w3.org/2000/01/rdf-schema#label> ?d ." //
            + "  ?l <http://www.w3.org/2000/01/rdf-schema#label> ?c ." //
            + "}"; //

    SPARQLParser parser = new SPARQLParser();

    ParsedQuery pq1 = parser.parseQuery(q1, null);

    ThreshholdPlanSelector tps = new ThreshholdPlanSelector(pq1.getTupleExpr());
    double cost = tps.getCost(pq1.getTupleExpr(), .4, .3, .3);
    Assert.assertEquals(.58, cost, .000000001);
  }
  @Test
  public void testCost1() throws Exception {

    String q1 =
        "" //
            + "SELECT ?f ?m ?d ?h ?i " //
            + "{" //
            + "  ?f a ?m ." //
            + "  ?m <http://www.w3.org/2000/01/rdf-schema#label> ?d ." //
            + "  ?d <uri:talksTo> ?f . " //
            + "  ?d <uri:hangOutWith> ?f ." //
            + "  ?f <uri:hangOutWith> ?h ." //
            + "  ?f <uri:associatesWith> ?i ." //
            + "  ?i <uri:associatesWith> ?h ." //
            + "}"; //

    SPARQLParser parser = new SPARQLParser();

    ParsedQuery pq1 = parser.parseQuery(q1, null);

    ThreshholdPlanSelector tps = new ThreshholdPlanSelector(pq1.getTupleExpr());
    double cost = tps.getCost(pq1.getTupleExpr(), .6, .4, 0);
    Assert.assertEquals(.7, cost, .01);
  }