All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.automatalib.util.automata.copy.AutomatonCopy Maven / Gradle / Ivy

Go to download

This artifact provides various common utility operations for analyzing and manipulating automata and graphs, such as traversal, minimization and copying.

There is a newer version: 0.11.0
Show newest version
/* 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 inputs,
			MutableAutomaton out,
			Mapping inputsMapping,
			Mapping spMapping,
			Mapping tpMapping) {
		PlainAutomatonCopy copy = new PlainAutomatonCopy<>(in, inputs, out, inputsMapping, spMapping, tpMapping);
		copy.doCopy();
		return copy.stateMapping;
	}
	
	public static 
	Mapping copyPlain(Automaton in,
			Collection inputs,
			MutableAutomaton out,
			Mapping spMapping,
			Mapping tpMapping) {
		return copyPlain(in, inputs, out, Mappings.identity(), spMapping, tpMapping);
	}
	
	public static 
	Mapping copyUniversalPlain(UniversalAutomaton in,
			Collection inputs,
			MutableAutomaton out,
			Mapping inputsMapping,
			Mapping spConversion,
			Mapping tpConversion) {
		Mapping spMapping = Mappings.compose(TS.stateProperties(in), spConversion);
		Mapping tpMapping = Mappings.compose(TS.transitionProperties(in), tpConversion);
		return copyPlain(in, inputs, out, inputsMapping, spMapping, tpMapping);
	}
	
	public static 
	Mapping copyUniversalPlain(UniversalAutomaton in,
			Collection inputs,
			MutableAutomaton out,
			Mapping spConversion,
			Mapping tpConversion) {
		return copyUniversalPlain(in, inputs, out, Mappings.identity(), spConversion, tpConversion);
	}
	
	public static 
	Mapping copyUniversalPlain(UniversalAutomaton in,
			Collection inputs,
			MutableAutomaton out,
			Mapping inputsMapping) {
		return copyPlain(in, inputs, out, inputsMapping, TS.stateProperties(in), TS.transitionProperties(in));
	}
	
	public static 
	Mapping copyUniversalPlain(UniversalAutomaton in,
			Collection 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 inputs,
			MutableAutomaton out,
			Mapping inputsMapping,
			Mapping spMapping,
			Mapping 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 inputs,
			MutableAutomaton out,
			Mapping spMapping,
			Mapping tpMapping) {
		return copyTraversal(TraversalOrder.DEPTH_FIRST, TSTraversal.NO_LIMIT, in, inputs, out, Mappings.identity(), spMapping, tpMapping);
	}
	
	public static 
	Mapping copyUniversalDfs(UniversalTransitionSystem in,
			Collection inputs,
			MutableAutomaton out,
			Mapping inputsMapping,
			Mapping spConversion,
			Mapping tpConversion) {
		Mapping spMapping = Mappings.compose(TS.stateProperties(in), spConversion);
		Mapping 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 inputs,
			MutableAutomaton out,
			Mapping spConversion,
			Mapping tpConversion) {
		return copyUniversalDfs(in, inputs, out, Mappings.identity(), spConversion, tpConversion);
	}
	
	public static 
	Mapping copyUniversalDfs(UniversalTransitionSystem in,
			Collection inputs,
			MutableAutomaton out,
			Mapping 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 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() {
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy