public bool Startup() { if (zeroState == null) { return(false); } zeroState.Do(zeroState); State <T> stateFrom = zeroState; State <T> stateTo = null; var ts = new List <Transition <T> >(GetTransitionStartingWith(stateFrom)); if (QuantifierDefault == Quantifier.LAZY) { while (ts.Count() > 0) { bool r = false; var tc = ts[0]; foreach (var t in ts) { double weight; r = t.Trace(stateFrom, t.StateTo, out weight); if (r) { stateTo = t.StateTo; tc = t; break; } } if (r) { tc.Do(stateFrom, stateTo); stateTo.Do(stateTo); stateFrom = stateTo; ts = new List <Transition <T> >(GetTransitionStartingWith(stateFrom)); } else { return(false); } } } else if (QuantifierDefault == Quantifier.GREEDY) { while (ts.Count() > 0) { double bestWeight = double.NegativeInfinity; bool r = false; var tc = ts[0]; foreach (var t in ts) { double weight; r = t.Trace(stateFrom, t.StateTo, out weight); if (r) { if (weight > bestWeight) { bestWeight = weight; stateTo = t.StateTo; tc = t; } } } if (r) { tc.Do(stateFrom, stateTo); stateTo.Do(stateTo); stateFrom = stateTo; ts = new List <Transition <T> >(GetTransitionStartingWith(stateFrom)); } else { return(false); } } } return(true); }