Exemplo n.º 1
0
 private void pictureBoxAddGeneration_Click(object sender, EventArgs e)
 {
     if (MainCarDatabase.Factories[FactoryIndex].Models[ModelIndex].AddGeneration(0, 0)) //добавили в объект
     {
         GenerationIndex = MainCarDatabase.Factories[FactoryIndex].Models[ModelIndex].FindGeneration(0, 0);
         int temp = comboBoxGeneration.Items.Add(OtherFuncs.FormGenerationName(0, 0));
         comboBoxGeneration.SelectedIndex = temp;
         //добавили в список
     }
 }
Exemplo n.º 2
0
        }//сделано

        public void LoadCarList(TModel CurrModel)
        {
            if (comboBoxGeneration != null)
            {
                comboBoxGeneration.ResetText();
                comboBoxGeneration.Items.Clear();
            }
            for (int i = 0; i < CurrModel.Generations.Count; i++)
            {
                comboBoxGeneration.Items.Add(OtherFuncs.FormGenerationName(CurrModel.Generations[i].GenBegin, CurrModel.Generations[i].GenEnd));
            }
        }//сделано
Exemplo n.º 3
0
    public bool AddGeneration(int Beg, int End)
    {
        for (int i = 0; i < Generations.Count; i++)
        {
            if (OtherFuncs.IsInRange(Beg, End, Generations[i].GenBegin, Generations[i].GenEnd))
            {
                return(false);
            }
        }
        Generations.Add(new TGeneration(Beg, End));

        return(true);
    }
Exemplo n.º 4
0
        private void comboBoxGeneration_SelectedIndexChanged(object sender, EventArgs e)
        {
            //чистка полей
            ResetCarInfo();

            GenerationIndex = -1;
            if (((ComboBox)sender).SelectedIndex != -1) //если выбрали поколение
            {
                int Beg, End;
                OtherFuncs.RecogniseGenerParamsFromString(comboBoxGeneration.SelectedItem.ToString(), out Beg, out End);
                GenerationIndex = MainCarDatabase.Factories[FactoryIndex].Models[ModelIndex].FindGeneration(Beg, End);
                if ((GenerationIndex == -1) && !(String.Equals(comboBoxGeneration.SelectedItem.ToString(), ProjectStrings.InitGenerationName)))
                {
                    MessageBox.Show(ProjectStrings.CarInfoWasNotFound);
                }

                if (!panelCarInfo.Visible)
                {
                    panelModelInfo.Hide();
                    panelCarInfo.Show();
                    panelFactoryInfo.Hide();
                }

                if (GenerationIndex != -1)
                {
                    if ((GenerationIndex != -1) && !(String.Equals(comboBoxGeneration.SelectedItem.ToString(), ProjectStrings.InitGenerationName)))
                    {
                        LoadCarInfo(MainCarDatabase.Factories[FactoryIndex].Models[ModelIndex].Generations[GenerationIndex]);
                    }
                }
                pictureBoxDelGeneration.Enabled = true;
                //pictureBoxAddModel.Enabled = true;
            }
            else
            {
                comboBoxGeneration.ResetText();
                GenerationIndex = -1;
                pictureBoxDelGeneration.Enabled = false;
            }

            //comboBoxGeneration.SelectedIndex = -1;
        }
