private void Deck_Load(object sender, EventArgs e) { Bdd bdd = new Bdd(); /*List<Serviteur> serviteurs = bdd.LoadServiteurs(); List<Sort> sorts = bdd.LoadSorts(); List<Arme> armes = bdd.LoadArmes(); List<Label> labels = new List<Label>(); pictureBox1 = bdd.Test(); /*foreach (Serviteur serviteur in serviteurs) { Label label = new Label(); label.Text = serviteur.ToString(); labels.Add(label); } int iX = 50; int iY = 50; foreach(Label label in labels) { iY += 50; Controls.Add(label); label.Location = new Point(iX, iY); }*/ }
private void Deck_Load(object sender, EventArgs e) { Bdd bdd = new Bdd(); /*List<Serviteur> serviteurs = bdd.LoadServiteurs(); List<Sort> sorts = bdd.LoadSorts(); List<Arme> armes = bdd.LoadArmes(); pictureBox1.Image = serviteurs[0]._imageCarte;*/ }
public void PublishDocs() => Bdd.PublishDocs(CancellationToken.None);
public void Setup() => Bdd.Configure(configuration => configuration .Use(DocPublishers.GherkinFiles()));
public void Reachable(debugPrintDelegate debugPrint) { if (ProgramCFG.CfgNodes.Count <= 1) { debugPrint("Invalid Program, unable to proceed!\n"); return; } m_PathEdges.Clear(); m_SummaryEdges.Clear(); BuildTransferFunctions(); LinkedList <CFGNode> workList = new LinkedList <CFGNode>(); CFGNodeProcedure tempNodeProc; CFGNode tempNode; Bdd bddLift, bddSummaryEdges, bddNew; PathEdges bddSelfLoop, bddJoin, bddPathEdges; Bdd [] array = new Bdd[3]; foreach (CFGNode node in ProgramCFG.CfgNodes) { m_PathEdges.Add(node, new PathEdges()); m_SummaryEdges.Add(node, m_BddManager.CreateBddZero()); } ProgramCFG.ProcedureNameToNode().TryGetValue("main", out tempNodeProc); workList.AddFirst(tempNodeProc.FirstStmtOf); m_PathEdges.Remove(tempNodeProc.FirstStmtOf); PathEdges firstMain = new PathEdges(); firstMain.AddPathEdge(new PathEdgesPartition(0, HelperFunctions.BuildIdentityTransfer (m_BddManager, tempNodeProc.LocalVariables.VariablesToId, ProgramCFG.GlobalVariables.VariablesToId)), m_BddManager); m_PathEdges.Add(tempNodeProc.FirstStmtOf, firstMain); #region Debug part of the reachability algorithm /* * ///////Debug //////////// * Dictionary<string, int>.ValueCollection valCollection = tempNodeProc.LocalVariables.VariablesToId.Values; * foreach (int id in valCollection) * { * tempBdd1 = tempBdd; * tempBdd = m_BddManager.LogicalOr(tempBdd, m_BddManager.GetBddVariableWithID(id)); * tempBdd1.FreeBdd(); * tempBdd1 = tempBdd; * tempBdd = m_BddManager.LogicalXnor(tempBdd, m_BddManager.GetBddVariableWithID(id + 2)); * tempBdd1.FreeBdd(); * } * * foreach (int id in ProgramCFG.GlobalVariables.VariablesToId.Values) * { * tempBdd1 = tempBdd; * tempBdd = m_BddManager.LogicalImplies(tempBdd, m_BddManager.GetBddVariableWithID(id)); * tempBdd1.FreeBdd(); * tempBdd1 = tempBdd; * tempBdd = m_BddManager.LogicalOr(tempBdd, m_BddManager.GetBddVariableWithID(id + 2)); * tempBdd1.FreeBdd(); * } * array[0] = tempBdd; * tempBdd = m_BddManager.CreateBddOne(); * * foreach (int id in valCollection) * { * tempBdd1 = tempBdd; * tempBdd = m_BddManager.LogicalAnd(tempBdd, m_BddManager.GetBddVariableWithID(id)); * tempBdd1.FreeBdd(); * tempBdd1 = tempBdd; * tempBdd = m_BddManager.LogicalNor(tempBdd, m_BddManager.GetBddVariableWithID(id + 2)); * tempBdd1.FreeBdd(); * } * * foreach (int id in ProgramCFG.GlobalVariables.VariablesToId.Values) * { * tempBdd1 = tempBdd; * tempBdd = m_BddManager.LogicalImplies(tempBdd, m_BddManager.GetBddVariableWithID(id)); * tempBdd1.FreeBdd(); * tempBdd1 = tempBdd; * tempBdd = m_BddManager.LogicalXor(tempBdd, m_BddManager.GetBddVariableWithID(id + 2)); * tempBdd1.FreeBdd(); * } * array[1] = tempBdd; * * //array[2] = Join(array[0], array[1], tempNodeProc.LocalVariables); * array[2] = SelfLoop(array[1], tempNodeProc.LocalVariables, tempNodeProc.LocalVariables); * m_BddManager.ForceGarbageCollection(); * return array; * //////////////////////// */ #endregion while (workList.Count != 0) { tempNode = workList.First.Value; debugPrint("Processing Node: " + tempNode.ToString() + ".\n"); workList.RemoveFirst(); if (tempNode is CFGNodeStmtProcCall) { CFGNodeStmtProcCall procCall = tempNode as CFGNodeStmtProcCall; m_PathEdges.TryGetValue(tempNode, out bddPathEdges); bddJoin = Join(bddPathEdges, procCall.Transfer, procCall.ProcOf.LocalVariables); bddSelfLoop = SelfLoop(bddJoin, procCall.ProcOf.LocalVariables, (procCall.Succesor as CFGNodeStatement).ProcOf.LocalVariables); Propagate(procCall.Succesor, bddSelfLoop, workList); bddJoin.FreeAllBdd(); bddSelfLoop.FreeAllBdd(); m_PathEdges.TryGetValue(tempNode, out bddPathEdges); m_SummaryEdges.TryGetValue(tempNode, out bddSummaryEdges); if (bddSummaryEdges != null) { bddJoin = Join(bddPathEdges, bddSummaryEdges, procCall.ProcOf.LocalVariables); Propagate(procCall.ReturnPoint, bddJoin, workList); bddJoin.FreeAllBdd(); } } else if (tempNode is CFGNodeProcedure) { foreach (CFGNodeStmtSkip node in (tempNode as CFGNodeProcedure).Succesor) { bddLift = Lift(node.previousProcCall, tempNode as CFGNodeProcedure); m_SummaryEdges.TryGetValue(node.previousProcCall, out bddSummaryEdges); m_PathEdges.TryGetValue(node.previousProcCall, out bddPathEdges); if (bddSummaryEdges != null) { bddNew = m_BddManager.LogicalOr(bddLift, bddSummaryEdges); bddLift.FreeBdd(); } else { bddNew = bddLift; } if (bddSummaryEdges != bddNew) { m_SummaryEdges.Remove(node.previousProcCall); m_SummaryEdges.Add(node.previousProcCall, bddNew); bddSummaryEdges.FreeBdd(); bddJoin = Join(bddPathEdges, bddNew, (node as CFGNodeStmtSkip).previousProcCall.ProcOf.LocalVariables); Propagate(node, bddJoin, workList); bddJoin.FreeAllBdd(); } } } else if (tempNode is CFGNodeStmtConditional) { CFGNodeStmtConditional tempNode1 = tempNode as CFGNodeStmtConditional; m_PathEdges.TryGetValue(tempNode, out bddPathEdges); bddJoin = Join(bddPathEdges, tempNode1.TransferTrue, tempNode1.ProcOf.LocalVariables); Propagate(tempNode1.TrueSuccesor, bddJoin, workList); bddJoin.FreeAllBdd(); m_PathEdges.TryGetValue(tempNode, out bddPathEdges); bddJoin = Join(bddPathEdges, tempNode1.TransferFalse, tempNode1.ProcOf.LocalVariables); Propagate(tempNode1.FalseSuccesor, bddJoin, workList); bddJoin.FreeAllBdd(); } else { if (!(tempNode is CFGNodeError)) { m_PathEdges.TryGetValue(tempNode, out bddPathEdges); bddJoin = Join(bddPathEdges, (tempNode as CFGNodeStatement).Transfer, (tempNode as CFGNodeStatement).ProcOf.LocalVariables); Propagate(tempNode.Succesor, bddJoin, workList); bddJoin.FreeAllBdd(); } } } m_BddManager.ForceGarbageCollection(); }
private void Button_Click(object sender, RoutedEventArgs e) { items = Bdd.Instance().ListeClient(_idClient.Text, _nomClient.Text, _prenomClient.Text); lvUsers.ItemsSource = items; }
// open boat to move down in private Bdd OpenBoat(Bdd bs, Bdd bsp, Bdd be, Bdd bep) { Bdd OB = !bs & !bsp & !be & bep; return(OB); }
public string Run(bool fake1, bool fake2, bool fake3) { Kernel.Setup(); Bdd I, E, T, R; Bdd[] ml = new Bdd[N]; // missionaries on left side Bdd[] mr = new Bdd[N]; // missionaries on right side Bdd[] mlp = new Bdd[N]; // missionaries on left' Bdd[] mrp = new Bdd[N]; Bdd[] cl = new Bdd[N]; // cannibles on left side Bdd[] cr = new Bdd[N]; // cannibles on right side Bdd[] clp = new Bdd[N]; Bdd[] crp = new Bdd[N]; Bdd br, brp, bl, blp; // the boat on right, the boat on right', the boat one the left, etc. BddPairList pairList = new BddPairList(); // *2 because we have both missionaries and cannibals // *2 because they all have two variables for (int i = 0; i < N * 2 * 2; i++) { pairList.Add(i * 2, i * 2 + 1); } for (int i = 0; i < N; i++) { ml[i] = new Bdd(i * 8); mlp[i] = new Bdd(i * 8 + 1); mr[i] = new Bdd(i * 8 + 2); mrp[i] = new Bdd(i * 8 + 3); cl[i] = new Bdd(i * 8 + 4); clp[i] = new Bdd(i * 8 + 5); cr[i] = new Bdd(i * 8 + 6); crp[i] = new Bdd(i * 8 + 7); } bl = new Bdd(N * 8); blp = new Bdd(N * 8 + 1); pairList.Add(N * 8, N * 8 + 1); br = new Bdd(N * 8 + 2); brp = new Bdd(N * 8 + 3); pairList.Add(N * 8 + 2, N * 8 + 3); I = InitialState(mr, cr, ml, cl, bl, br); E = EndState(mr, cr, ml, cl, bl, br); T = Transitions(mr, cr, ml, cl, mrp, crp, mlp, clp, bl, blp, br, brp); R = Transition.ReachableStates(I, T, pairList); Bdd result = E >= R; int tracelength = Transition.Tracelength(I, E, T, pairList); string trace = Transition.FindTrace(I, E, T, transList, pairList, tracelength); return("R=>E-satcount: " + Kernel.SatCountVarSet(result).ToString() + Environment.NewLine + "R-satcount: " + Kernel.SatCountVarSet(R).ToString() + Environment.NewLine + "Solution: " + trace + Environment.NewLine + "Tracelength: " + tracelength); }
public void CanNotPayOverAmountAvailable() => Bdd.Scenario <Context>() .Given(c => c.AmountAvailableWas(100, Currency.PLN)) .And(c => c.DebtLimitWas(0, Currency.PLN)) .When(c => c.AccountIsCharged(101, Currency.PLN)) .Then((c, r) => c.PaymentIsRefused(r)) .Test();
public void CanPayUpToAmountAvailable() => Bdd.Scenario <Context>() .Given(c => c.AmountAvailableWas(100, Currency.PLN)) .When(c => c.AccountIsCharged(10, Currency.PLN)) .Then(c => c.AmountAvailableIs(90, Currency.PLN)) .Test();
public void NewAccountHasNoAmountAvailable() => Bdd.Scenario <Context>() .When(c => c.NewAccountIsCreated(Currency.PLN)) .Then(c => c.AmountAvailableIs(0, Currency.PLN)) .Test();
/// <summary> /// méthode permettant de remplir une combobox à partir d'une source de données /// </summary> /// <param name="UneConnexion">L'objet connexion à utiliser pour la connexion à la BD</param> /// <param name="UneCombo"> La combobox que l'on doit remplir</param> /// <param name="UneSource">Le nom de la source de données qui va fournir les données. Il s'agit en fait d'une vue de type /// VXXXXOn ou XXXX représente le nom de la tabl à partir de laquelle la vue est créée. n représente un numéro de séquence</param> public static void RemplirComboBox(Bdd UneConnexion, ComboBox UneCombo, String UneSource) { UneCombo.DataSource = UneConnexion.ObtenirDonnees(UneSource); UneCombo.DisplayMember = "LIBELLE"; UneCombo.ValueMember = "id"; }
// we are NOT using these rules /* * Regler: * * One location at a time: * ----------------------- * if m1r then !m1b & !m1l * if m2r then !m2b & !m2l * if m3r then !m3b & !m3l * * Shore rule * ---------- * if (m1r & m2r & !m3r) then * ((c1r & c2r & !c3r) | (!c1r & c2r & c3r) | (c1r & !c2r & c3r) | * (!c1r &!c2r & c3r) | (c1r & !c2r & !c3r) | (!c1r & c2r & !c3r) | * (!c1r & !c2r & !c3r)) * if (m1r & m2r & m3r) then ((c1r & c2r & c3r) & (above rule)) * * Boat rule (left) * --------- * if (m1bl & !m2bl & !m3bl) then * ((c1bl & !c2bl & !c3bl) | (!c1bl & !c2bl & c3bl) |!c1bl & c2bl & !c3bl) | * (!c1bl & !c2bl)) * if (!m1bl & !m2bl & m3b1) then * (c1bl & c2bl & !c3bl) | (!c1bl & c2bl & c3bl) | (c1bl & !c2bl & c3bl) | (above rule) * if (m1bl & m2bl & !m3b1) then * (!c1bl & !c2bl & !c3bl) * * */ public string Run() { Kernel.Setup(); Bdd I, E, T, R; Bdd[] ml = new Bdd[N]; // missionaries on left side Bdd[] mr = new Bdd[N]; // missionaries on right side Bdd[] mbr = new Bdd[N]; // missionaries on boat on right side Bdd[] mbl = new Bdd[N]; // missionaries on boat on left side Bdd[] mlp = new Bdd[N]; Bdd[] mrp = new Bdd[N]; Bdd[] mbrp = new Bdd[N]; Bdd[] mblp = new Bdd[N]; Bdd[] cl = new Bdd[N]; // cannibles on left side Bdd[] cr = new Bdd[N]; // cannibles on right side Bdd[] cbr = new Bdd[N]; // cannibles on boat on right side Bdd[] cbl = new Bdd[N]; // cannibles on boat on left side Bdd[] clp = new Bdd[N]; Bdd[] crp = new Bdd[N]; Bdd[] cbrp = new Bdd[N]; Bdd[] cblp = new Bdd[N]; Bdd br, brp, bl, blp; // the boat on right, the boat on right', the boat one the left, etc. //List<int> PreState = new List<int>(); //List<int> PostState = new List<int>(); BddPairList pairList = new BddPairList(); // *2 because we have both missionaries and cannibals // *4 because they all have four variables for (int i = 0; i < N * 2 * 4; i++) { pairList.Add(i * 2, i * 2 + 1); } //for (int i = 0; i < N*2*4; i++) //{ // PreState.Add(i * 2); // PostState.Add(i * 2 + 1); //} for (int i = 0; i < N; i++) { ml[i] = new Bdd(i * 16); mlp[i] = new Bdd(i * 16 + 1); mbl[i] = new Bdd(i * 16 + 2); mblp[i] = new Bdd(i * 16 + 3); mr[i] = new Bdd(i * 16 + 4); mrp[i] = new Bdd(i * 16 + 5); mbr[i] = new Bdd(i * 16 + 6); mbrp[i] = new Bdd(i * 16 + 7); cl[i] = new Bdd(i * 16 + 8); clp[i] = new Bdd(i * 16 + 9); cbl[i] = new Bdd(i * 16 + 10); cblp[i] = new Bdd(i * 16 + 11); cr[i] = new Bdd(i * 16 + 12); crp[i] = new Bdd(i * 16 + 13); cbr[i] = new Bdd(i * 16 + 14); cbrp[i] = new Bdd(i * 16 + 15); } bl = new Bdd(N * 16); blp = new Bdd(N * 16 + 1); pairList.Add(N * 16, N * 16 + 1); br = new Bdd(N * 16 + 2); brp = new Bdd(N * 16 + 3); pairList.Add(N * 16 + 2, N * 16 + 3); I = InitialState(mr, cr, ml, cl, mbr, cbr, mbl, cbl, bl, br); E = EndState(mr, cr, ml, cl, mbr, cbr, mbl, cbl, bl, br); T = Transitions(mr, cr, ml, cl, mbr, cbr, mbl, cbl, mrp, crp, mlp, clp, mbrp, cbrp, mblp, cblp, bl, blp, br, brp); //R = ReachableStates(I, T, PreState, PostState); R = ReachableStates(I, T, pairList); Bdd result = E & R; //BddSerializer.Serialize(R, "output2"); return("R&E-satcount: " + Kernel.SatCount(result).ToString() + Environment.NewLine + "R&E-anysat: " + Kernel.AnySat(result) + Environment.NewLine + "R-satcount: " + Kernel.SatCount(R).ToString() + Environment.NewLine + "LevelCount: " + count.ToString()); }
// bs = boat startpoint, be = boat endpoint, p = ') private Bdd LockBoat(Bdd bs, Bdd bsp, Bdd be, Bdd bep) { Bdd MB = bs & !bsp & !be & !bep; return(MB); }
// ms = missonaries startpoint (pre) // msp = missonaries startpoint (post or ') // me = missinaries endpoint (pre) // mep = missionaries endpoint (post or ') // same for cannibals // bs = boat start // be = boat end private Bdd MoveToBoat(Bdd[] ms, Bdd[] msp, Bdd[] me, Bdd[] mep, Bdd[] cs, Bdd[] csp, Bdd[] ce, Bdd[] cep, Bdd bs, Bdd bsp, Bdd be, Bdd bep) { Bdd M = new Bdd(false); Bdd LB = LockBoat(bs, bsp, be, bep); // one missionary move for (int i = 0; i < N; i++) { M = M | (ms[i] & !msp[i] & !me[i] & mep[i] & LB & Assign(ms, msp, i) & Assign(me, mep, i)); //M = M | (ms[i] & !msp[i] & mep[i] & Assign(ms, msp, i) & Assign(me, mep, i)); } // one cannibal move for (int i = 0; i < N; i++) { M = M | (cs[i] & !csp[i] & !ce[i] & cep[i] & LB & Assign(cs, csp, i) & Assign(ce, cep, i)); //M = M | (cs[i] & !csp[i] & cep[i] & Assign(cs, csp, i) & Assign(ce, cep, i)); } // two missionaries move for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { if (i != j) { M = M | (ms[i] & ms[j] & !msp[i] & !msp[j] & !me[i] & !me[j] & mep[i] & mep[j] & LB & Assign(ms, msp, i, j) & Assign(me, mep, i, j)); /*M = M | (ms[i] & ms[j] & !msp[i] & !msp[j] * & mep[i] & mep[j] * & Assign(ms, msp, i, j) & Assign(me, mep, i, j));*/ } } } // two cannibals move for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { if (i != j) { M = M | (cs[i] & cs[j] & !csp[i] & !csp[j] & !ce[i] & !ce[j] & cep[i] & cep[j] & LB & Assign(cs, csp, i, j) & Assign(ce, cep, i, j)); /*M = M | (cs[i] & cs[j] & !csp[i] & !csp[j] * & cep[i] & cep[j] * & Assign(cs, csp, i, j) & Assign(ce, cep, i, j));*/ } } } // one of each move for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { M = M | (cs[i] & ms[j] & !csp[i] & !msp[j] & !ce[i] & !me[j] & cep[i] & mep[j] & LB & Assign(ms, msp, j) & Assign(cs, csp, i)) & Assign(me, mep, j) & Assign(ce, cep, i); /*M = M | (cs[i] & ms[j] & !csp[i] & !msp[j] * & cep[i] & mep[j] * & Assign(ms, msp, j) & Assign(cs, csp, i)) * & Assign(me, mep, j) & Assign(ce, cep, i);*/ } } // boat empty Bdd emptyBoat = new Bdd(true); for (int i = 0; i < N; i++) { emptyBoat &= !me[i] & !ce[i]; } // if boat is empty then make move M = Kernel.IfThen(emptyBoat, M); return(M); }
public static Bdd BuildAssignmentTransfer(CommonAST assignAST, BddManager Manager, Dictionary <string, int> LocalVarToId, Dictionary <string, int> GlobalVarToId) { CommonAST walkerVariable = assignAST.getFirstChild() as CommonAST; CommonAST walkerExpresion = assignAST.getFirstChild() as CommonAST; while (walkerExpresion.Type == BoolParserTokenTypes.ID) { walkerExpresion = walkerExpresion.getNextSibling() as CommonAST; } walkerExpresion = walkerExpresion.getNextSibling() as CommonAST; List <int> assignedVariables = new List <int>(); Bdd transfer = null; bool bddTransferIsnull = true; while (walkerVariable.Type == BoolParserTokenTypes.ID) { Bdd tempBdd, varBdd, exprBdd; int VariableID; if (!LocalVarToId.TryGetValue(walkerVariable.getText(), out VariableID)) { if (!GlobalVarToId.TryGetValue(walkerVariable.getText(), out VariableID)) { Debug.Assert(false);//Varijabla mora biti ili medju lokalnim ili medju globalnim } } assignedVariables.Add(VariableID); varBdd = Manager.GetBddVariableWithID(VariableID + 2); exprBdd = HelperFunctions.ExprToBdd(walkerExpresion, Manager, LocalVarToId, GlobalVarToId); tempBdd = Manager.LogicalXnor(varBdd, exprBdd); varBdd.FreeBdd(); exprBdd.FreeBdd(); if (bddTransferIsnull) { transfer = tempBdd; bddTransferIsnull = false; } else { varBdd = transfer; transfer = Manager.LogicalAnd(transfer, tempBdd); varBdd.FreeBdd(); tempBdd.FreeBdd(); } walkerVariable = walkerVariable.getNextSibling() as CommonAST; walkerExpresion = walkerExpresion.getNextSibling() as CommonAST; } #region add identitiy transfer for the rest of the variables //Now we add the identity over variables that were not assigned to int[] localVariablesIDs = new int[LocalVarToId.Values.Count]; LocalVarToId.Values.CopyTo(localVariablesIDs, 0); int[] globalVariablesIDs = new int[GlobalVarToId.Values.Count]; GlobalVarToId.Values.CopyTo(globalVariablesIDs, 0); int[] unassignedVariables = new int[LocalVarToId.Values.Count + GlobalVarToId.Values.Count - assignedVariables.Count]; int unAssIndex = 0; for (int index = 0; index < LocalVarToId.Values.Count; index++) { if (!(assignedVariables.Contains(localVariablesIDs[index]))) { unassignedVariables[unAssIndex++] = localVariablesIDs[index]; } } for (int index = 0; index < GlobalVarToId.Values.Count; index++) { if (!(assignedVariables.Contains(globalVariablesIDs[index]))) { unassignedVariables[unAssIndex++] = globalVariablesIDs[index]; } } Bdd identitiy = HelperFunctions.BuildIdentityOverVariableIDs(Manager, unassignedVariables); Bdd tempBdd2 = transfer; transfer = Manager.LogicalAnd(transfer, identitiy); identitiy.FreeBdd(); tempBdd2.FreeBdd(); #endregion return(transfer); }
private Bdd ShoreRule(Bdd[] ms, Bdd[] cs, Bdd[] me, Bdd[] ce, Bdd[] msp, Bdd[] csp, Bdd[] mep, Bdd[] cep, Bdd bs, Bdd bsp, Bdd bep, string side) { Bdd rule = new Bdd(false); Bdd tempTrans; // three missionaries on a shore Bdd ThM = ThreePersonShore(ms); // two misionaries on a shore Bdd TwM = TwoPersonShore(ms); // one missinary on a shore; Bdd OM = OnePersonShore(ms); // no missionary on a shore Bdd NM = NoPersonShore(ms); // three cannibals on a shore Bdd ThC = ThreePersonShore(cs); // two cannibals on a shore Bdd TwC = TwoPersonShore(cs); // one cannibals on a shore Bdd OC = OnePersonShore(cs); // no cannibal on a shore Bdd NC = NoPersonShore(cs); // boat ready Bdd B = bs; // move one missionary Bdd MOM = MoveOne(ms, msp, me, mep, cs, csp, ce, cep, bs, bsp, bep); // move one cannibal Bdd MOC = MoveOne(cs, csp, ce, cep, ms, msp, me, mep, bs, bsp, bep); // move two missionaries Bdd MTM = MoveTwo(ms, msp, me, mep, cs, csp, ce, cep, bs, bsp, bep); // move two cannibals Bdd MTC = MoveTwo(cs, csp, ce, cep, ms, msp, me, mep, bs, bsp, bep); // move one of each Bdd MOOE = MoveOneOfEach(ms, msp, me, mep, cs, csp, ce, cep, bs, bsp, bep); // m=3 c=3 //tempTrans = Kernel.IfThen(ThM & ThC & B, MOC | MTC | MOOE); tempTrans = ThM & ThC & B & (MOC | MTC | MOOE); transList.Add(tempTrans, "33" + side); rule |= tempTrans; // m=3 c=2 //tempTrans = Kernel.IfThen(ThM & TwC & B, MOM | MOC | MTC); tempTrans = ThM & TwC & B & (MOM | MOC | MTC); transList.Add(tempTrans, "32" + side); rule |= tempTrans; // m=3 c=1 //tempTrans = Kernel.IfThen(ThM & OC & B, MOC | MTM); tempTrans = ThM & OC & B & (MOC | MTM); transList.Add(tempTrans, "31" + side); rule |= tempTrans; // m=2 c=2 //tempTrans = Kernel.IfThen(TwM & TwC & B, MTM | MOOE); tempTrans = TwM & TwC & B & (MTM | MOOE); transList.Add(tempTrans, "22" + side); rule |= tempTrans; // m=1 c=1 //tempTrans = Kernel.IfThen(OM & OC & B, MOM | MOOE); tempTrans = OM & OC & B & (MOM | MOOE); transList.Add(tempTrans, "11" + side); rule |= tempTrans; // m=0 c=3 //tempTrans = Kernel.IfThen(NM & ThC & B, MOC | MTC); tempTrans = NM & ThC & B & (MOC | MTC); transList.Add(tempTrans, "03" + side); rule |= tempTrans; // m=0 c=2 //tempTrans = Kernel.IfThen(NM & TwC & B, MOC | MTC); tempTrans = NM & TwC & B & (MOC | MTC); transList.Add(tempTrans, "02" + side); rule |= tempTrans; // m=0 c=1 //tempTrans = Kernel.IfThen(NM & OC & B, MOC); tempTrans = NM & OC & B & MOC; transList.Add(tempTrans, "01" + side); rule |= tempTrans; return(rule); }
public void RechargingIncreasesAmountAvailable() => Bdd.Scenario <Context>() .Feature(RechargingPrePaidAccount) .Given(c => c.AmountAvailableWas(100, Currency.PLN)) .When(c => c.AccountIsRecharged(10, Currency.PLN)) .Then(c => c.AmountAvailableIs(110, Currency.PLN)) .Test();
// move boat to other side private Bdd MoveBoat(Bdd bs, Bdd bsp, Bdd bep) { Bdd MB = bs & !bsp & bep; return(MB); }
public void test() { Bdd.connexion(); }
public void SendMessage([FromBody] Message requestFront) { Bdd bdd = DataBaseConnection.databaseConnection(); bdd.sendMessage(requestFront); }
// ms = missonaries startpoint (pre) // msp = missonaries startpoint (post or ') // me = missinaries endpoint (pre) // mep = missionaries endpoint (post or ') // same for cannibals // bs = boat start // be = boat end private Bdd MoveToShore(Bdd[] ms, Bdd[] msp, Bdd[] me, Bdd[] mep, Bdd[] cs, Bdd[] csp, Bdd[] ce, Bdd[] cep, Bdd bs, Bdd bsp, Bdd be, Bdd bep) { Bdd M = new Bdd(false); // opens boat after move Bdd OB = OpenBoat(bs, bsp, be, bep); // if one missionary in boat then one missionary move for (int i = 0; i < N; i++) { Bdd temp = Kernel.IfThen(OnePersonBoat(ms, cs, i), (ms[i] & !msp[i] & !me[i] & mep[i] & OB & Assign(ms, msp, i) & Assign(me, mep, i))); M |= temp; //M = M | (ms[i] & !msp[i] & mep[i] & Assign(ms, msp, i) & Assign(me, mep, i)); } // if one cannibal in boat then move one cannibal for (int i = 0; i < N; i++) { M |= Kernel.IfThen(OnePersonBoat(cs, ms, i), (cs[i] & !csp[i] & !ce[i] & cep[i] & OB & Assign(cs, csp, i) & Assign(ce, cep, i))); //M = M | (cs[i] & !csp[i] & cep[i] & Assign(cs, csp, i) & Assign(ce, cep, i)); } // two missionaries move for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { if (i != j) { M |= Kernel.IfThen(TwoPersonBoat(ms, cs, i, j), (ms[i] & ms[j] & !msp[i] & !msp[j] & !me[i] & !me[j] & mep[i] & mep[j] & OB & Assign(ms, msp, i, j) & Assign(me, mep, i, j))); /*M = M | (ms[i] & ms[j] & !msp[i] & !msp[j] * & mep[i] & mep[j] * & Assign(ms, msp, i, j) & Assign(me, mep, i, j));*/ } } } // two cannibals move for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { if (i != j) { M |= Kernel.IfThen(TwoPersonBoat(cs, ms, i, j), (cs[i] & cs[j] & !csp[i] & !csp[j] & !ce[i] & !ce[j] & cep[i] & cep[j] & OB & Assign(cs, csp, i, j) & Assign(ce, cep, i, j))); /*M = M | (cs[i] & cs[j] & !csp[i] & !csp[j] * & cep[i] & cep[j] * & Assign(cs, csp, i, j) & Assign(ce, cep, i, j));*/ } } } // one of each move for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { M |= Kernel.IfThen(TwoDifPersonBoat(cs, ms, i, j), (cs[i] & ms[j] & !csp[i] & !msp[j] & !ce[i] & !me[j] & cep[i] & mep[j] & OB & Assign(ms, msp, j) & Assign(cs, csp, i)) & Assign(me, mep, j) & Assign(ce, cep, i)); /*M = M | (cs[i] & ms[j] & !csp[i] & !msp[j] * & cep[i] & mep[j] * & Assign(ms, msp, j) & Assign(cs, csp, i)) * & Assign(me, mep, j) & Assign(ce, cep, i);*/ } } return(M); }