Search in sources :

Example 1 with TarjanSimpleCycles

use of org.jgrapht.alg.cycle.TarjanSimpleCycles in project bmoth by hhu-stups.

the class StateSpaceExplorationTest method testStateSpaceExploration.

@Test
public void testStateSpaceExploration() {
    machine = machineBuilder.setName("BoringMachineWithoutLoop").setVariables("x").setInvariant("x : 1..7").setInitialization("ANY p WHERE p : 1..2 THEN x := p END").addOperation("incToThree = SELECT x : 1..2 THEN x := 3 END").addOperation("incFromThree = SELECT x : 3..6 THEN x := x + 1 END").build();
    result = new ExplicitStateModelChecker(machine).check();
    assertEquals(7, result.getSteps());
    assertTrue(result.isCorrect());
    StateSpace space = result.getStateSpace();
    List<List<State>> cycles = new TarjanSimpleCycles<>(space).findSimpleCycles();
    assertEquals(0, cycles.size());
    machine = machineBuilder.setName("ExitingMachineWithLoop").addOperation("resetToThree = SELECT x = 7 THEN x := 3 END").build();
    result = new ExplicitStateModelChecker(machine).check();
    assertEquals(7, result.getSteps());
    assertTrue(result.isCorrect());
    space = result.getStateSpace();
    cycles = new TarjanSimpleCycles<>(space).findSimpleCycles();
    comparator.addExpectedCycle("{x=3}", "{x=4}", "{x=5}", "{x=6}", "{x=7}");
    comparator.addActualCycle(cycles.get(0));
    comparator.compare();
}
Also used : StateSpace(de.bmoth.modelchecker.StateSpace) List(java.util.List) TarjanSimpleCycles(org.jgrapht.alg.cycle.TarjanSimpleCycles) Test(org.junit.Test)

Aggregations

StateSpace (de.bmoth.modelchecker.StateSpace)1 List (java.util.List)1 TarjanSimpleCycles (org.jgrapht.alg.cycle.TarjanSimpleCycles)1 Test (org.junit.Test)1