Exemplo n.º 1
0
Arquivo: Access.cs Projeto: belush/cba
        public SeriesModel[] SeriesToModel(Series[] series)
        {
            var seriesModel = new SeriesModel[3];

            for (var k = 0; k < series[0].SizeOfSeries; k++)
            {
                seriesModel[k] = new SeriesModel();
                seriesModel[k].items = new List<double[]>();

                seriesModel[k].SizeOfSeries = series[k].SizeOfSeries;
                seriesModel[k].Size = series[k].Size;
                seriesModel[k].MOValue = series[k].MOValue;

                for (var i = 0; i < series[k].Size; i++)
                {
                    var mas = new double[12];

                    for (var j = 0; j < 12; j++)
                    {
                        mas[j] = series[k].a[i][j];
                    }

                    seriesModel[k].items.Add(mas);
                    seriesModel[k].Name = series[k].Name;
                    seriesModel[k].activity = series[k].activity;
                    seriesModel[k].ratio = series[k].ratio;
                    seriesModel[k].breeding = series[k].breeding;
                }
            }

            return seriesModel;
        }
Exemplo n.º 2
0
Arquivo: Access.cs Projeto: belush/cba
        public Series[] ModelToSeries(SeriesModel[] seriesModel)
        {
            var series = new Series[3];


            for (var k = 0; k < seriesModel[0].SizeOfSeries; k++)
            {
                series[k] = new Series();
                series[k].a = new DataArray(seriesModel[0].Size);

                series[k].SizeOfSeries = seriesModel[k].SizeOfSeries;
                series[k].Size = seriesModel[k].Size;
                series[k].MOValue = seriesModel[k].MOValue;

                for (var i = 0; i < seriesModel[0].Size; i++)
                {
                    var mas = seriesModel[k].items[i];

                    for (var j = 0; j < 12; j++)
                    {
                        series[k].a[i][j] = mas[j];
                    }

                    series[k].Name = seriesModel[k].Name;
                    series[k].activity = seriesModel[k].activity;
                    series[k].ratio = seriesModel[k].ratio;
                    series[k].breeding = seriesModel[k].breeding;
                }
            }

            return series;
        }
Exemplo n.º 3
0
        private void InitTable(int n)
        {
            for (var i = 0; i < 3; i++)
            {
                series[i] = new Series(n);
                //TODO: remove
                series[i].a = new DataArray(n);
                series[0].Size = n;
                //Series.SizeOfSeries = int.Parse(comboBoxNumberOfSeries.SelectedValue.ToString());
                series[0].MOValue = int.Parse(textBoxMO.Text); //!!!
            }

            series[0].Name = textBoxSeriesName1.Text;
            series[1].Name = textBoxSeriesName2.Text;
            series[2].Name = textBoxSeriesName3.Text;

            dataGridA.ItemsSource = series[0].a.Data.DefaultView;
            dataGridB.ItemsSource = series[1].a.Data.DefaultView;
            dataGridC.ItemsSource = series[2].a.Data.DefaultView;

            for (var k = 0; k < 3; k++)
            {
                for (var i = 0; i < n; i++)
                {
                    for (var j = 0; j < 12; j++)
                    {
                        series[k].a[i][j] = 0;
                    }
                }
            }

            dataGridA.CanUserAddRows = false;
            dataGridB.CanUserAddRows = false;
            dataGridC.CanUserAddRows = false;
        }
Exemplo n.º 4
0
        public MainWindow()
        {
            info.Close();
            InitializeComponent();

            for (var i = 2; i <= 15; i++)
                comboBoxN.Items.Add(i);
            comboBoxN.SelectedItem = 5;

            for (var i = 1; i <= 3; i++)
                comboBoxNumberOfSeries.Items.Add(i);
            comboBoxNumberOfSeries.SelectedItem = 3;

            var size = int.Parse(comboBoxN.SelectedValue + "");
            var numberOfSeries = int.Parse(comboBoxNumberOfSeries.SelectedValue.ToString());

            for (var i = 0; i < 3; i++)
            {
                series[i] = new Series(size);
                series[i].a = new DataArray(size);
                series[i].Size = size;
                series[i].SizeOfSeries = numberOfSeries;
                series[i].MOValue = int.Parse(textBoxMO.Text); //!!!
            }

            series[0].Name = "A";
            series[1].Name = "B";
            series[2].Name = "C";

            InitTable(size);
        }
Exemplo n.º 5
0
Arquivo: Solver.cs Projeto: belush/cba
        private bool IsInRange(Series a)
        {
            if ((a.activity > 40000) && (a.activity < 60000))
            {
                return true;
            }

            return false;
        }
Exemplo n.º 6
0
Arquivo: Solver.cs Projeto: belush/cba
        private bool IsChecked(Series a)
        {
            if (IsInRange(a))
            {
                a.ratio = FindRatio(a);
                return true;
            }

            a.ratio = -1;
            return false;
        }
