Search in sources :

Example 11 with Edge

use of com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge in project Dat3M by hernanponcedeleon.

the class AcyclicityConstraint method getViolations.

@Override
public List<List<Edge>> getViolations() {
    if (violatingSccs.isEmpty()) {
        return Collections.emptyList();
    }
    List<List<Edge>> cycles = new ArrayList<>();
    // (3) remove chords and normalize cycle order (starting from element with smallest id)
    for (Set<Integer> scc : violatingSccs) {
        MaterializedSubgraphView subgraph = new MaterializedSubgraphView(constrainedGraph, scc);
        Set<Integer> nodes = new HashSet<>(Sets.intersection(scc, markedNodes));
        while (!nodes.isEmpty()) {
            int e = nodes.stream().findAny().get();
            List<Edge> cycle = PathAlgorithm.findShortestPath(subgraph, e, e);
            cycle = new ArrayList<>(cycle);
            cycle.forEach(edge -> nodes.remove(edge.getFirst()));
            // TODO: Most cycles have chords, so a specialized algorithm that avoids
            // chords altogether would be great
            reduceChordsAndNormalize(cycle);
            if (!cycles.contains(cycle)) {
                cycles.add(cycle);
            }
        }
    }
    return cycles;
}
Also used : MaterializedSubgraphView(com.dat3m.dartagnan.solver.caat.predicates.misc.MaterializedSubgraphView) Edge(com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge)

Example 12 with Edge

use of com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge in project Dat3M by hernanponcedeleon.

the class CoherenceGraph method edgeIterator.

@Override
public Iterator<Edge> edgeIterator(int id, EdgeDirection dir) {
    EventData e = getEvent(id);
    if (!e.isWrite()) {
        return Collections.emptyIterator();
    }
    com.google.common.base.Function<EventData, Edge> mapping = dir == EdgeDirection.INGOING ? (event -> new Edge(event.getId(), id)) : (event -> new Edge(id, event.getId()));
    return Iterators.transform(getCoSuccessorList(e, dir).iterator(), mapping);
}
Also used : java.util(java.util) Stream(java.util.stream.Stream) EventData(com.dat3m.dartagnan.verification.model.EventData) BigInteger(java.math.BigInteger) StreamSupport(java.util.stream.StreamSupport) Function(java.util.function.Function) Spliterator(java.util.Spliterator) Edge(com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge) Iterators(com.google.common.collect.Iterators) EdgeDirection(com.dat3m.dartagnan.solver.caat.misc.EdgeDirection) Edge(com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge) EventData(com.dat3m.dartagnan.verification.model.EventData)

Example 13 with Edge

use of com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge in project Dat3M by hernanponcedeleon.

the class CoherenceGraph method edgeStream.

@Override
public Stream<Edge> edgeStream(int id, EdgeDirection dir) {
    EventData e = getEvent(id);
    if (!e.isWrite()) {
        return Stream.empty();
    }
    Function<EventData, Edge> mapping = dir == EdgeDirection.INGOING ? (event -> new Edge(event.getId(), id)) : (event -> new Edge(id, event.getId()));
    return getCoSuccessorList(e, dir).stream().map(mapping);
}
Also used : java.util(java.util) Stream(java.util.stream.Stream) EventData(com.dat3m.dartagnan.verification.model.EventData) BigInteger(java.math.BigInteger) StreamSupport(java.util.stream.StreamSupport) Function(java.util.function.Function) Spliterator(java.util.Spliterator) Edge(com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge) Iterators(com.google.common.collect.Iterators) EdgeDirection(com.dat3m.dartagnan.solver.caat.misc.EdgeDirection) Edge(com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge) EventData(com.dat3m.dartagnan.verification.model.EventData)

Example 14 with Edge

use of com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge in project Dat3M by hernanponcedeleon.

the class InternalGraph method edgeStream.

@Override
public Stream<Edge> edgeStream(int id, EdgeDirection dir) {
    EventData e = getEvent(id);
    Function<EventData, Edge> edgeMapping = dir == EdgeDirection.OUTGOING ? (x -> new Edge(id, x.getId())) : (x -> new Edge(x.getId(), id));
    return threadEventsMap.get(e.getThread()).stream().map(edgeMapping);
}
Also used : IntStream(java.util.stream.IntStream) List(java.util.List) Stream(java.util.stream.Stream) EventData(com.dat3m.dartagnan.verification.model.EventData) Map(java.util.Map) Thread(com.dat3m.dartagnan.program.Thread) Function(java.util.function.Function) Edge(com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge) EdgeDirection(com.dat3m.dartagnan.solver.caat.misc.EdgeDirection) Edge(com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge) EventData(com.dat3m.dartagnan.verification.model.EventData)

Example 15 with Edge

use of com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge in project Dat3M by hernanponcedeleon.

the class LocationGraph method edgeStream.

@Override
public Stream<Edge> edgeStream(int id, EdgeDirection dir) {
    EventData e = getEvent(id);
    if (!e.isMemoryEvent()) {
        return Stream.empty();
    }
    Function<EventData, Edge> edgeMapping = dir == EdgeDirection.OUTGOING ? (x -> new Edge(id, x.getId())) : (x -> new Edge(x.getId(), id));
    return addrEventsMap.get(e.getAccessedAddress()).stream().map(edgeMapping);
}
Also used : java.util(java.util) Stream(java.util.stream.Stream) EventData(com.dat3m.dartagnan.verification.model.EventData) BigInteger(java.math.BigInteger) Function(java.util.function.Function) Edge(com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge) EdgeDirection(com.dat3m.dartagnan.solver.caat.misc.EdgeDirection) Edge(com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge) EventData(com.dat3m.dartagnan.verification.model.EventData)

Aggregations

Edge (com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge)22 EventData (com.dat3m.dartagnan.verification.model.EventData)10 EdgeDirection (com.dat3m.dartagnan.solver.caat.misc.EdgeDirection)7 Stream (java.util.stream.Stream)6 java.util (java.util)5 Function (java.util.function.Function)5 Thread (com.dat3m.dartagnan.program.Thread)3 BigInteger (java.math.BigInteger)3 RelationGraph (com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.RelationGraph)2 Element (com.dat3m.dartagnan.solver.caat.predicates.sets.Element)2 Conjunction (com.dat3m.dartagnan.utils.logic.Conjunction)2 Iterators (com.google.common.collect.Iterators)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Map (java.util.Map)2 Spliterator (java.util.Spliterator)2 IntStream (java.util.stream.IntStream)2 StreamSupport (java.util.stream.StreamSupport)2 Event (com.dat3m.dartagnan.program.event.core.Event)1 RMWStore (com.dat3m.dartagnan.program.event.core.rmw.RMWStore)1