Index: trunk/EventBenchCore/src/de/ugoe/cs/eventbench/data/Event.java
===================================================================
--- trunk/EventBenchCore/src/de/ugoe/cs/eventbench/data/Event.java	(revision 6)
+++ trunk/EventBenchCore/src/de/ugoe/cs/eventbench/data/Event.java	(revision 7)
@@ -4,5 +4,8 @@
 
 public class Event<T> {
-
+	
+	public static final Event<Object> STARTEVENT = new Event<Object>("START");
+	public static final Event<Object> ENDEVENT = new Event<Object>("END");
+	
 	/**
 	 * <p>
Index: trunk/EventBenchCore/src/de/ugoe/cs/eventbench/ppm/PredictionByPartialMatch.java
===================================================================
--- trunk/EventBenchCore/src/de/ugoe/cs/eventbench/ppm/PredictionByPartialMatch.java	(revision 6)
+++ trunk/EventBenchCore/src/de/ugoe/cs/eventbench/ppm/PredictionByPartialMatch.java	(revision 7)
@@ -1,5 +1,4 @@
 package de.ugoe.cs.eventbench.ppm;
 
-import java.util.ArrayList;
 import java.util.LinkedHashSet;
 import java.util.LinkedList;
@@ -10,48 +9,59 @@
 import de.ugoe.cs.eventbench.data.Event;
 import de.ugoe.cs.eventbench.markov.IncompleteMemory;
-import de.ugoe.cs.util.console.Console;
 
 public class PredictionByPartialMatch {
 	
-	private String initialSymbol = "GS";
-	private String endSymbol = "GE";
-	
 	private int maxOrder = 3;
 	
-	private Trie<String> trie;
-	
-	private Set<String> knownSymbols;
-	
-	private double probEscape = 0.2d; // TODO getter/setter - steering parameter!
-	
-	private Random r = new Random(); // TODO should be defined in the constructor
+	private Trie<Event<?>> trie;
+	
+	private Set<Event<?>> knownSymbols;
+	
+	private double probEscape;
+	
+	private final Random r;
+	
+	public PredictionByPartialMatch(Random r) {
+		this(r, 0.1);
+	}
+	
+	public PredictionByPartialMatch(Random r, double probEscape) {
+		this.r = r; // TODO defensive copy instead?
+		this.probEscape = probEscape;
+	}
+	
+	public void setProbEscape(double probEscape) {
+		this.probEscape = probEscape;
+	}
+	
+	public double getProbEscape() {
+		return probEscape;
+	}
 	
 	// the training is basically the generation of the trie
 	public void train(List<List<Event<?>>> sequences) {
-		trie = new Trie<String>();
-		knownSymbols = new LinkedHashSet<String>();
-		knownSymbols.add(initialSymbol);
-		knownSymbols.add(endSymbol);
+		trie = new Trie<Event<?>>();
+		knownSymbols = new LinkedHashSet<Event<?>>();
+		knownSymbols.add(Event.STARTEVENT);
+		knownSymbols.add(Event.ENDEVENT);
 		
 		for(List<Event<?>> sequence : sequences) {
-			List<String> stringSequence = new LinkedList<String>();
-			stringSequence.add(initialSymbol);
-			for( Event<?> event : sequence ) {
-				stringSequence.add(event.getStandardId());
-			}
-			stringSequence.add(endSymbol);
+			List<Event<?>> currentSequence = new LinkedList<Event<?>>(sequence); // defensive copy
+			currentSequence.add(0, Event.STARTEVENT);
+			currentSequence.add(Event.ENDEVENT);
 			
-			trainStringTrie(stringSequence);
-		}
-	}
-	
-	private void trainStringTrie(List<String> sequence) {
-		knownSymbols = new LinkedHashSet<String>();		
-		IncompleteMemory<String> latestActions = new IncompleteMemory<String>(maxOrder);
+			addToTrie(currentSequence);
+		}
+	}
+	
+	private void addToTrie(List<Event<?>> sequence) {
+		if( knownSymbols==null ) {
+			knownSymbols = new LinkedHashSet<Event<?>>();
+		}
+		IncompleteMemory<Event<?>> latestActions = new IncompleteMemory<Event<?>>(maxOrder);
 		int i=0;
-		for(String currentAction : sequence) {
-			String currentId = currentAction;
-			latestActions.add(currentId);
-			knownSymbols.add(currentId);
+		for(Event<?> currentEvent : sequence) {
+			latestActions.add(currentEvent);
+			knownSymbols.add(currentEvent);
 			i++;
 			if( i>=maxOrder ) {
@@ -65,25 +75,28 @@
 	}
 	
-	// TODO needs to be changed from String to <? extends Event>
-	public List<String> randomSequence() {
-		List<String> sequence = new LinkedList<String>();
-		
-		IncompleteMemory<String> context = new IncompleteMemory<String>(maxOrder-1);
-		context.add(initialSymbol);
-		sequence.add(initialSymbol);
-		
-		String currentState = initialSymbol;
-		
-		Console.println(currentState);
-		while(!endSymbol.equals(currentState)) {
+	public List<? extends Event<?>> randomSequence() {
+		List<Event<?>> sequence = new LinkedList<Event<?>>();
+		
+		IncompleteMemory<Event<?>> context = new IncompleteMemory<Event<?>>(maxOrder-1);
+		context.add(Event.STARTEVENT);
+		
+		Event<?> currentState = Event.STARTEVENT;
+		
+		boolean endFound = false;
+		
+		while(!endFound) {
 			double randVal = r.nextDouble();
 			double probSum = 0.0;
-			List<String> currentContext = context.getLast(maxOrder);
-			for( String symbol : knownSymbols ) {
+			List<Event<?>> currentContext = context.getLast(maxOrder);
+			for( Event<?> symbol : knownSymbols ) {
 				probSum += getProbability(currentContext, symbol);
 				if( probSum>=randVal ) {
-					context.add(symbol);
-					currentState = symbol;
-					sequence.add(currentState);
+					endFound = (symbol==Event.ENDEVENT);
+					if( !(symbol==Event.STARTEVENT || symbol==Event.ENDEVENT) ) {
+						// only add the symbol the sequence if it is not START or END
+						context.add(symbol);
+						currentState = symbol;
+						sequence.add(currentState);
+					}
 					break;
 				}
@@ -93,15 +106,15 @@
 	}
 		
-	private double getProbability(List<String> context, String symbol) {
+	private double getProbability(List<Event<?>> context, Event<?> symbol) {
 		double result = 0.0d;
 		double resultCurrentContex = 0.0d;
 		double resultShorterContex = 0.0d;
 		
-		List<String> contextCopy = new LinkedList<String>(context); // defensive copy
-
-	
-		List<String> followers = trie.getFollowingSymbols(contextCopy); // \Sigma'
+		List<Event<?>> contextCopy = new LinkedList<Event<?>>(context); // defensive copy
+
+	
+		List<Event<?>> followers = trie.getFollowingSymbols(contextCopy); // \Sigma'
 		int sumCountFollowers = 0; // N(s\sigma')
-		for( String follower : followers ) {
+		for( Event<?> follower : followers ) {
 			sumCountFollowers += trie.getCount(contextCopy, follower);
 		}
@@ -130,4 +143,5 @@
 	}
 	
+	/*
 	public void testStuff() {
 		// basically an inline unit test without assertions but manual observation
@@ -151,11 +165,4 @@
 		model.trainStringTrie(list);
 		model.trie.display();
-		Console.println("------------------------");
-		model.randomSequence();/*
-		Console.println("------------------------");
-		model.randomSequence();
-		Console.println("------------------------");
-		model.randomSequence();
-		Console.println("------------------------");*/
 		
 		List<String> context = new ArrayList<String>();
@@ -204,4 +211,4 @@
 		context.add("a");
 		Console.traceln(""+model.getProbability(context, "z"));
-	}
+	}*/
 }