Exemplo n.º 7
0
Arquivo: Solver.cs Projeto: belush/cba
        public int bestMedNum; //номер лучшего припарата

        public int Culculate(Series[] series)
        {
            var isTableValid = true;

            for (var k = 0; k < series[0].SizeOfSeries; k++)
            {
                for (var i = 0; i < series[0].Size; i++)
                {
                    for (var j = 0; j < 12; j++)
                    {
                        if (series[k].a[i][j] < 0)
                        {
                            isTableValid = false;
                        }
                    }
                }
            }

            if (isTableValid)
            {
                for (var i = 0; i < series[0].SizeOfSeries; i++)
                {
                    series[i].FindMidValues();
                    series[i].FindBreedingSum();
                    series[i].FindActivityValue();
                }

                var isSeriesValid = true;

                for (var i = 0; i < series[0].SizeOfSeries; i++)
                {
                    if (!IsChecked(series[i]))
                    {
                        isSeriesValid = false;
                    }
                }

                //for (var i = Series.Size; i < 3; i++)
                //{
                //    series[i].ratio = 0;
                //}

                if (isSeriesValid)
                {
                    bestMedNum = FindBestMed(series);
                }

                return bestMedNum;
            }

            throw new Exception("Не все препараты прошли проверку!");
        }
Exemplo n.º 8
0
        //{


        public void Load(Series[] series, DataArray[] a)
        {
            for (var k = 0; k < 3; k++)
            {
                for (var i = 0; i < series[0].Size; i++)
                {
                    for (var j = 0; j < 12; j++)
                    {
                        a[k][i][j] = series[k].a[i][j];
                    }
                }
            }
        }
Exemplo n.º 9
0
        public void ShowInfo(Series[] series)
        {
            labelABreed1.Content = series[0].breeding[0] + "";
            labelABreed2.Content = series[0].breeding[1] + "";
            labelABreed3.Content = series[0].breeding[2] + "";
            labelABreed4.Content = series[0].breeding[3] + "";

            labelBBreed1.Content = series[1].breeding[0] + "";
            labelBBreed2.Content = series[1].breeding[1] + "";
            labelBBreed3.Content = series[1].breeding[2] + "";
            labelBBreed4.Content = series[1].breeding[3] + "";

            labelCBreed1.Content = series[2].breeding[0] + "";
            labelCBreed2.Content = series[2].breeding[1] + "";
            labelCBreed3.Content = series[2].breeding[2] + "";
            labelCBreed4.Content = series[2].breeding[3] + "";

            var Ad1 = series[0].breeding[0] + series[0].breeding[1];
            var Ad2 = series[0].breeding[2] + series[0].breeding[3];
            labelAD1.Content = "d1 = " + Ad1 + "";
            labelAD2.Content = "d2 = " + Ad2 + "";

            var Bd1 = series[1].breeding[0] + series[1].breeding[1];
            var Bd2 = series[1].breeding[2] + series[1].breeding[3];
            labelBD1.Content = "d1 = " + Bd1 + "";
            labelBD2.Content = "d2 = " + Bd2 + "";

            var Cd1 = series[2].breeding[0] + series[2].breeding[1];
            var Cd2 = series[2].breeding[2] + series[2].breeding[3];
            labelCD1.Content = "d1 = " + Cd1 + "";
            labelCD2.Content = "d2 = " + Cd2 + "";

            labelAA.Content = "A = " + Ad1 + " / " + Ad2 + " * " + series[0].MOValue + " = " +
                              Math.Round(series[0].activity);
            labelBA.Content = "A = " + Bd1 + " / " + Bd2 + " * " + series[0].MOValue + " = " +
                              Math.Round(series[1].activity);
            labelCA.Content = "A = " + Cd1 + " / " + Cd2 + " * " + series[0].MOValue + " = " +
                              Math.Round(series[2].activity);

            labelARatio.Content = "Эффект. = " + series[0].ratio;
            labelBRatio.Content = "Эффект. = " + series[1].ratio;
            labelCRatio.Content = "Эффект. = " + series[2].ratio;
        }
Exemplo n.º 10
0
        public void FillNumbers(Series[] series, int size, int sizeOfRows)
        {
            var random = new Random(unchecked((int) DateTime.Now.Ticks));

            for (var k = 0; k < size; k++)
            {
                for (var i = 0; i < sizeOfRows; i++)
                {
                    for (var j = 0; j < 12; j++)
                    {
                        series[k].a[i][j] = random.Next(7, 12);

                        if ((j + 1)%3 == 0)
                        {
                            series[k].a[i][j] = 0; //i row j column
                        }
                    }
                }
            }
        }
Exemplo n.º 11
0
Arquivo: Solver.cs Projeto: belush/cba
        private double FindMaxBreed(Series[] series)
        {
            var maxBreed = series[0].breeding[0];

            for (var i = 0; i < 3; i++)
            {
                for (var j = 0; j < 2; j++)
                {
                    if (series[i].breeding[j] > maxBreed)
                    {
                        maxBreed = series[i].breeding[j];
                    }
                }
            }

            return maxBreed;
        }
Exemplo n.º 12
0
Arquivo: Solver.cs Projeto: belush/cba
 private double FindRatio(Series a)
 {
     return (a.breeding[0] + a.breeding[1])/2;
 }
Exemplo n.º 13
0
        private void menuItemFileNew_Click(object sender, RoutedEventArgs e)
        {
            buttonMakeReport.IsEnabled = false;
            buttonSaveGraph.IsEnabled = false;

            var n = int.Parse(comboBoxN.SelectedValue + "");

            for (var i = 0; i < series[0].SizeOfSeries; i++)
            {
                series[i] = new Series(n);
                series[i].a = new DataArray(n);
                series[i].Size = n;
                series[i].SizeOfSeries = int.Parse(comboBoxNumberOfSeries.SelectedValue.ToString());
                series[i].MOValue = int.Parse(textBoxMO.Text); //!!!
            }

            InitTable(n);
            info.ShowInfo(series);

            Draw();
        }