本文整理汇总了C#中CharSetSolver.SaveAsDot方法的典型用法代码示例。如果您正苦于以下问题:C# CharSetSolver.SaveAsDot方法的具体用法?C# CharSetSolver.SaveAsDot怎么用?C# CharSetSolver.SaveAsDot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CharSetSolver
的用法示例。
在下文中一共展示了CharSetSolver.SaveAsDot方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WS1SSingleton
public void WS1SSingleton()
{
var solver = new CharSetSolver(BitWidth.BV64); //new solver using ASCII encoding
List<char> alph = new List<char> { 'a', 'b' };
HashSet<char> al = new HashSet<char>(alph);
WS1SFormula f1 = new WS1SSingleton("X");
WS1SFormula phi = new WS1SExists("X", f1);
var dfa = phi.getDFA(al, solver);
var test = solver.Convert(@"^(a|b)+$").Determinize(solver).Minimize(solver);
string file = "../../../MSOZ3Test/DotFiles/singletona";
solver.SaveAsDot(dfa, "aut", file); //extension .dot is added automatically when missing
Assert.IsTrue(dfa.IsEquivalentWith(test, solver));
}
示例2: WS1SSucc
public void WS1SSucc()
{
var solver = new CharSetSolver(BitWidth.BV64); //new solver using ASCII encoding
List<char> alph = new List<char> { 'a', 'b' };
HashSet<char> al = new HashSet<char>(alph);
WS1SFormula f3 = new WS1SSucc("X", "Y");
WS1SFormula phi = new WS1SExists("X", new WS1SExists("Y", f3));
var dfa = phi.getDFA(al, solver);
var test = solver.Convert(@"^(a|b){2,}$");
string file = "../../../MSOZ3Test/DotFiles/containsab";
solver.SaveAsDot(dfa, "aut", file); //extension .dot is added automatically when missing
Assert.IsTrue(dfa.IsEquivalentWith(test, solver));
}
示例3: MSOLast
public void MSOLast()
{
var solver = new CharSetSolver(BitWidth.BV64); //new solver using ASCII encoding
List<char> alph = new List<char> { 'a', 'b' };
HashSet<char> al = new HashSet<char>(alph);
//ex x. first(x)
MSOFormula formula = new MSOExistsFO("x", new MSOLast("x"));
Assert.IsTrue(formula.CheckUseOfVars());
var dfa = formula.getDFA(al, solver);
var test = solver.Convert(@"^(a|b)+$");
Assert.IsTrue(dfa.IsEquivalentWith(test, solver));
string file = "../../../MSOZ3Test/DotFiles/exlast";
solver.SaveAsDot(dfa, "aut", file); //extension .dot is added automatically when missing
}
示例4: Grade2DFAs
public void Grade2DFAs()
{
var solver = new CharSetSolver(BitWidth.BV64);
List<char> alph = new List<char> { 'a', 'b' };
HashSet<char> al = new HashSet<char>(alph);
PDLPred phi = new PDLAnd(new PDLIntGeq(new PDLIndicesOf("a"), 2), new PDLIntGeq(new PDLIndicesOf("b"), 2));
//PDLPred phi2 = new PDLIf(new PDLStartsWith("b"), new PDLEndsWith("b"));
var dfaCorr = phi.GetDFA(al, solver);
var a = solver.MkCharConstraint(false, 'a');
var b = solver.MkCharConstraint(false, 'b');
var moves = new List<Move<BDD>>();
moves.Add(new Move<BDD>(0, 1, a));
moves.Add(new Move<BDD>(0, 1, b));
moves.Add(new Move<BDD>(1, 2, a));
moves.Add(new Move<BDD>(1, 2, b));
moves.Add(new Move<BDD>(2, 3, a));
moves.Add(new Move<BDD>(2, 3, b));
moves.Add(new Move<BDD>(3,3, a));
moves.Add(new Move<BDD>(3, 3, b));
//moves.Add(new Move<BDD>(3, 4, a));
//moves.Add(new Move<BDD>(3, 2, b));
//moves.Add(new Move<BDD>(4, 4, a));
//moves.Add(new Move<BDD>(4, 5, b));
//moves.Add(new Move<BDD>(5, 6, a));
//moves.Add(new Move<BDD>(5, 4, b));
//moves.Add(new Move<BDD>(6, 6, a));
//moves.Add(new Move<BDD>(6, 6, b));
var dfa2 = Automaton<BDD>.Create(0, new int[] { 3 }, moves);
//Assert.IsTrue(phi2.GetDFA(al,solver).IsEquivalentWith(dfa2,solver));
solver.SaveAsDot(dfaCorr, "aa", "corr");
solver.SaveAsDot(dfa2, "aa", "wrong");
//var v0 = DFADensity.GetDFADifferenceRatio(dfa1, dfa2, al, solver);
//var v1 = PDLEditDistance.GetMinimalFormulaEditDistanceRatio(dfa1, dfa2, al, solver, timeout);
//var v2 = DFAEditDistance.GetDFAOptimalEdit(dfa1, dfa2, al, solver, 4, new StringBuilder());
//Console.WriteLine("density ratio: {0}; pdl edit distance: {1}; dfa edit distance: {2}", v0, v1, v2);
var gr = DFAGrading.GetGrade(dfaCorr, dfa2, al, solver, 2000, 10, FeedbackLevel.Hint, true, true, true);
Console.WriteLine(gr.First);
foreach (var f in gr.Second)
Console.WriteLine(f.ToString());
}
示例5: MSOaafterb
public void MSOaafterb()
{
var solver = new CharSetSolver(BitWidth.BV64); //new solver using ASCII encoding
List<char> alph = new List<char> { 'a', 'b' };
HashSet<char> al = new HashSet<char>(alph);
MSOFormula formula = new MSOForallFO("x1",
new MSOIf(
new MSOLabel("x1", 'b'),
new MSOExistsFO("x2",
new MSOAnd(
new MSOLess("x1", "x2"),
new MSOLabel("x2", 'a')))));
Assert.IsTrue(formula.CheckUseOfVars());
var WS1S = formula.ToWS1S(solver);
var dfa = WS1S.getDFA(al, solver);
var timer = new Stopwatch();
var tt = 100;
var acc = 0L;
for (int k = 0; k < tt; k++)
{
timer.Reset();
timer.Start();
dfa = WS1S.getDFA(al, solver);
timer.Stop();
acc += timer.ElapsedMilliseconds;
}
Console.WriteLine("time: " + acc / tt + " ms");
//var test = solver.Convert(@"^(a|b)$");
//Assert.IsTrue(dfa.IsEquivalentWith(test, solver));
string file = "../../../MSOZ3Test/DotFiles/aafterb";
solver.SaveAsDot(dfa, "aut", file); //extension .dot is added automatically when missing
}
示例6: MSOForall
public void MSOForall()
{
var solver = new CharSetSolver(BitWidth.BV64); //new solver using ASCII encoding
List<char> alph = new List<char> { 'a', 'b' };
int a2 = 'a' * 2;
int b2 = 'b' * 2;
List<char> alph2 = new List<char> { (char)a2, (char)b2, (char)(a2+1), (char)(b2+1) };
HashSet<char> al = new HashSet<char>(alph);
//ex x. all y. x<=y and a(x)
MSOFormula formula = new MSOForallFO("x",
new MSOLabel("x", 'b'));
Assert.IsTrue(formula.CheckUseOfVars());
var dfa = formula.getDFA(al, solver);
var test = solver.Convert(@"^b*$");
Assert.IsTrue(dfa.IsEquivalentWith(test, solver));
string file = "../../../MSOZ3Test/DotFiles/bstar";
solver.SaveAsDot(dfa, "aut", file); //extension .dot is added automatically when missing
}
示例7: CreateDotFiles
//create dotfiles for all attempts
private static void CreateDotFiles(int probId)
{
string fromDir = "C:/Users/Dileep/Desktop/Attempts/" + probId + "/";
string toDir = "C:/Users/Dileep/Desktop/Graded/" + probId + "/";
Directory.CreateDirectory(toDir);
var files = Directory.GetFiles(fromDir, "*.xml", System.IO.SearchOption.AllDirectories);
string outputFile;
foreach (string inputFile in files)
{
outputFile = toDir + Path.GetFileNameWithoutExtension(inputFile);
var solver = new CharSetSolver(BitWidth.BV64);
try
{
var aut = DFAUtilities.parseDFAfromEvent(inputFile, solver);
solver.SaveAsDot(aut.Second, "second", outputFile);
}
catch (System.FormatException e)
{
Console.WriteLine("EXCEPTION: {0}", e);
Console.WriteLine("Failed: {0}", Path.GetFileNameWithoutExtension(inputFile));
}
}
}
示例8: WS1SFormula
public void WS1SFormula()
{
var solver = new CharSetSolver(BitWidth.BV64); //new solver using ASCII encoding
List<char> alph = new List<char> { 'a', 'b' };
HashSet<char> al = new HashSet<char>(alph);
WS1SFormula f1 = new WS1SUnaryPred("X", solver.MkCharConstraint(false, 'a'));
WS1SFormula f2 = new WS1SUnaryPred("Y", solver.MkCharConstraint(false, 'b'));
WS1SFormula f3 = new WS1SSucc("X", "Y");
WS1SFormula phi = new WS1SAnd(new WS1SAnd(f1, f2), f3);
WS1SFormula psi = new WS1SSucc("Y", "Z");
WS1SFormula formula = new WS1SExists("X", new WS1SExists("Y",
new WS1SAnd(phi, new WS1SNot(new WS1SExists("Z", psi)))));
StringBuilder sb = new StringBuilder();
formula.ToString(sb);
Console.WriteLine(sb.ToString());
var dfa = formula.getDFA(al, solver);
var test = solver.Convert(@"^(a|b)*ab$");
string file = "../../../MSOZ3Test/DotFiles/endsinab";
solver.SaveAsDot(dfa, "aut", file); //extension .dot is added automatically when missing
Assert.IsTrue(dfa.IsEquivalentWith(test, solver));
}
示例9: WS1SSubset
public void WS1SSubset()
{
var solver = new CharSetSolver(BitWidth.BV64); //new solver using ASCII encoding
List<char> alph = new List<char> { 'a', 'b' };
HashSet<char> al = new HashSet<char>(alph);
WS1SFormula f1 = new WS1SUnaryPred("X", solver.MkCharConstraint(false, 'a'));
WS1SFormula f2 = new WS1SUnaryPred("Y1", solver.MkCharConstraint(false, 'b'));
WS1SFormula f3 = new WS1SUnaryPred("Z", solver.MkCharConstraint(false, 'a'));
WS1SFormula f = new WS1SAnd(f1, new WS1SAnd(f2, f3));
WS1SFormula s1 = new WS1SSucc("X", "Y1");
WS1SFormula s2 = new WS1SSucc("Y2", "Z");
WS1SFormula s3 = new WS1SSubset("Y1", "Y2");
WS1SFormula s = new WS1SAnd(new WS1SAnd(s1, s2), s3);
WS1SFormula phi = new WS1SExists("X",
new WS1SExists("Y1",
new WS1SExists("Y2",
new WS1SExists("Z",
new WS1SAnd(f, s)))));
WS1SFormula phit = new WS1SExists("X",
new WS1SExists("Y",
new WS1SSubset("X", "Y")));
var dd = phit.getDFA(al, solver);
//solver.SaveAsDot(phit.getDFA(al, solver), "bla","bla.dot");
var dfa = phi.getDFA(al, solver);
var test = solver.Convert(@"^(a|b)*aba(a|b)*$");
Assert.IsTrue(dfa.IsEquivalentWith(test, solver));
string file = "../../../MSOZ3Test/DotFiles/aba";
solver.SaveAsDot(dfa, "aut", file); //extension .dot is added automatically when missing
}
示例10: WS1SNot
public void WS1SNot()
{
var solver = new CharSetSolver(BitWidth.BV64); //new solver using ASCII encoding
List<char> alph = new List<char> { 'a', 'b' };
HashSet<char> al = new HashSet<char>(alph);
WS1SFormula f1 = new WS1SUnaryPred("X", solver.MkCharConstraint(false, 'a'));
WS1SFormula f2 = new WS1SSingleton("X");
WS1SFormula f = new WS1SAnd(f1, f2);
WS1SFormula phi = new WS1SNot(new WS1SExists("X", f));
var dfa = phi.getDFA(al, solver);
var test = solver.Convert(@"^b*$");
Assert.IsTrue(dfa.IsEquivalentWith(test, solver));
string file = "../../../MSOZ3Test/DotFiles/nota";
solver.SaveAsDot(dfa, "aut", file); //extension .dot is added automatically when missing
}