net.automatalib.util.automata.copy.AutomatonCopy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of automata-util Show documentation
Show all versions of automata-util Show documentation
This artifact provides various common utility operations for analyzing and manipulating
automata and graphs, such as traversal, minimization and copying.
/* Copyright (C) 2013 TU Dortmund
* This file is part of AutomataLib, http://www.automatalib.net/.
*
* AutomataLib is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 3.0 as published by the Free Software Foundation.
*
* AutomataLib is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with AutomataLib; if not, see
* http://www.gnu.de/documents/lgpl.en.html.
*/
package net.automatalib.util.automata.copy;
import java.util.Collection;
import net.automatalib.automata.Automaton;
import net.automatalib.automata.MutableAutomaton;
import net.automatalib.automata.UniversalAutomaton;
import net.automatalib.commons.util.mappings.Mapping;
import net.automatalib.commons.util.mappings.Mappings;
import net.automatalib.ts.TransitionSystem;
import net.automatalib.ts.UniversalTransitionSystem;
import net.automatalib.util.traversal.TraversalOrder;
import net.automatalib.util.ts.TS;
import net.automatalib.util.ts.traversal.TSTraversal;
public abstract class AutomatonCopy {
public static
Mapping copyPlain(Automaton in,
Collection extends I1> inputs,
MutableAutomaton out,
Mapping super I1,? extends I2> inputsMapping,
Mapping super S1,? extends SP2> spMapping,
Mapping super T1,? extends TP2> tpMapping) {
PlainAutomatonCopy copy = new PlainAutomatonCopy<>(in, inputs, out, inputsMapping, spMapping, tpMapping);
copy.doCopy();
return copy.stateMapping;
}
public static
Mapping copyPlain(Automaton in,
Collection extends I1> inputs,
MutableAutomaton out,
Mapping super S1,? extends SP2> spMapping,
Mapping super T1,? extends TP2> tpMapping) {
return copyPlain(in, inputs, out, Mappings.identity(), spMapping, tpMapping);
}
public static
Mapping copyUniversalPlain(UniversalAutomaton in,
Collection extends I1> inputs,
MutableAutomaton out,
Mapping super I1,? extends I2> inputsMapping,
Mapping super SP1,? extends SP2> spConversion,
Mapping super TP1,? extends TP2> tpConversion) {
Mapping super S1,? extends SP2> spMapping = Mappings.compose(TS.stateProperties(in), spConversion);
Mapping super T1,? extends TP2> tpMapping = Mappings.compose(TS.transitionProperties(in), tpConversion);
return copyPlain(in, inputs, out, inputsMapping, spMapping, tpMapping);
}
public static
Mapping copyUniversalPlain(UniversalAutomaton in,
Collection extends I1> inputs,
MutableAutomaton out,
Mapping super SP1,? extends SP2> spConversion,
Mapping super TP1,? extends TP2> tpConversion) {
return copyUniversalPlain(in, inputs, out, Mappings.identity(), spConversion, tpConversion);
}
public static
Mapping copyUniversalPlain(UniversalAutomaton in,
Collection extends I1> inputs,
MutableAutomaton out,
Mapping super I1,? extends I2> inputsMapping) {
return copyPlain(in, inputs, out, inputsMapping, TS.stateProperties(in), TS.transitionProperties(in));
}
public static
Mapping copyUniversalPlain(UniversalAutomaton in,
Collection extends I1> inputs,
MutableAutomaton out) {
return copyPlain(in, inputs, out, Mappings.identity(), TS.stateProperties(in), TS.transitionProperties(in));
}
public static
Mapping copyTraversal(
TraversalOrder order,
int limit,
TransitionSystem in,
Collection extends I1> inputs,
MutableAutomaton out,
Mapping super I1,? extends I2> inputsMapping,
Mapping super S1,? extends SP2> spMapping,
Mapping super T1,? extends TP2> tpMapping) {
TraversalAutomatonCopy copy = new TraversalAutomatonCopy<>(order, limit, in, inputs, out, inputsMapping, spMapping, tpMapping);
copy.doCopy();
return copy.stateMapping;
}
public static
Mapping copyDfs(TransitionSystem in,
Collection extends I1> inputs,
MutableAutomaton out,
Mapping super S1,? extends SP2> spMapping,
Mapping super T1,? extends TP2> tpMapping) {
return copyTraversal(TraversalOrder.DEPTH_FIRST, TSTraversal.NO_LIMIT, in, inputs, out, Mappings.identity(), spMapping, tpMapping);
}
public static
Mapping copyUniversalDfs(UniversalTransitionSystem in,
Collection extends I1> inputs,
MutableAutomaton out,
Mapping super I1,? extends I2> inputsMapping,
Mapping super SP1,? extends SP2> spConversion,
Mapping super TP1,? extends TP2> tpConversion) {
Mapping super S1,? extends SP2> spMapping = Mappings.compose(TS.stateProperties(in), spConversion);
Mapping super T1,? extends TP2> tpMapping = Mappings.compose(TS.transitionProperties(in), tpConversion);
return copyTraversal(TraversalOrder.DEPTH_FIRST, TSTraversal.NO_LIMIT, in, inputs, out, inputsMapping, spMapping, tpMapping);
}
public static
Mapping copyUniversalDfs(UniversalTransitionSystem in,
Collection extends I1> inputs,
MutableAutomaton out,
Mapping super SP1,? extends SP2> spConversion,
Mapping super TP1,? extends TP2> tpConversion) {
return copyUniversalDfs(in, inputs, out, Mappings.identity(), spConversion, tpConversion);
}
public static
Mapping copyUniversalDfs(UniversalTransitionSystem in,
Collection extends I1> inputs,
MutableAutomaton out,
Mapping super I1,? extends I2> inputsMapping) {
return copyTraversal(TraversalOrder.DEPTH_FIRST, TSTraversal.NO_LIMIT, in, inputs, out, inputsMapping, TS.stateProperties(in), TS.transitionProperties(in));
}
public static
Mapping copyUniversalDfs(UniversalTransitionSystem in,
Collection extends I1> inputs,
MutableAutomaton out) {
return copyTraversal(TraversalOrder.DEPTH_FIRST, TSTraversal.NO_LIMIT, in, inputs, out, Mappings.identity(), TS.stateProperties(in), TS.transitionProperties(in));
}
// TODO: Traversal copy
private AutomatonCopy() {
}
}