Exemplo n.º 5
0
        static public List <double> squeezer(ref List <int> lCluster_NonMember, ref List <int> cluster_belong, ref List <Cluster_Squeezer> b_cluster, List <double> data, int N_LENGTH, int W_LENGTH, double threshold, int type_convert_raw_data, int index_table = 0, bool first_time = true)
        {
            var watch = System.Diagnostics.Stopwatch.StartNew();///calc execution time

            //call the function
            if (first_time)
            {
                BitCluster.squeezerCluster(data, type_convert_raw_data, ref b_cluster, ref cluster_belong, threshold, N_LENGTH, W_LENGTH, index_table);
            }
            else
            {
                BitCluster.squeezerClusterAgain(ref lCluster_NonMember, index_table, data, type_convert_raw_data, ref b_cluster, ref cluster_belong, threshold, N_LENGTH, W_LENGTH);
            }
            lCluster_NonMember = new List <int>();
            watch.Stop();//stop timer
            var elapsedMs = watch.ElapsedMilliseconds;

            Console.WriteLine("________squeezerCluster is Done in " + elapsedMs + ".\nKeep going...Please wait");



            // get Outer loop:
            List <int> outer_loop = getOuterLoop(b_cluster, b_cluster.Count, index_table); //get outer

            List <int> inner_loop;
            bool       continue_to_outer_loop = false;

            double nearest_neighbor_dist = 0;
            double dist = 0;

            double best_so_far_dist = 0;
            int    best_so_far_loc  = 0;

            List <double> p_center, q_center;

            bool[] is_skip_at_p = new bool[outer_loop.Count];
            for (int i = 0; i < outer_loop.Count; i++)
            {
                is_skip_at_p[i] = false;
            }

            int cluster_of_cur_outer; //thang p dang nam o cluster nao
            int cluster_of_cur_inner; // tracking for q's cluster at inner loop

            //test
            int count_skip_at_p               = 0;
            int count_break_sub_2_dis         = 0;
            int count_dis_smaller_best_so_far = 0;
            int count_center_p_diff_center_q  = 0;

            foreach (int p in outer_loop)
            {
                if (is_skip_at_p[p])
                {
                    count_skip_at_p++;
                    //p was visited at inner loop before
                    continue;
                }
                else
                {
                    nearest_neighbor_dist = INFINITE;

                    cluster_of_cur_outer = cluster_belong[p];

                    inner_loop = getInnerLoop(b_cluster, b_cluster.Count, cluster_of_cur_outer, index_table);

                    foreach (int q in inner_loop)// inner loop
                    {
                        if (Math.Abs(p - q) < N_LENGTH)
                        {
                            continue;// self-match => skip to the next one
                        }
                        else
                        {
                            //calculate the Distance between p and q
                            dist = OtherFuncs.gaussDistance(data.GetRange(p, N_LENGTH), data.GetRange(q, N_LENGTH));

                            if (dist < best_so_far_dist)
                            {
                                //skip the element q at oute_loop, 'cuz if (p,q) is not a solution, so does (q,p).
                                is_skip_at_p[q] = true;
                                count_dis_smaller_best_so_far++;

                                continue_to_outer_loop = true; //break, to the next loop at outer_loop
                                break;                         // break at inner_loop first
                            }

                            if (dist < nearest_neighbor_dist)
                            {
                                nearest_neighbor_dist = dist;
                            }
                        } //end else
                    }     //end inner
                    if (continue_to_outer_loop)
                    {
                        continue_to_outer_loop = false; //reset
                        continue;                       //go to the next p in outer loop
                    }

                    if (nearest_neighbor_dist > best_so_far_dist)
                    {
                        best_so_far_dist = nearest_neighbor_dist;
                        best_so_far_loc  = p;
                    }
                } //end else
            }     //end outter

            Console.WriteLine("count_skip_at_p =" + count_skip_at_p);
            Console.WriteLine("=======count_break_sub_2_dis =" + count_break_sub_2_dis);
            Console.WriteLine("count_dis_smaller_best_so_far =" + count_dis_smaller_best_so_far);
            Console.WriteLine("count_center_p_diff_center_q=" + count_center_p_diff_center_q);


            return(new List <double> {
                best_so_far_dist, best_so_far_loc
            });
        }//end bitClusterDiscord_Enhancement()
