Search in sources :

Example 21 with Edge

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

the class UnionGraph method forwardPropagate.

@Override
@SuppressWarnings("unchecked")
public Collection<Edge> forwardPropagate(CAATPredicate changedSource, Collection<? extends Derivable> added) {
    if (changedSource == first || changedSource == second) {
        ArrayList<Edge> newlyAdded = new ArrayList<>();
        Collection<Edge> addedEdges = (Collection<Edge>) added;
        for (Edge e : addedEdges) {
            Edge edge = derive(e);
            if (simpleGraph.add(edge)) {
                newlyAdded.add(edge);
            }
        }
        return newlyAdded;
    } else {
        return Collections.emptyList();
    }
}
Also used : Edge(com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge)

Example 22 with Edge

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

the class AcyclicityConstraint method reduceChordsAndNormalize.

private void reduceChordsAndNormalize(List<Edge> cycle) {
    // Reduces chords by iteratively merging first and last edge if possible
    // Note that edges in the middle should not have chords since
    // we start with a shortest cycle rooted at some node <e>
    // TODO: after the first merge, the two nodes of the merged edge
    // both may allow further merging but we only iteratively merge one of the two.
    boolean prog;
    do {
        if (cycle.size() == 1) {
            // Self-cycles are not reducible
            return;
        }
        prog = false;
        Edge in = cycle.get(cycle.size() - 1);
        Edge out = cycle.get(0);
        Edge chord = constrainedGraph.get(new Edge(in.getFirst(), out.getSecond()));
        if (chord != null) {
            cycle.remove(cycle.size() - 1);
            cycle.set(0, chord);
            prog = true;
        }
    } while (prog);
    // Normalize
    int first = 0;
    int minId = Integer.MAX_VALUE;
    int counter = 0;
    for (Edge e : cycle) {
        if (e.getFirst() < minId) {
            minId = e.getFirst();
            first = counter;
        }
        counter++;
    }
    Collections.rotate(cycle, -first);
}
Also used : Edge(com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge)

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