Ejemplo n.º 1
0
  @Test
  public void test2() {
    CPSolver s = new CPSolver();
    RealVar alpha = s.createRealVal("alpha", -5.5 * Math.PI, -1.5 * Math.PI);
    RealExp exp = new RealCos(s, alpha);
    s.post(s.makeEquation(exp, s.cst(1.0)));

    boolean first = false;
    s.setFirstSolution(first);
    s.generateSearchStrategy();
    s.addGoal(new AssignInterval(new CyclicRealVarSelector(s), new RealIncreasingDomain()));
    s.launch();

    assertTrue(s.getNbSolutions() >= 2);
  }
Ejemplo n.º 2
0
  @Test
  public void test1() {
    CPSolver s = new CPSolver();
    RealVar alpha = s.createRealVal("alpha", -Math.PI, Math.PI);

    RealExp exp = new RealMinus(s, new RealCos(s, alpha), new RealSin(s, alpha));
    SConstraint c = s.makeEquation(exp, s.cst(0.0));
    LOGGER.info("c = " + c.pretty());
    s.post(s.makeEquation(exp, s.cst(0.0)));

    boolean first = false;
    s.setFirstSolution(first);
    s.generateSearchStrategy();
    s.addGoal(new AssignInterval(new CyclicRealVarSelector(s), new RealIncreasingDomain()));
    s.launch();

    assertTrue("Nb sols", s.getNbSolutions() >= 2);
    assertTrue("Precision", Math.abs(Math.cos(alpha.getInf()) - Math.sin(alpha.getInf())) < 1e-8);
  }