Exemplo n.º 6
0
        static public void squeezerCluster(RawDataType data, int type_convert_raw_data, ref List <Cluster_Squeezer> b_cluster, ref List <int> cluster_belong, double threshold, int N_LENGTH, int W_LENGTH, int index_table = 0)
        {
            //store Bit series data
            Dictionary <int, BitseriesType> bit_series_data;

            if (type_convert_raw_data == BitClusterDiscord.BIT_SERIES)
            {
                //get bit series data from original data
                bit_series_data = OtherFuncs.bitSeriesDataset(data, N_LENGTH, W_LENGTH);
            }
            else
            {
                if (type_convert_raw_data == BitClusterDiscord.PLA)
                {
                    bit_series_data = OtherFuncs.PLA(data, N_LENGTH, W_LENGTH);
                }

                else
                {
                    bit_series_data = OtherFuncs.PAA(data, N_LENGTH, W_LENGTH);
                }
            }


            //set some variables:
            int bit_series_data_length = bit_series_data.Count;

            b_cluster      = new List <Cluster_Squeezer>(); //store clusters
            cluster_belong = new List <int>();              //store the Cluster_Squeezer whose each point belong to

            //set initial values for cluster_belong: '-1'  here imply they dont lie in any clusters
            for (int i = 0; i < bit_series_data_length; i++)
            {
                cluster_belong.Add(-1);
            }


            //initialize the first data as a center point
            b_cluster.Add(new Cluster_Squeezer(new Cluster(1), new List <Dictionary <int, int> >()));// or 0 ??
            b_cluster[0].getCluster().addToListMemberIndice(index_table);
            b_cluster[0].updateCountElements(bit_series_data[0]);
            cluster_belong[0] = 0;


            double sim_max       = 0;
            double sim_value     = 0;
            int    cluster_index = 0;                        //the Cluster_Squeezer whose point j belong to.

            for (int j = 1; j < bit_series_data_length; j++) //go through the BD data,  except the first one
            {
                sim_max       = 0;
                cluster_index = 0;
                //for each existed Cluster_Squeezer C
                for (int i = 0; i < b_cluster.Count; i++)
                {
                    sim_value = simComputation(b_cluster[i], bit_series_data[j]);
                    if (sim_max < sim_value)
                    {
                        cluster_index = i;
                        sim_max       = sim_value;
                    }
                }


                if (sim_max >= threshold)
                {
                    cluster_belong[j] = cluster_index;
                    b_cluster[cluster_index].getCluster().plusOneToNumberOfMembers();
                    b_cluster[cluster_index].getCluster().addToListMemberIndice(j + index_table);
                    b_cluster[cluster_index].updateCountElements(bit_series_data[j]);
                }
                else
                {
                    //make a new Cluster_Squeezer then add it to b_cluster
                    b_cluster.Add(new Cluster_Squeezer(new Cluster(1), new List <Dictionary <int, int> >()));
                    cluster_belong[j] = b_cluster.Count - 1;
                    b_cluster[b_cluster.Count - 1].getCluster().addToListMemberIndice(j + index_table);
                    b_cluster[b_cluster.Count - 1].updateCountElements(bit_series_data[j]);
                }
            }//end of for

            Console.WriteLine("The number of clusters is " + b_cluster.Count);

            foreach (Cluster_Squeezer list_members in b_cluster)
            {
                list_members.getCluster().getListMemberIndice().Shuffle();
            }

            Console.WriteLine("End shuffle.");

            //double radius;
            //List<double> center_value;
            //for (int i = 0; i < b_cluster.Count; i++)
            //{
            //    center_value = data.GetRange(b_cluster[i].getCluster().getCenterIndex(), N_LENGTH);
            //    radius = HelperFunctions.calculateRadius(data, b_cluster[i].getCluster().getListMemberIndice(), center_value, N_LENGTH);
            //    b_cluster[i].getCluster().setRadius(radius);
            //}
        }//end squeezerCluster() function
