コード例 #1
0
        private void startButton_Click(object sender, EventArgs e)
        {
            if (checkInputs())
            {
                getInputs();
            }
            else
            {
                return;
            }

            random              = new Random();
            analyticObj         = new AnalyticMethod(dataInput.gamma, dataInput.intervalBegin, dataInput.intervalEnd, dataInput.x0);
            inverseMethodObj    = new InverseFunctionMethod(dataInput.experimentsAmount, dataInput.partitionsAmount, dataInput.gamma, dataInput.intervalBegin, dataInput.intervalEnd, dataInput.x0);
            neymanMethodObj     = new NeymanMethod(dataInput.experimentsAmount, dataInput.partitionsAmount, dataInput.gamma, dataInput.intervalBegin, dataInput.intervalEnd, dataInput.x0);
            metropolisMethodObj = new MetropolisMethod(dataInput.experimentsAmount, dataInput.partitionsAmount, dataInput.gamma, dataInput.intervalBegin, dataInput.intervalEnd, dataInput.x0);
            experiment          = new Experiment(dataInput, analyticObj, inverseMethodObj, neymanMethodObj, metropolisMethodObj);

            actualExperimentAmount = 0;
            pause   = false;
            isSaved = false;

            setButtonsEnable(true);
            startButton.Enabled = false;
            saveButton.Enabled  = false;

            backgroundWorker.RunWorkerAsync();
        }
 public Experiment(Experiment experiment)
 {
     this.dataInput                = new DataInput(experiment.dataInput);
     this.analyticMethodObj        = new AnalyticMethod(experiment.analyticMethodObj);
     this.inverseFunctionMethodObj = new InverseFunctionMethod(experiment.inverseFunctionMethodObj);
     this.neymanMethodObj          = new NeymanMethod(experiment.neymanMethodObj);
     this.metropolisMethodObj      = new MetropolisMethod(experiment.metropolisMethodObj);
 }
 public Experiment(DataInput dataInput, AnalyticMethod analyticMethodObj, InverseFunctionMethod inverseFunctionMethodObj, NeymanMethod neymanMethodObj, MetropolisMethod metropolisMethodObj)
 {
     this.dataInput                = new DataInput(dataInput);
     this.analyticMethodObj        = new AnalyticMethod(analyticMethodObj);
     this.inverseFunctionMethodObj = new InverseFunctionMethod(inverseFunctionMethodObj);
     this.neymanMethodObj          = new NeymanMethod(neymanMethodObj);
     this.metropolisMethodObj      = new MetropolisMethod(metropolisMethodObj);
 }
コード例 #4
0
 public AnalyticMethod(AnalyticMethod analyticMethod)
 {
     this.gamma         = analyticMethod.gamma;
     this.intervalBegin = analyticMethod.intervalBegin;
     this.intervalEnd   = analyticMethod.intervalEnd;
     this.x0            = analyticMethod.x0;
     this.resultList    = new List <double>(analyticMethod.resultList);
     this.intervalsList = new List <double>(analyticMethod.intervalsList);
 }
        public List <double> getResultList()
        {
            double         max         = resultList.Max();
            AnalyticMethod analytic    = new AnalyticMethod(this.gamma, this.intervalBegin, this.intervalEnd, this.x0);
            double         maxAnalytic = analytic.getResultList().Max();

            for (int i = 0; i < resultList.Count; i++)
            {
                resultList[i] = (resultList[i] / max) * maxAnalytic;
            }

            resultList[resultList.Count - 1] = resultList[resultList.Count - 2];

            return(this.resultList);
        }
        public double getMaxValue()
        {
            AnalyticMethod analytic = new AnalyticMethod(this.gamma, this.intervalBegin, this.intervalEnd, this.x0);
            double         max      = analytic.getPDF(0);

            for (double i = this.intervalBegin; i < this.intervalEnd; i += 0.005)
            {
                double value = analytic.getPDF(i);
                if (value > max)
                {
                    max = value;
                }
            }

            return(max);
        }
コード例 #7
0
        public void LoadExperimentsFromDB()
        {
            this.idList.Clear();

            using (SQLiteConnection connection = new SQLiteConnection("Data Source=Experiments.sqlite3"))
            {
                connection.Open();

                using (SQLiteCommand command = connection.CreateCommand())
                {
                    command.CommandText = "SELECT * FROM experiment;";

                    using (SQLiteDataReader reader = command.ExecuteReader())
                    {
                        BinaryFormatter formatter = new BinaryFormatter();
                        this.experimentsList = new List <Experiment>();

                        while (reader.Read())
                        {
                            using (MemoryStream ms = new MemoryStream((byte[])reader["metropolis"]))
                            {
                                ms.Seek(0, SeekOrigin.Begin);
                                this.dataInput             = new DataInput((DataInput)formatter.Deserialize(ms));
                                this.analyticMethod        = new AnalyticMethod((AnalyticMethod)formatter.Deserialize(ms));
                                this.inverseFunctionMethod = new InverseFunctionMethod((InverseFunctionMethod)formatter.Deserialize(ms));
                                this.neymanMethod          = new NeymanMethod((NeymanMethod)formatter.Deserialize(ms));
                                this.metropolisMethod      = new MetropolisMethod((MetropolisMethod)formatter.Deserialize(ms));

                                this.idList.Add(int.Parse(reader["id"].ToString()));
                                this.experimentsList.Add(new Experiment(dataInput, analyticMethod, inverseFunctionMethod, neymanMethod, metropolisMethod));
                            }
                        }
                    }
                }
            }

            this.FillListBox();
        }