Search in sources :

Example 6 with RealBinaryExpression

use of org.evosuite.symbolic.expr.fp.RealBinaryExpression in project evosuite by EvoSuite.

the class IEEEremainder method executeFunction.

@Override
public Object executeFunction() {
    double res = this.getConcDoubleRetVal();
    RealValue left = this.getSymbRealArgument(0);
    RealValue right = this.getSymbRealArgument(1);
    RealValue ieeeRemainderExpr;
    if (left.containsSymbolicVariable() || right.containsSymbolicVariable()) {
        Operator op = Operator.IEEEREMAINDER;
        ieeeRemainderExpr = new RealBinaryExpression(left, op, right, res);
    } else {
        ieeeRemainderExpr = this.getSymbRealRetVal();
    }
    return ieeeRemainderExpr;
}
Also used : RealValue(org.evosuite.symbolic.expr.fp.RealValue) Operator(org.evosuite.symbolic.expr.Operator) RealBinaryExpression(org.evosuite.symbolic.expr.fp.RealBinaryExpression)

Example 7 with RealBinaryExpression

use of org.evosuite.symbolic.expr.fp.RealBinaryExpression in project evosuite by EvoSuite.

the class POW method executeFunction.

@Override
public Object executeFunction() {
    double res = this.getConcDoubleRetVal();
    RealValue left = this.getSymbRealArgument(0);
    RealValue right = this.getSymbRealArgument(1);
    RealValue powExpr;
    if (left.containsSymbolicVariable() || right.containsSymbolicVariable()) {
        Operator op = Operator.POW;
        powExpr = new RealBinaryExpression(left, op, right, res);
    } else {
        powExpr = this.getSymbRealRetVal();
    }
    return powExpr;
}
Also used : RealValue(org.evosuite.symbolic.expr.fp.RealValue) Operator(org.evosuite.symbolic.expr.Operator) RealBinaryExpression(org.evosuite.symbolic.expr.fp.RealBinaryExpression)

Example 8 with RealBinaryExpression

use of org.evosuite.symbolic.expr.fp.RealBinaryExpression in project evosuite by EvoSuite.

the class TestRealSearch method testEvosuiteExample3.

// @Test
public void testEvosuiteExample3() {
    // ((1102.5 + var22__SYM(12.220999717712402)) *
    // var19__SYM(-45.633541107177734)) == 2.772399987618165E32
    double var1 = 12.220999717712402;
    double var2 = -45.633541107177734;
    RealVariable realVar1 = new RealVariable("test1", var1, -1000000, 1000000);
    RealVariable realVar2 = new RealVariable("test2", var2, -1000000, 1000000);
    List<Constraint<?>> constraints = new ArrayList<Constraint<?>>();
    constraints.add(new RealConstraint(new RealBinaryExpression(new RealBinaryExpression(new RealConstant(1102.5), Operator.PLUS, realVar1, 1.22209997177135E16), Operator.MUL, realVar2, -5.57687492989087E32), Comparator.EQ, new RealConstant(2.772399987618165E32)));
    assert (DistanceEstimator.getDistance(constraints) > 0);
    EvoSuiteSolver skr = new EvoSuiteSolver();
    Map<String, Object> result;
    try {
        result = solve(skr, constraints);
        assertNotNull(result);
        if (result.containsKey("test1"))
            var1 = ((Number) result.get("test1")).doubleValue();
        if (result.containsKey("test2"))
            var2 = ((Number) result.get("test2")).doubleValue();
        assertEquals(var1, var2, 0.0001);
    } catch (SolverTimeoutException e) {
        fail();
    }
}
Also used : SolverTimeoutException(org.evosuite.symbolic.solver.SolverTimeoutException) Constraint(org.evosuite.symbolic.expr.Constraint) RealConstraint(org.evosuite.symbolic.expr.RealConstraint) EvoSuiteSolver(org.evosuite.symbolic.solver.avm.EvoSuiteSolver) ArrayList(java.util.ArrayList) RealVariable(org.evosuite.symbolic.expr.fp.RealVariable) RealConstant(org.evosuite.symbolic.expr.fp.RealConstant) RealBinaryExpression(org.evosuite.symbolic.expr.fp.RealBinaryExpression) RealConstraint(org.evosuite.symbolic.expr.RealConstraint)

Example 9 with RealBinaryExpression

use of org.evosuite.symbolic.expr.fp.RealBinaryExpression in project evosuite by EvoSuite.

the class TestRealSearch method testAddition.

@Test
public void testAddition() {
    double var1 = 1.0;
    RealVariable realVar1 = new RealVariable("test1", var1, Double.MIN_VALUE, Double.MAX_VALUE);
    List<Constraint<?>> constraints = new ArrayList<Constraint<?>>();
    final double doubleValue = 2000.087658834634;
    constraints.add(new RealConstraint(new RealBinaryExpression(new RealConstant(1102.5), Operator.PLUS, realVar1, 1103.5), Comparator.EQ, new RealConstant(doubleValue)));
    assert (DistanceEstimator.getDistance(constraints) > 0);
    EvoSuiteSolver skr = new EvoSuiteSolver();
    Map<String, Object> result;
    try {
        result = solve(skr, constraints);
        assertNotNull(result);
        if (result.containsKey("test1"))
            var1 = ((Number) result.get("test1")).doubleValue();
    // assertEquals(var1, var2, 0.0001);
    } catch (SolverTimeoutException e) {
        fail();
    }
}
Also used : SolverTimeoutException(org.evosuite.symbolic.solver.SolverTimeoutException) Constraint(org.evosuite.symbolic.expr.Constraint) RealConstraint(org.evosuite.symbolic.expr.RealConstraint) EvoSuiteSolver(org.evosuite.symbolic.solver.avm.EvoSuiteSolver) ArrayList(java.util.ArrayList) RealVariable(org.evosuite.symbolic.expr.fp.RealVariable) RealConstant(org.evosuite.symbolic.expr.fp.RealConstant) RealBinaryExpression(org.evosuite.symbolic.expr.fp.RealBinaryExpression) RealConstraint(org.evosuite.symbolic.expr.RealConstraint) Test(org.junit.Test)

Aggregations

RealBinaryExpression (org.evosuite.symbolic.expr.fp.RealBinaryExpression)9 RealValue (org.evosuite.symbolic.expr.fp.RealValue)6 Operator (org.evosuite.symbolic.expr.Operator)4 RealConstant (org.evosuite.symbolic.expr.fp.RealConstant)3 ArrayList (java.util.ArrayList)2 Constraint (org.evosuite.symbolic.expr.Constraint)2 RealConstraint (org.evosuite.symbolic.expr.RealConstraint)2 RealVariable (org.evosuite.symbolic.expr.fp.RealVariable)2 SolverTimeoutException (org.evosuite.symbolic.solver.SolverTimeoutException)2 EvoSuiteSolver (org.evosuite.symbolic.solver.avm.EvoSuiteSolver)2 Test (org.junit.Test)1