本文整理汇总了C#中CharSetSolver.PrettyPrint方法的典型用法代码示例。如果您正苦于以下问题:C# CharSetSolver.PrettyPrint方法的具体用法?C# CharSetSolver.PrettyPrint怎么用?C# CharSetSolver.PrettyPrint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CharSetSolver
的用法示例。
在下文中一共展示了CharSetSolver.PrettyPrint方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ChooseTest2
public void ChooseTest2()
{
CharSetSolver solver = new CharSetSolver(BitWidth.BV16);
BDD set1 = solver.MkRangeConstraint('a', 'a', true);
string set1str = solver.PrettyPrint(set1);
BDD set2 = solver.MkRangeConstraint('a', 'a');
string set2str = solver.PrettyPrint(set2);
BDD set3 = solver.MkRangeConstraint('A', 'A');
string set3str = solver.PrettyPrint(set3);
BDD set1a = solver.MkOr(set2, set3);
Assert.AreEqual<string>("[Aa]", set1str);
Assert.AreEqual<string>("a", set2str);
Assert.AreEqual<string>("A", set3str);
}
示例2: ChooseTest
public void ChooseTest()
{
for (int i = 0; i < 10; i++)
{
CharSetSolver solver = new CharSetSolver(BitWidth.BV16);
BDD set1 = solver.MkRangeConstraint('a', 'c', true);
string set1str = solver.PrettyPrint(set1);
BDD set2 = solver.MkRangeConstraint('a', 'c');
string set2str = solver.PrettyPrint(set2);
BDD set3 = solver.MkRangeConstraint( 'A', 'C');
string set3str = solver.PrettyPrint(set3);
BDD set1a = solver.MkOr(set2, set3);
Assert.AreEqual<string>("[A-Ca-c]",set1str);
Assert.AreEqual<string>("[a-c]", set2str);
Assert.AreEqual<string>("[A-C]", set3str);
int h1 = set1.GetHashCode();
int h2 = set1a.GetHashCode();
bool same = (h1 == h2);
Assert.AreSame(set1, set1a);
Assert.IsTrue(same);
Assert.IsTrue(solver.AreEquivalent(set1, set1a));
//int seed = solver.Chooser.RandomSeed;
char choice1 = (char)solver.Choose(set1);
char choice2 = (char)solver.Choose(set1);
char choice3 = (char)solver.Choose(set1);
char choice4 = (char)solver.Choose(set1);
//solver.Chooser.RandomSeed = seed;
//char choice1a = solver.Choose(set1a);
//char choice2a = solver.Choose(set1a);
//char choice3a = solver.Choose(set1a);
//char choice4a = solver.Choose(set1a);
//string s = new String(new char[] { choice1, choice2, choice3, choice4 });
//string sa = new String(new char[] { choice1a, choice2a, choice3a, choice4a });
//Assert.AreEqual<string>(s, sa);
}
}
示例3: ChooseUnifromlyTest
public void ChooseUnifromlyTest()
{
CharSetSolver solver = new CharSetSolver(BitWidth.BV16);
BDD set1 = solver.MkRangeConstraint('\0', '\x01', true);
BDD set2 = solver.MkRangeConstraint( '\u0FFF', '\u0FFF');
string set2str = solver.PrettyPrint(set2);
BDD set3 = solver.MkRangeConstraint( '\u00FF', '\u00FF');
BDD set4 = solver.MkRangeConstraint( '\u000F', '\u000F');
BDD set = solver.MkOr(new BDD[]{set2, set3, set4, set1});
string setstr = solver.PrettyPrint(set);
set.ToDot(@"foo.dot");
var map = new Dictionary<char, int>();
map['\0'] = 0;
map['\x01'] = 0;
map['\u0FFF'] = 0;
map['\u00FF'] = 0;
map['\u000F'] = 0;
for (int i = 0; i < 50000; i++)
{
var c = solver.ChooseUniformly(set);
map[c] += 1;
}
foreach (var kv in map)
Assert.IsTrue(kv.Value > 9700);
}
示例4: PrintEpsilon
private string PrintEpsilon(BvSet cond, CharSetSolver slvr)
{
if (cond == null)
{
return "E";
}
else return slvr.PrettyPrint(cond);
}
示例5: BuildAutomaton
//.........这里部分代码省略.........
transitions.Add(transition);
}
else if (edgeLabels[e] == "C")
{
int[] transition = new int[4];
transition[0] = e.Item1;
transition[1] = 67; // ASCII C
transition[2] = 67;
transition[3] = e.Item2;
transitions.Add(transition);
}
else if (edgeLabels[e] == "B")
{
int[] transition = new int[4];
transition[0] = e.Item1;
transition[1] = 66; // ASCII B
transition[2] = 66;
transition[3] = e.Item2;
transitions.Add(transition);
}
else if (edgeLabels[e] == "E")
{
int[] transition = new int[4];
transition[0] = e.Item1;
transition[1] = -1;
transition[2] = -1;
transition[3] = e.Item2;
transitions.Add(transition);
}
}
#if (DEBUG && !DEBUG_DETAIL)
Console.Write(" \n Transitions before EPSILONS are added\n ");
for (int i = 0; i < transitions.Count; i++)
{
int[] trans = transitions[i];
Console.Write("\n From : " + trans[0].ToString() + "--- " + trans[1] + " --- " + " to : " + trans[3].ToString());
}
#endif
#if DEBUG && !DEBUG_DETAIL
Console.WriteLine(" ******* Printing initial states\n");
foreach (int inits in initialStates) {
Console.WriteLine("initial state is " + inits.ToString());
}
#endif
// get final states
int[] finalSts = ComputeFinalStates(finalStates);
#if DEBUG && !DEBUG_DETAIL
Console.WriteLine("\n*****Printing Finals states\n");
foreach (int finals in finalSts)
{
Console.WriteLine(" final state " + finals.ToString());
}
#endif
int dummyInitial = Math.Abs(Guid.NewGuid().GetHashCode());
foreach (int s in initialStates)
{
int[] transition = new int[4];
transition[0] = dummyInitial;
transition[1] = -1;
transition[2] = -1;
transition[3] = s;
transitions.Add(transition);
}
#if (DEBUG && !DEBUG_DETAIL)
Console.Write(" \n Transitions are\n ");
for (int i = 0; i < transitions.Count; i++)
{
int[] trans = transitions[i];
Console.Write("\n From : " + trans[0].ToString() + "--- " + trans[1] + " --- " + " to : " + trans[3].ToString());
}
#endif
var solver = new CharSetSolver(BitWidth.BV7);
// create Automaton
Automaton<BvSet> yieldTypeCheckAutomaton = solver.ReadFromRanges(dummyInitial, finalSts, transitions);
#if DEBUG && !DEBUG_DETAIL
Console.WriteLine("\n--Implementation Automaton--");
foreach (var move in yieldTypeCheckAutomaton.GetMoves()) {
Console.WriteLine("\n "+ move.SourceState.ToString() + " -- " + this.PrintEpsilon(move.Condition,solver)+ " --> " + move.TargetState.ToString() +" \n");
}
string implAutomatonGraphName = ytypeChecked.Proc.Name + "phaseNum__" + yTypeCheckCurrentPhaseNum.ToString();
solver.ShowGraph(yieldTypeCheckAutomaton, implAutomatonGraphName+".dmgl");
#endif
#if DEBUG && !DEBUG_DETAIL
Console.WriteLine("\n--Epsilons Reduced Automaton--");
foreach (var move in epsilonReducedAtutomaton.GetMoves()) {
Console.WriteLine("\n "+ move.SourceState.ToString() + " -- " + solver.PrettyPrint(move.Condition)+ " --> " + move.TargetState.ToString() +" \n");
}
#endif
return yieldTypeCheckAutomaton;
}