本文整理汇总了C#中CharSetSolver.IsSatisfiable方法的典型用法代码示例。如果您正苦于以下问题:C# CharSetSolver.IsSatisfiable方法的具体用法?C# CharSetSolver.IsSatisfiable怎么用?C# CharSetSolver.IsSatisfiable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CharSetSolver
的用法示例。
在下文中一共展示了CharSetSolver.IsSatisfiable方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetClosestElement
//.........这里部分代码省略.........
Pold[S, T] = int.MaxValue;
P1[S, T] = false;
foreach (var c in chars)
Lold[c][S, T] = false;
}
}
}
}
#endregion
//solver.ShowGraph(automaton,"as");
//Inductive step
for(int k=1;k<=bound;k++){
foreach (var stT in automaton.States)
{
var T = stToInd[stT];
foreach (var stS in automaton.States)
{
var S = stToInd[stS];
if (Pold[S, T] == int.MaxValue)
{
bool found=false;
foreach (var move in automaton.GetMovesFrom(stS))
{
var stk = move.TargetState;
var K = stToInd[stk];
if (Pold[K, T] != int.MaxValue)
if (P1[S, K])
{
found = true;
Pnew[S, T] = Pold[K, T] + 1;
foreach (var c in chars)
Lnew[c][S, T] = Lold[c][K, T] || solver.IsSatisfiable(solver.MkAnd(move.Label,solver.MkCharConstraint(c)));
}
}
if (!found)
{
Pnew[S, T] = Pold[S, T];
foreach (var c in chars)
Lnew[c][S, T] = Lold[c][S, T];
}
}
else
{
Pnew[S, T] = Pold[S, T];
foreach (var c in chars)
Lnew[c][S, T] = Lold[c][S, T];
}
}
}
Pold = Pnew;
Pnew=new int[states.Length, states.Length];
foreach (var c in chars)
Lold[c] = Lnew[c];
Lnew = new Dictionary<char, bool[,]>();
foreach (var c in chars)
Lnew[c] = new bool[states.Length, states.Length];
}
//Initialize table for value 0
Pair<int, int>[,] F = new Pair<int, int>[maxl, automaton.StateCount];
foreach (var st in automaton.States)
示例2: MoveFromStoTContainsC
//check if delta(S,T,c) exists
static bool MoveFromStoTContainsC(char c, int S, int T, Automaton<BDD> aut, CharSetSolver solver, out char witness)
{
var ccond = solver.MkCharConstraint(c);
foreach (var move in aut.GetMovesFrom(S))
if (move.TargetState == T)
{
if (solver.IsSatisfiable(solver.MkAnd(move.Label, ccond)))
{
witness = c;
return true;
}
else
foreach (var w in solver.GenerateAllCharacters(move.Label, false))
{
witness = w;
return true;
}
}
witness = c;
return false;
}
示例3: ComputeModels
internal static void ComputeModels(
string currStr, int currState,
Automaton<BDD> dfa, List<int> finalStates, HashSet<char> alphabet, CharSetSolver solver,
List<string> positive, List<string> negative)
{
if (currStr.Length >= 8)
return;
if (currState == -1 || !finalStates.Contains(currState))
negative.Add(currStr);
else
positive.Add(currStr);
foreach (char ch in alphabet)
{
if (currState == -1)
ComputeModels(currStr + ch, currState, dfa, finalStates, alphabet, solver, positive, negative);
else
{
bool found = false;
foreach (var move in dfa.GetMovesFrom(currState))
{
if (solver.IsSatisfiable(solver.MkAnd(move.Label, solver.MkCharConstraint(false, ch))))
{
found = true;
ComputeModels(currStr + ch, move.TargetState, dfa, finalStates, alphabet, solver, positive, negative);
break;
}
}
if (!found)
ComputeModels(currStr + ch, -1, dfa, finalStates, alphabet, solver, positive, negative);
}
}
}
示例4: GetNextState
// returns the state reached from currState when reading c
private static int GetNextState(int currState, char c, Automaton<BDD> dfa, CharSetSolver solver)
{
foreach (var move in dfa.GetNonepsilonMovesFrom(currState))
if (solver.IsSatisfiable(solver.MkAnd(move.Label, solver.MkCharConstraint(false, c))))
return move.TargetState;
return -1;
}
示例5: GetDFAEditScriptTimeout
// looks for an edit at depth "depth"
// returns false and null in bestScript if no edit is found at depth "depth"
// returns false and not null in bestScript if found
// returns true if timeout
internal static bool GetDFAEditScriptTimeout(
Automaton<BDD> dfa1, Automaton<BDD> dfa2,
HashSet<char> al, CharSetSolver solver,
List<long> editScriptHash, List<DFAEdit> editList,
int depth, long timeout, Stopwatch sw,
Pair<IEnumerable<string>, IEnumerable<string>> tests,
double dfa1density,
int totalCost,
DFAEditScript bestScript, Dictionary<int, int> stateNamesMapping)
{
// check timer
if (sw.ElapsedMilliseconds > timeout)
return true;
//Compute worst case distance, call finalScript with this value?
int dist = (dfa1.StateCount + dfa2.StateCount) * (al.Count + 1);
//Stop if no more moves left
if (depth == 0)
{
if (DFAUtilities.ApproximateMNEquivalent(tests, dfa1density, dfa2, al, solver) && dfa2.IsEquivalentWith(dfa1, solver))
//check if totalCost < finalScript cost and replace if needed
if (bestScript.script == null || totalCost < bestScript.GetCost())
bestScript.script = ObjectCopier.Clone<List<DFAEdit>>(editList);
return false;
}
DFAEdit edit = null;
#region Flip one move target state
foreach (var move in dfa2.GetMoves())
{
//Creaty copy of the moves without current move
var movesWithoutCurrMove = dfa2.GetMoves().ToList();
movesWithoutCurrMove.Remove(move);
//Redirect every ch belonging to move condition
foreach (var c in solver.GenerateAllCharacters(move.Label, false))
{
long hash = IntegerUtil.PairToInt(move.SourceState, c - 97) + dfa2.StateCount;
if (CanAdd(hash, editScriptHash))
{
editScriptHash.Insert(0, hash);
//Local copy of moves
var newMoves = movesWithoutCurrMove.ToList();
var newMoveCondition = solver.MkCharConstraint(false, c);
#region Remove ch from current move
var andCond = solver.MkAnd(move.Label, solver.MkNot(newMoveCondition));
//add back move without ch iff satisfiable
if (solver.IsSatisfiable(andCond))
newMoves.Add(new Move<BDD>(move.SourceState, move.TargetState, andCond));
#endregion
#region Redirect c to a different state
foreach (var state in dfa2.States)
if (state != move.TargetState)
{
var newMovesComplete = newMoves.ToList();
newMovesComplete.Add(new Move<BDD>(move.SourceState, state, newMoveCondition));
var dfa2new = Automaton<BDD>.Create(dfa2.InitialState, dfa2.GetFinalStates(), newMovesComplete);
edit = new DFAEditMove(stateNamesMapping[move.SourceState], stateNamesMapping[state], c);
editList.Insert(0, edit);
if (GetDFAEditScriptTimeout(dfa1, dfa2new, al, solver, editScriptHash, editList, depth - 1, timeout, sw, tests, dfa1density, totalCost + edit.GetCost(), bestScript, stateNamesMapping))
return true;
editList.RemoveAt(0);
}
#endregion
editScriptHash.RemoveAt(0);
}
}
}
#endregion
#region Flip one state from fin to non fin
foreach (var state in dfa2.States)
{
if (CanAdd(state, editScriptHash))
{
//flip its final non final status
editScriptHash.Insert(0, state);
var newFinalStates = new HashSet<int>(dfa2.GetFinalStates());
Automaton<BDD> dfa2new = null;
if (dfa2.GetFinalStates().Contains(state))
{
edit = new DFAEditState(stateNamesMapping[state], false);
editList.Insert(0, edit);
newFinalStates.Remove(state);
dfa2new = Automaton<BDD>.Create(dfa2.InitialState, newFinalStates, dfa2.GetMoves());
}
//.........这里部分代码省略.........