예제 #1
0
        public static void PrintExpressionFor3DirDerivative(int n)
        {
            BooleanFunction f = new BooleanFunction((byte)n);

            Console.WriteLine(DirDerivStrings[6] + " = " + BooleanExpression.FindMininalExpressionInBasis(
                                  f.DirectionalDeriv(VarLists[6]).Eval(), AvdoshinBases[0], AvdoshinVars[0]).ToString());

            Console.WriteLine();
        }
예제 #2
0
        public static void PrintExpressionsFor2DirDerivatives(int n)
        {
            BooleanFunction f = new BooleanFunction((byte)n);

            for (int i = 3; i <= 5; i++)
            {
                Console.WriteLine(DirDerivStrings[i] + " = " + BooleanExpression.FindMininalExpressionInBasis(
                                      f.DirectionalDeriv(VarLists[i]).Eval(), AvdoshinBases[0], AvdoshinVars[0]).ToString());
            }

            Console.WriteLine();
        }
예제 #3
0
        public static void PrintMinimaInAvdoshinBases(int n, bool minOps, bool showBlocks)
        {
            Console.WriteLine("\nМинимальные представления f_" + n + " в базисах (для рисования в винлогике):");

            Console.WriteLine(" ☻   Базис             Выражение");
            Console.WriteLine();

            for (int i = 0; i < AvdoshinBases.Length; i++)
            {
                Console.Write("{0} — {1}", i.ToString("D2"), AvdoshinNames[i].PadRight(18));

                try {
                    var ex = BooleanExpression.FindMininalExpressionInBasis(n, AvdoshinBases[i], AvdoshinVars[i],
                                                                            mode: minOps ? BooleanExpression.ExpressionSearchMode.CountOps :
                                                                            BooleanExpression.ExpressionSearchMode.CountBlocks);

                    Console.WriteLine(ex.ToString());

                    if (showBlocks)
                    {
                        if (ex.CountOps() == ex.CountBlocks())
                        {
                            Console.WriteLine("\tСколько операций, столько и блоков");
                        }
                        else
                        {
                            foreach (string s in new HashSet <string>(ex.GetSetOfAllBlockStrings()).OrderByDescending(x => x.Length).Skip(1))
                            {
                                if (s != ex.ToString())
                                {
                                    Console.WriteLine("\t" + s);
                                }
                            }

                            Console.WriteLine("\tИтого: операций: {0}, блоков: {1}", ex.CountOps(), ex.CountBlocks());
                        }
                    }
                }
                catch (CouldntFindExpressionException) {
                    Console.WriteLine("не нашлось");
                }
            }
        }