Adds a global configurable delta for all objective function value checks

This commit is contained in:
Maximilian Kratz 2022-08-04 10:38:49 +02:00
parent 72f8a67db5
commit 571fce43b7
12 changed files with 63 additions and 42 deletions

View file

@ -0,0 +1,10 @@
package test.suite.gips;
public class GlobalTestConfig {
private GlobalTestConfig() {
}
final public static double DELTA_OBJ = 0.0001d;
}

View file

@ -7,6 +7,7 @@ import org.emoflon.gips.core.ilp.ILPSolverStatus;
import org.junit.jupiter.api.Test;
import gipsl.all.build.and.connector.AndConnector;
import test.suite.gips.GlobalTestConfig;
public class GipslAllBuildAndTest extends AGipslAllBuildTest {
@ -31,7 +32,7 @@ public class GipslAllBuildAndTest extends AGipslAllBuildTest {
assertEquals(ILPSolverStatus.OPTIMAL, ret.status());
// All mappings must be chosen, according to the objective function
assertEquals(2, ret.objectiveValue());
assertEquals(2, ret.objectiveValue(), GlobalTestConfig.DELTA_OBJ);
}
@Test
@ -46,7 +47,7 @@ public class GipslAllBuildAndTest extends AGipslAllBuildTest {
assertEquals(ILPSolverStatus.OPTIMAL, ret.status());
// All mappings must be chosen, according to the objective function
assertEquals(3, ret.objectiveValue());
assertEquals(3, ret.objectiveValue(), GlobalTestConfig.DELTA_OBJ);
}
@Test
@ -62,7 +63,7 @@ public class GipslAllBuildAndTest extends AGipslAllBuildTest {
assertEquals(ILPSolverStatus.OPTIMAL, ret.status());
// Only 3 mappings must be chosen, according to the constraint
assertEquals(3, ret.objectiveValue());
assertEquals(3, ret.objectiveValue(), GlobalTestConfig.DELTA_OBJ);
}
// Negative tests

View file

@ -7,6 +7,7 @@ import org.emoflon.gips.core.ilp.ILPSolverStatus;
import org.junit.jupiter.api.Test;
import gipsl.all.build.implication.connector.ImplicationConnector;
import test.suite.gips.GlobalTestConfig;
public class GipslAllBuildImplicationTest extends AGipslAllBuildTest {
@ -30,7 +31,7 @@ public class GipslAllBuildImplicationTest extends AGipslAllBuildTest {
// No mapping must be chosen due to the implication constraint
assertEquals(ILPSolverStatus.OPTIMAL, ret.status());
assertEquals(0, ret.objectiveValue());
assertEquals(0, ret.objectiveValue(), GlobalTestConfig.DELTA_OBJ);
}
@Test
@ -44,7 +45,7 @@ public class GipslAllBuildImplicationTest extends AGipslAllBuildTest {
// Both mappings must be chosen to fulfill the implication constraint
assertEquals(ILPSolverStatus.OPTIMAL, ret.status());
assertEquals(2, ret.objectiveValue());
assertEquals(2, ret.objectiveValue(), GlobalTestConfig.DELTA_OBJ);
}
@Test
@ -59,7 +60,7 @@ public class GipslAllBuildImplicationTest extends AGipslAllBuildTest {
// Two mappings must be chosen to satisfy objective function
assertEquals(ILPSolverStatus.OPTIMAL, ret.status());
assertEquals(3, ret.objectiveValue());
assertEquals(3, ret.objectiveValue(), GlobalTestConfig.DELTA_OBJ);
}
@Test
@ -71,7 +72,7 @@ public class GipslAllBuildImplicationTest extends AGipslAllBuildTest {
// No mapping possible, but constraint is fulfilled
assertEquals(ILPSolverStatus.OPTIMAL, ret.status());
assertEquals(0, Math.abs(ret.objectiveValue()));
assertEquals(0, Math.abs(ret.objectiveValue()), GlobalTestConfig.DELTA_OBJ);
}
@Test
@ -84,7 +85,7 @@ public class GipslAllBuildImplicationTest extends AGipslAllBuildTest {
// No mapping possible, but constraint is not applied due to missing substrate
// node
assertEquals(ILPSolverStatus.OPTIMAL, ret.status());
assertEquals(0, Math.abs(ret.objectiveValue()));
assertEquals(0, Math.abs(ret.objectiveValue()), GlobalTestConfig.DELTA_OBJ);
}
}

View file

@ -7,6 +7,7 @@ import org.emoflon.gips.core.ilp.ILPSolverStatus;
import org.junit.jupiter.api.Test;
import gipsl.all.build.not.connector.NotConnector;
import test.suite.gips.GlobalTestConfig;
public class GipslAllBuildNotTest extends AGipslAllBuildTest {
@ -29,7 +30,7 @@ public class GipslAllBuildNotTest extends AGipslAllBuildTest {
assertEquals(ILPSolverStatus.OPTIMAL, ret.status());
// v1 must not be mapped because it is forbidden by a constraint
assertEquals(0, Math.abs(ret.objectiveValue()));
assertEquals(0, Math.abs(ret.objectiveValue()), GlobalTestConfig.DELTA_OBJ);
}
}

View file

@ -7,6 +7,7 @@ import org.emoflon.gips.core.ilp.ILPSolverStatus;
import org.junit.jupiter.api.Test;
import gipsl.all.build.objective.max.connector.ObjectiveMaxConnector;
import test.suite.gips.GlobalTestConfig;
public class GipslAllBuildObjectiveMaxTest extends AGipslAllBuildTest {
@ -30,7 +31,7 @@ public class GipslAllBuildObjectiveMaxTest extends AGipslAllBuildTest {
assertEquals(ILPSolverStatus.OPTIMAL, ret.status());
// All mappings chosen according to objective goal
assertEquals(2, ret.objectiveValue());
assertEquals(2, ret.objectiveValue(), GlobalTestConfig.DELTA_OBJ);
}
@Test
@ -45,7 +46,7 @@ public class GipslAllBuildObjectiveMaxTest extends AGipslAllBuildTest {
assertEquals(ILPSolverStatus.OPTIMAL, ret.status());
// All mappings chosen according to objective goal
assertEquals(3, ret.objectiveValue());
assertEquals(3, ret.objectiveValue(), GlobalTestConfig.DELTA_OBJ);
}
@Test
@ -61,7 +62,7 @@ public class GipslAllBuildObjectiveMaxTest extends AGipslAllBuildTest {
assertEquals(ILPSolverStatus.OPTIMAL, ret.status());
// All mappings chosen according to objective goal
assertEquals(4, ret.objectiveValue());
assertEquals(4, ret.objectiveValue(), GlobalTestConfig.DELTA_OBJ);
}
@Test
@ -73,7 +74,7 @@ public class GipslAllBuildObjectiveMaxTest extends AGipslAllBuildTest {
// No mappings chosen according to objective goal
// Objective is -0.0 -> Math.asb(...) fixes this for the test
assertEquals(0, Math.abs(ret.objectiveValue()));
assertEquals(0, Math.abs(ret.objectiveValue()), GlobalTestConfig.DELTA_OBJ);
}
@Test
@ -85,7 +86,7 @@ public class GipslAllBuildObjectiveMaxTest extends AGipslAllBuildTest {
// No mappings chosen according to objective goal
// Objective is -0.0 -> Math.asb(...) fixes this for the test
assertEquals(0, Math.abs(ret.objectiveValue()));
assertEquals(0, Math.abs(ret.objectiveValue()), GlobalTestConfig.DELTA_OBJ);
}
}

View file

@ -7,6 +7,7 @@ import org.emoflon.gips.core.ilp.ILPSolverStatus;
import org.junit.jupiter.api.Test;
import gipsl.all.build.objective.min.connector.ObjectiveMinConnector;
import test.suite.gips.GlobalTestConfig;
public class GipslAllBuildObjectiveMinTest extends AGipslAllBuildTest {
@ -31,7 +32,7 @@ public class GipslAllBuildObjectiveMinTest extends AGipslAllBuildTest {
assertEquals(ILPSolverStatus.OPTIMAL, ret.status());
// No mappings chosen according to objective goal
assertEquals(0, ret.objectiveValue());
assertEquals(0, ret.objectiveValue(), GlobalTestConfig.DELTA_OBJ);
}
@Test
@ -46,7 +47,7 @@ public class GipslAllBuildObjectiveMinTest extends AGipslAllBuildTest {
assertEquals(ILPSolverStatus.OPTIMAL, ret.status());
// No mappings chosen according to objective goal
assertEquals(0, ret.objectiveValue());
assertEquals(0, ret.objectiveValue(), GlobalTestConfig.DELTA_OBJ);
}
@Test
@ -62,7 +63,7 @@ public class GipslAllBuildObjectiveMinTest extends AGipslAllBuildTest {
assertEquals(ILPSolverStatus.OPTIMAL, ret.status());
// No mappings chosen according to objective goal
assertEquals(0, ret.objectiveValue());
assertEquals(0, ret.objectiveValue(), GlobalTestConfig.DELTA_OBJ);
}
// Negative
@ -75,7 +76,7 @@ public class GipslAllBuildObjectiveMinTest extends AGipslAllBuildTest {
final ILPSolverOutput ret = con.run(OUTPUT_PATH);
// No mappings chosen because there are no matches
assertEquals(0, ret.objectiveValue());
assertEquals(0, ret.objectiveValue(), GlobalTestConfig.DELTA_OBJ);
}
@Test
@ -86,7 +87,7 @@ public class GipslAllBuildObjectiveMinTest extends AGipslAllBuildTest {
final ILPSolverOutput ret = con.run(OUTPUT_PATH);
// No mappings chosen because there are no matches
assertEquals(0, ret.objectiveValue());
assertEquals(0, ret.objectiveValue(), GlobalTestConfig.DELTA_OBJ);
}
}

View file

@ -7,6 +7,7 @@ import org.emoflon.gips.core.ilp.ILPSolverStatus;
import org.junit.jupiter.api.Test;
import gips.all.build.objective.connector.ObjectiveConnector;
import test.suite.gips.GlobalTestConfig;
public class GipslAllBuildObjectiveTest extends AGipslAllBuildTest {
@ -32,7 +33,7 @@ public class GipslAllBuildObjectiveTest extends AGipslAllBuildTest {
+ 1 - 9 + 10 / 10;
final double refObjB = 500;
final double refGlobal = 2 * refObjA + 73 + 2 * refObjB;
assertEquals(refGlobal, ret.objectiveValue());
assertEquals(refGlobal, ret.objectiveValue(), GlobalTestConfig.DELTA_OBJ);
}
@Test
@ -47,7 +48,7 @@ public class GipslAllBuildObjectiveTest extends AGipslAllBuildTest {
// No matches -> Only static value of 73 + 2 * obj on class root
final double refObjB = 500;
final double refGlobal = 2 * refObjB + 73;
assertEquals(refGlobal, ret.objectiveValue());
assertEquals(refGlobal, ret.objectiveValue(), GlobalTestConfig.DELTA_OBJ);
}
}

View file

@ -7,6 +7,7 @@ import org.emoflon.gips.core.ilp.ILPSolverStatus;
import org.junit.jupiter.api.Test;
import gipsl.all.build.or.connector.OrAConnector;
import test.suite.gips.GlobalTestConfig;
public class GipslAllBuildOrATest extends AGipslAllBuildTest {
@ -30,7 +31,7 @@ public class GipslAllBuildOrATest extends AGipslAllBuildTest {
final ILPSolverOutput ret = con.run(OUTPUT_PATH);
assertEquals(ILPSolverStatus.OPTIMAL, ret.status());
assertEquals(1, Math.abs(ret.objectiveValue()));
assertEquals(1, Math.abs(ret.objectiveValue()), GlobalTestConfig.DELTA_OBJ);
}
@Test
@ -43,7 +44,7 @@ public class GipslAllBuildOrATest extends AGipslAllBuildTest {
final ILPSolverOutput ret = con.run(OUTPUT_PATH);
assertEquals(ILPSolverStatus.OPTIMAL, ret.status());
assertEquals(2, Math.abs(ret.objectiveValue()));
assertEquals(2, Math.abs(ret.objectiveValue()), GlobalTestConfig.DELTA_OBJ);
}
@Test
@ -58,7 +59,7 @@ public class GipslAllBuildOrATest extends AGipslAllBuildTest {
assertEquals(ILPSolverStatus.OPTIMAL, ret.status());
// Three mappings valid because of the constraint(s) (>=1)
assertEquals(3, Math.abs(ret.objectiveValue()));
assertEquals(3, Math.abs(ret.objectiveValue()), GlobalTestConfig.DELTA_OBJ);
}
// Negative tests
@ -73,7 +74,7 @@ public class GipslAllBuildOrATest extends AGipslAllBuildTest {
// No virtual node match -> problem must be feasible, because the constraint
// is defined with <= 2
assertEquals(ILPSolverStatus.OPTIMAL, ret.status());
assertEquals(0, Math.abs(ret.objectiveValue()));
assertEquals(0, Math.abs(ret.objectiveValue()), GlobalTestConfig.DELTA_OBJ);
}
@Test
@ -86,7 +87,7 @@ public class GipslAllBuildOrATest extends AGipslAllBuildTest {
// No substrate node match -> problem must be feasible, because the constraint
// is defined on class SubstrateNode
assertEquals(ILPSolverStatus.OPTIMAL, ret.status());
assertEquals(0, Math.abs(ret.objectiveValue()));
assertEquals(0, Math.abs(ret.objectiveValue()), GlobalTestConfig.DELTA_OBJ);
}
}

View file

@ -7,6 +7,7 @@ import org.emoflon.gips.core.ilp.ILPSolverStatus;
import org.junit.jupiter.api.Test;
import gipsl.all.build.or.b.connector.OrBConnector;
import test.suite.gips.GlobalTestConfig;
public class GipslAllBuildOrBTest extends AGipslAllBuildTest {
@ -30,7 +31,7 @@ public class GipslAllBuildOrBTest extends AGipslAllBuildTest {
final ILPSolverOutput ret = con.run(OUTPUT_PATH);
assertEquals(ILPSolverStatus.OPTIMAL, ret.status());
assertEquals(1, Math.abs(ret.objectiveValue()));
assertEquals(1, Math.abs(ret.objectiveValue()), GlobalTestConfig.DELTA_OBJ);
}
@Test
@ -43,7 +44,7 @@ public class GipslAllBuildOrBTest extends AGipslAllBuildTest {
final ILPSolverOutput ret = con.run(OUTPUT_PATH);
assertEquals(ILPSolverStatus.OPTIMAL, ret.status());
assertEquals(2, Math.abs(ret.objectiveValue()));
assertEquals(2, Math.abs(ret.objectiveValue()), GlobalTestConfig.DELTA_OBJ);
}
@Test
@ -58,7 +59,7 @@ public class GipslAllBuildOrBTest extends AGipslAllBuildTest {
assertEquals(ILPSolverStatus.OPTIMAL, ret.status());
// Two mappings valid because of the constraint(s) (<=2)
assertEquals(2, Math.abs(ret.objectiveValue()));
assertEquals(2, Math.abs(ret.objectiveValue()), GlobalTestConfig.DELTA_OBJ);
}
@Test
@ -74,7 +75,7 @@ public class GipslAllBuildOrBTest extends AGipslAllBuildTest {
assertEquals(ILPSolverStatus.OPTIMAL, ret.status());
// Two mappings valid because of the constraint(s) (<=2)
assertEquals(2, Math.abs(ret.objectiveValue()));
assertEquals(2, Math.abs(ret.objectiveValue()), GlobalTestConfig.DELTA_OBJ);
}
// Negative tests
@ -89,7 +90,7 @@ public class GipslAllBuildOrBTest extends AGipslAllBuildTest {
// No virtual node match -> problem must be feasible, because the constraint
// is defined with <= 2
assertEquals(ILPSolverStatus.OPTIMAL, ret.status());
assertEquals(0, Math.abs(ret.objectiveValue()));
assertEquals(0, Math.abs(ret.objectiveValue()), GlobalTestConfig.DELTA_OBJ);
}
@Test
@ -102,7 +103,7 @@ public class GipslAllBuildOrBTest extends AGipslAllBuildTest {
// No substrate node match -> problem must be feasible, because the constraint
// is defined on class SubstrateNode
assertEquals(ILPSolverStatus.OPTIMAL, ret.status());
assertEquals(0, Math.abs(ret.objectiveValue()));
assertEquals(0, Math.abs(ret.objectiveValue()), GlobalTestConfig.DELTA_OBJ);
}
}

View file

@ -7,6 +7,7 @@ import org.emoflon.gips.core.ilp.ILPSolverStatus;
import org.junit.jupiter.api.Test;
import gipsl.all.build.simple.connector.SimpleConnector;
import test.suite.gips.GlobalTestConfig;
public class GipslAllBuildSimpleAddTest extends AGipslAllBuildTest {
@ -29,7 +30,7 @@ public class GipslAllBuildSimpleAddTest extends AGipslAllBuildTest {
final ILPSolverOutput ret = con.run(OUTPUT_PATH);
assertEquals(ILPSolverStatus.OPTIMAL, ret.status());
assertEquals(1 * 2 + 1, ret.objectiveValue());
assertEquals(1 * 2 + 1, ret.objectiveValue(), GlobalTestConfig.DELTA_OBJ);
}
@Test
@ -42,7 +43,7 @@ public class GipslAllBuildSimpleAddTest extends AGipslAllBuildTest {
final ILPSolverOutput ret = con.run(OUTPUT_PATH);
assertEquals(ILPSolverStatus.OPTIMAL, ret.status());
assertEquals(2 * 2 + 1, ret.objectiveValue());
assertEquals(2 * 2 + 1, ret.objectiveValue(), GlobalTestConfig.DELTA_OBJ);
}
@Test
@ -56,7 +57,7 @@ public class GipslAllBuildSimpleAddTest extends AGipslAllBuildTest {
final ILPSolverOutput ret = con.run(OUTPUT_PATH);
assertEquals(ILPSolverStatus.OPTIMAL, ret.status());
assertEquals(10 * 2 + 1, ret.objectiveValue());
assertEquals(10 * 2 + 1, ret.objectiveValue(), GlobalTestConfig.DELTA_OBJ);
}
@Test
@ -70,7 +71,7 @@ public class GipslAllBuildSimpleAddTest extends AGipslAllBuildTest {
final ILPSolverOutput ret = con.run(OUTPUT_PATH);
assertEquals(ILPSolverStatus.OPTIMAL, ret.status());
assertEquals(2 * 2 + 1, ret.objectiveValue());
assertEquals(2 * 2 + 1, ret.objectiveValue(), GlobalTestConfig.DELTA_OBJ);
}
@Test
@ -85,7 +86,7 @@ public class GipslAllBuildSimpleAddTest extends AGipslAllBuildTest {
final ILPSolverOutput ret = con.run(OUTPUT_PATH);
assertEquals(ILPSolverStatus.OPTIMAL, ret.status());
assertEquals(2 * 2 + 1, ret.objectiveValue());
assertEquals(2 * 2 + 1, ret.objectiveValue(), GlobalTestConfig.DELTA_OBJ);
}
// Negative tests
@ -123,7 +124,7 @@ public class GipslAllBuildSimpleAddTest extends AGipslAllBuildTest {
// Status must be optimal because constraint is placed on matches (not on
// objects)
assertEquals(ILPSolverStatus.OPTIMAL, ret.status());
assertEquals(0 + 1, ret.objectiveValue());
assertEquals(0 + 1, ret.objectiveValue(), GlobalTestConfig.DELTA_OBJ);
}
@Test

View file

@ -8,6 +8,7 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import gipsl.all.build.simple.connector.SimpleConnector;
import test.suite.gips.GlobalTestConfig;
import test.suite.gipsl.all.build.utils.AllBuildModelGenerator;
public class GipslAllBuildSmokeTest extends AGipslAllBuildTest {
@ -24,7 +25,7 @@ public class GipslAllBuildSmokeTest extends AGipslAllBuildTest {
public void testCreateOutput() {
final ILPSolverOutput ret = con.run(OUTPUT_PATH);
assertEquals(ILPSolverStatus.OPTIMAL, ret.status());
assertEquals(0 + 1, ret.objectiveValue());
assertEquals(0 + 1, ret.objectiveValue(), GlobalTestConfig.DELTA_OBJ);
}
}

View file

@ -7,6 +7,7 @@ import org.emoflon.gips.core.ilp.ILPSolverStatus;
import org.junit.jupiter.api.Test;
import gipsl.all.build.xor.connector.XorConnector;
import test.suite.gips.GlobalTestConfig;
public class GipslAllBuildXorTest extends AGipslAllBuildTest {
@ -30,7 +31,7 @@ public class GipslAllBuildXorTest extends AGipslAllBuildTest {
assertEquals(ILPSolverStatus.OPTIMAL, ret.status());
// One mapping must be chosen
assertEquals(1, Math.abs(ret.objectiveValue()));
assertEquals(1, Math.abs(ret.objectiveValue()), GlobalTestConfig.DELTA_OBJ);
}
@Test
@ -45,7 +46,7 @@ public class GipslAllBuildXorTest extends AGipslAllBuildTest {
assertEquals(ILPSolverStatus.OPTIMAL, ret.status());
// Only one of the three matches must be embedded because of the XOR constraint
assertEquals(1, Math.abs(ret.objectiveValue()));
assertEquals(1, Math.abs(ret.objectiveValue()), GlobalTestConfig.DELTA_OBJ);
}
@Test
@ -69,7 +70,7 @@ public class GipslAllBuildXorTest extends AGipslAllBuildTest {
// No mapping must be chosen but status must be optimal
assertEquals(ILPSolverStatus.OPTIMAL, ret.status());
assertEquals(0, Math.abs(ret.objectiveValue()));
assertEquals(0, Math.abs(ret.objectiveValue()), GlobalTestConfig.DELTA_OBJ);
}
}