// Copyright 2012 Georg-August-Universität Göttingen, Germany // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package de.ugoe.cs.autoquest.plugin.guitar; import java.util.ArrayList; import java.util.Collection; import java.util.LinkedList; import java.util.List; import java.util.Random; import de.ugoe.cs.autoquest.eventcore.Event; import de.ugoe.cs.autoquest.plugin.guitar.eventcore.GUITAREventTarget; import de.ugoe.cs.autoquest.plugin.guitar.eventcore.GUITAREventType; import de.ugoe.cs.autoquest.plugin.guitar.eventcore.GUITARReplayable; import de.ugoe.cs.autoquest.usageprofiles.DeterministicFiniteAutomaton; import de.ugoe.cs.autoquest.usageprofiles.FirstOrderMarkovModel; import edu.umd.cs.guitar.model.GUITARConstants; import edu.umd.cs.guitar.model.IO; import edu.umd.cs.guitar.model.data.EFG; import edu.umd.cs.guitar.model.data.EventGraphType; import edu.umd.cs.guitar.model.data.EventType; /** *
* Provides functionality to generates models defined in the package * de.ugoe.cs.autoquest.usageprofiles from EFGs. *
* * @author Steffen Herbold * @version 1.0 */ public class EFGModelGenerator { /** ** Generates a {@link FirstOrderMarkovModel} from an EFG. In the generated * model, all following events are equally possible, i.e., the model is * equal to a {@link DeterministicFiniteAutomaton}. *
* * @param efgFileName * name of the EFG file * @return model generated from the EFG */ public FirstOrderMarkovModel efgToFirstOrderMarkovModel(String efgFileName) { EFG efg = (EFG) IO.readObjFromFile(efgFileName, EFG.class); Collection* Generates a {@link DeterministicFiniteAutomaton} from an EFG. *
* * @param efgFileName * name of the EFG file * @return model generated from the EFG */ public DeterministicFiniteAutomaton efgToDeterministicFiniteAutomaton( String efgFileName) { EFG efg = (EFG) IO.readObjFromFile(efgFileName, EFG.class); Collection* Extracts the graph structure from the EFG. The result is a set of * sequences, where each sequence has length two and represents an edge in * the EFG. *
* * @param efg * EFG for which the edge sequence set is generated * @return edge sequence set */ private Collection* Extracts creates {@link EFGEvent} for every event contained in the EFG. *
* * @param efg * EFG for which the events are created * @return list of events */ private List