Exemplo n.º 7
0
        }//end squeezerCluster() function

        static public void squeezerClusterAgain(ref List <int> lCluster_NonMember, int index_table, RawDataType data, int type_convert_raw_data, ref List <Cluster_Squeezer> b_cluster, ref List <int> cluster_belong, double threshold, int N_LENGTH, int W_LENGTH)
        {
            // Get old_bit_series and remove it from data
            Dictionary <int, BitseriesType> old_bit_series_data;

            old_bit_series_data = OtherFuncs.PAA(data.GetRange(0, N_LENGTH), N_LENGTH, W_LENGTH);
            data.RemoveAt(0);


            //store Bit series data
            Dictionary <int, BitseriesType> bit_series_data;


            if (type_convert_raw_data == BitClusterDiscord.BIT_SERIES)
            {
                //get bit series data from original data
                bit_series_data = OtherFuncs.bitSeriesDataset(data, N_LENGTH, W_LENGTH);
            }
            else
            {
                if (type_convert_raw_data == BitClusterDiscord.PLA)
                {
                    bit_series_data = OtherFuncs.PLA(data, N_LENGTH, W_LENGTH);
                }

                else
                {
                    bit_series_data = OtherFuncs.PAA(data, N_LENGTH, W_LENGTH);
                }
            }



            // Update b_cluster and cluster_belong
            // *Remove old_bit_series
            if (b_cluster[cluster_belong[0]].getCluster().getNumberOfMembers() == 1)
            {
                lCluster_NonMember.Add(cluster_belong[0]);
                Console.WriteLine("lCluster_NonMember has new member!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
            }
            b_cluster[cluster_belong[0]].getCluster().removeToListMemberIndice(index_table - 1);
            b_cluster[cluster_belong[0]].getCluster().extractOneToNumberOfMembers();
            b_cluster[cluster_belong[0]].decreaseCountElements(old_bit_series_data[0]);
            cluster_belong.RemoveAt(0);

            //set some variables:
            int bit_series_data_length = bit_series_data.Count;

            // *Add new_bit_series
            cluster_belong.Add(-1);
            int    cluster_index = 0;//the Cluster_Squeezer whose point j belong to.
            double sim_max       = 0;
            double sim_value     = 0;

            sim_max       = 0;
            cluster_index = 0;
            //for each existed Cluster_Squeezer C
            for (int i = 0; i < b_cluster.Count; i++)
            {
                if (lCluster_NonMember.FindIndex(x => x == i) < 0)
                {
                    sim_value = simComputation(b_cluster[i], bit_series_data[bit_series_data_length - 1]);
                    if (sim_max < sim_value)
                    {
                        cluster_index = i;
                        sim_max       = sim_value;
                    }
                }
            }

            if (sim_max >= threshold)
            {
                cluster_belong[bit_series_data_length - 1] = cluster_index;
                b_cluster[cluster_index].getCluster().plusOneToNumberOfMembers();
                b_cluster[cluster_index].getCluster().addToListMemberIndice(bit_series_data_length + index_table - 1); // error?
                b_cluster[cluster_index].updateCountElements(bit_series_data[bit_series_data_length - 1]);
            }
            else
            {
                int new_cluster_index;
                if (lCluster_NonMember.Count == 0)
                {
                    //make a new Cluster_Squeezer then add it to b_cluster
                    b_cluster.Add(new Cluster_Squeezer(new Cluster(1), new List <Dictionary <int, int> >()));
                    new_cluster_index = b_cluster.Count - 1;
                }
                else
                {
                    new_cluster_index = lCluster_NonMember[0];
                    lCluster_NonMember.RemoveAt(0);
                }
                cluster_belong[bit_series_data_length - 1] = new_cluster_index;
                b_cluster[new_cluster_index].getCluster().addToListMemberIndice(bit_series_data_length + index_table - 1);
                b_cluster[new_cluster_index].updateCountElements(bit_series_data[bit_series_data_length - 1]);
            }
            for (int i = 0; i < cluster_belong.Count; i++)
            {
                if (cluster_belong[i] < 0)
                {
                    Console.WriteLine("Cluster belong has -1");
                }
            }
            Console.WriteLine("The number of clusters is " + b_cluster.Count);

            foreach (Cluster_Squeezer list_members in b_cluster)
            {
                list_members.getCluster().getListMemberIndice().Shuffle();
            }

            Console.WriteLine("End shuffle.");
        }
Exemplo n.º 8
0
        /// <summary>
        /// Возвращает название функции по типу анимации
        /// </summary>
        /// <returns>Название функции с параметрами</returns>
        private string getFuncName()
        {
            string ex = "";

            //Парсим параметры в строку JSON
            string json = OtherFuncs.objectToJSON(animationParameters);

            //Выбираем название по типу
            switch (type)
            {
            case AnimationType.Без_действия:
            {
                ex = "";
                break;
            }

            case AnimationType.Мерцание:
            {
                ex = $"animate_blink({ json });";
                break;
            }

            case AnimationType.Мигание:
            {
                ex = $"animate_flash({ json });";
                break;
            }

            case AnimationType.Перемещение:
            {
                ex = $"animate_move({ json });";
                break;
            }

            case AnimationType.Прозрачность:
            {
                ex = $"animate_opacity({ json });";
                break;
            }

            case AnimationType.Цвет:
            {
                ex = $"animate_color({ json });";
                break;
            }

            case AnimationType.Смена_сцены:
            {
                ex = $"scene_redirect({ json });";
                break;
            }

            case AnimationType.Установка_параметра:
            {
                ex = $"set_param({ json });";
                break;
            }
            }

            return(ex);
        }