Exemplo n.º 1
0
        public ReportBorderForm(BorderExperimentResult borderExperimentResult)
        {
            InitializeComponent();

            lbVariableCount.Text = borderExperimentResult.VariableCount.ToString();
            lbFreeMembers.Text = borderExperimentResult.FreeMembers.ToString();
            lbExperimentRepeat.Text = borderExperimentResult.ExperimentRepeat.ToString();

            float meanKonync = borderExperimentResult.BorderCount.Sum() / borderExperimentResult.BorderCount.Count;
            lbKonyncCount.Text = meanKonync.ToString();

            GraphPane graphPane = this.zedGraphControl1.GraphPane;
            graphPane.CurveList.Clear();
            graphPane.Title.Text = "Demonstration of experiment by calculation of realizability of function";
            graphPane.XAxis.Title.Text = "Experiment Number";
            graphPane.YAxis.Title.Text = "Probability";
            string[] massX = new string[borderExperimentResult.PercentageSatisfiability.Count];

            for (int i = 0; i < borderExperimentResult.PercentageSatisfiability.Count; i++)
            {
                massX[i] = borderExperimentResult.PercentageSatisfiability[i].ToString();
            }

            PointPairList points = new PointPairList();
            PointPairList list3 = new PointPairList();
            Random random = new Random();
            for (int i = 0; i < borderExperimentResult.BorderCount.Count; i++)
            {
                double x = i + 1.0;
                double z = 5.0;
                points.Add(x, (double)borderExperimentResult.BorderCount[i], z);
            }
            BarItem item = graphPane.AddBar("Count Minterms", points, Color.Blue);
            graphPane.BarSettings.MinBarGap = 0f;
            graphPane.XAxis.Scale.TextLabels = massX;
            graphPane.XAxis.Type = AxisType.Text;

            this.zedGraphControl1.AxisChange();
            this.zedGraphControl1.Invalidate();
        }
Exemplo n.º 2
0
        void BackgroundWorkerDoWorkBorderSatisfiability(object sender, DoWorkEventArgs e)
        {
            var borderExperimentResult = new BorderExperimentResult();
            borderExperimentResult.VariableCount = variableCount;
            borderExperimentResult.FreeMembers = iFreeMembers;
            borderExperimentResult.ExperimentRepeat = iExperimentRepeat;

            float borderSatisfiability = (float)numBorderSatisfiability.Value;
            var rnd = new Random();

            Log.Debug("-------------------------New checking at " + DateTime.Now);
            Log.Debug("Count minterms - " + iKonyncCount);
            Log.Debug("Count free members - " + iFreeMembers);
            Log.Debug("Count parameters - " + variableCount);

            for (int experimentIndex = 0; (experimentIndex < iExperimentRepeat) && (!e.Cancel); experimentIndex++)
            {
                Log.Debug("------------------Next generation");
                int num = iKonyncCount;
                int countParams = variableCount;
                int countFreeMembers = iFreeMembers;
                uint countUniqueConjunction = 0;

                var buffer = new byte[BinaryCounter.BinaryCounter.FindSizeBitMapForCountParams(countParams)];
                Log.DebugFormat("Size of mass = {0}", buffer.Length);

                int[] freeMembersIndex = BinaryCounter.BinaryCounter.FindFreeMembersIndex(countParams, countFreeMembers);
                uint mask = BinaryCounter.BinaryCounter.GetMask(freeMembersIndex);
                uint rotatedMask = BinaryCounter.BinaryCounter.GetRotateMask(mask);
                Log.DebugFormat("Mask = {0}", mask);
                Log.DebugFormat("RotateMask = {0}", rotatedMask);

                float currentSatisfiability = 0;
                int indexMinterm = 0;
                do
                {
                    uint generatedConjunction = BinaryCounter.BinaryCounter.GetRandomСonjunction(countParams);
                    Log.DebugFormat("Generate Digit = {0}", generatedConjunction);

                    foreach (var recoveredConjunction in BinaryCounter.BinaryCounter.RecoveredConjunction(mask, rotatedMask, generatedConjunction, countFreeMembers))
                    {
                        uint byteIndex = recoveredConjunction / 8;
                        Log.Debug("                PereborDigit = " + recoveredConjunction);
                        Log.Debug("                Index = " + byteIndex);

                        byte conjunctionByte = BinaryCounter.BinaryCounter.GetCheckedBitrForConjunction(recoveredConjunction);
                        if ((buffer[byteIndex] & conjunctionByte) == 0)
                            countUniqueConjunction++;

                        Log.Debug("                Count = " + countUniqueConjunction);
                        buffer[byteIndex] |= conjunctionByte;
                    }
                    currentSatisfiability = Convert.ToSingle(countUniqueConjunction) / (1 << variableCount);
                    indexMinterm++;

                    Log.Debug("Total = " + currentSatisfiability);

                } while((currentSatisfiability < borderSatisfiability) && (!e.Cancel));

                borderExperimentResult.PercentageSatisfiability.Add(currentSatisfiability);
                borderExperimentResult.BorderCount.Add(indexMinterm);

                backgroundWorker.ReportProgress(experimentIndex);

                if (backgroundWorker.CancellationPending)
                {
                    e.Cancel = true;
                    break;
                }
            }
            e.Result = borderExperimentResult;
        }