Ejemplo n.º 1
0
 private void cbStartDataStructure_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (!startMode)
     {
         if (cbStartDataStructure.SelectedItem != null)
         {
             //TODO? check if the selected data structure belong to the selected data structure group
             bool ok = false;
             foreach (KeyValuePair <DataStructureGroup, SCG.List <C5DataStructure> > group in dataStructuresByGroup)
             {
                 if (group.Key == CurrentDataStructureGroup)
                 {
                     if (group.Value.Contains((C5DataStructure)cbStartDataStructure.SelectedItem))
                     {
                         ok = true;
                     }
                 }
             }
             if (ok)
             {
                 StartDataStructure          = (C5DataStructure)cbStartDataStructure.SelectedItem;
                 CurrentC5DataStructure      = StartDataStructure;
                 lbCurrentDataStructure.Text = "Current Data Structure: " + CurrentC5DataStructure.ToString();
             }
             else
             {
                 MessageBox.Show("Your selected data structure is not belong to the selected group. Please select a new one.");
                 cbStartDataStructure.SelectedItem = StartDataStructure;
             }
         }
     }
 }
Ejemplo n.º 2
0
 private void cbDataStructureGroup_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (!startMode)
     {
         if (cbDataStructureGroup.SelectedItem != null)
         {
             KeyValuePair <DataStructureGroup, C5DataStructure> dsg = (KeyValuePair <DataStructureGroup, C5DataStructure>)cbDataStructureGroup.SelectedItem;
             //automatically set the start data structure to the worst option in the selected data structure group
             CurrentDataStructureGroup         = dsg.Key;
             StartDataStructure                = dsg.Value;
             CurrentC5DataStructure            = dsg.Value;
             lbCurrentDataStructure.Text       = "Current Data Structure: " + CurrentC5DataStructure.ToString();
             cbStartDataStructure.SelectedItem = dsg.Value;
         }
     }
 }
Ejemplo n.º 3
0
        public GreenC5UserControl(string greenC5Name, bool infiniteExecution, int k1, double k2)
        {
            InitializeComponent();
            Status                = "Idle";
            IsInfiniteMode        = infiniteExecution;
            GreenC5Name           = greenC5Name;
            lbName.Text           = "Instance ID: " + GreenC5Name;
            InternalDataStructure = new GreenC5 <string>();
            K1 = k1;
            K2 = k2;


            //set datastructure list by groups for validation
            SCG.List <C5DataStructure> iCollection = new SCG.List <C5DataStructure>();
            iCollection.Add(C5DataStructure.ArrayList);
            iCollection.Add(C5DataStructure.HashBag);
            iCollection.Add(C5DataStructure.HashedArrayList);
            iCollection.Add(C5DataStructure.HashedLinkedList);
            iCollection.Add(C5DataStructure.HashSet);
            iCollection.Add(C5DataStructure.LinkedList);
            iCollection.Add(C5DataStructure.SortedArray);
            iCollection.Add(C5DataStructure.TreeBag);
            iCollection.Add(C5DataStructure.TreeSet);
            dataStructuresByGroup.Add(new KeyValuePair <DataStructureGroup, SCG.List <C5DataStructure> >(DataStructureGroup.ICollection, iCollection));

            SCG.List <C5DataStructure> iCollectionBag = new SCG.List <C5DataStructure>();
            iCollectionBag.Add(C5DataStructure.HashBag);
            iCollectionBag.Add(C5DataStructure.TreeBag);
            iCollectionBag.Add(C5DataStructure.ArrayList);
            iCollectionBag.Add(C5DataStructure.LinkedList);
            dataStructuresByGroup.Add(new KeyValuePair <DataStructureGroup, SCG.List <C5DataStructure> >(DataStructureGroup.ICollectionBag, iCollectionBag));

            SCG.List <C5DataStructure> iCollectionSet = new SCG.List <C5DataStructure>();
            iCollectionSet.Add(C5DataStructure.HashSet);
            iCollectionSet.Add(C5DataStructure.TreeSet);
            iCollectionSet.Add(C5DataStructure.HashedArrayList);
            iCollectionSet.Add(C5DataStructure.HashedLinkedList);
            iCollectionSet.Add(C5DataStructure.SortedArray);
            dataStructuresByGroup.Add(new KeyValuePair <DataStructureGroup, SCG.List <C5DataStructure> >(DataStructureGroup.ICollectionSet, iCollectionSet));

            SCG.List <C5DataStructure> iList = new SCG.List <C5DataStructure>();
            iList.Add(C5DataStructure.ArrayList);
            iList.Add(C5DataStructure.LinkedList);
            iList.Add(C5DataStructure.HashedArrayList);
            iList.Add(C5DataStructure.HashedLinkedList);
            iList.Add(C5DataStructure.SortedArray);
            dataStructuresByGroup.Add(new KeyValuePair <DataStructureGroup, SCG.List <C5DataStructure> >(DataStructureGroup.IList, iList));

            SCG.List <C5DataStructure> iListBag = new SCG.List <C5DataStructure>();
            iListBag.Add(C5DataStructure.ArrayList);
            iListBag.Add(C5DataStructure.LinkedList);
            dataStructuresByGroup.Add(new KeyValuePair <DataStructureGroup, SCG.List <C5DataStructure> >(DataStructureGroup.IListBag, iListBag));

            SCG.List <C5DataStructure> iListSet = new SCG.List <C5DataStructure>();
            iListSet.Add(C5DataStructure.HashedArrayList);
            iListSet.Add(C5DataStructure.HashedLinkedList);
            iListSet.Add(C5DataStructure.SortedArray);
            dataStructuresByGroup.Add(new KeyValuePair <DataStructureGroup, SCG.List <C5DataStructure> >(DataStructureGroup.IListSet, iListSet));


            //set data structure groups
            SCG.List <KeyValuePair <DataStructureGroup, C5DataStructure> > dsGroupAndWorstDataStructures = new SCG.List <KeyValuePair <DataStructureGroup, C5DataStructure> >();
            dsGroupAndWorstDataStructures.Add(new KeyValuePair <DataStructureGroup, C5DataStructure>(DataStructureGroup.ICollection, C5DataStructure.ArrayList));
            dsGroupAndWorstDataStructures.Add(new KeyValuePair <DataStructureGroup, C5DataStructure>(DataStructureGroup.ICollectionBag, C5DataStructure.LinkedList));
            dsGroupAndWorstDataStructures.Add(new KeyValuePair <DataStructureGroup, C5DataStructure>(DataStructureGroup.ICollectionSet, C5DataStructure.SortedArray));
            dsGroupAndWorstDataStructures.Add(new KeyValuePair <DataStructureGroup, C5DataStructure>(DataStructureGroup.IList, C5DataStructure.LinkedList));
            dsGroupAndWorstDataStructures.Add(new KeyValuePair <DataStructureGroup, C5DataStructure>(DataStructureGroup.IListBag, C5DataStructure.LinkedList));
            dsGroupAndWorstDataStructures.Add(new KeyValuePair <DataStructureGroup, C5DataStructure>(DataStructureGroup.IListSet, C5DataStructure.SortedArray));

            //cbDataStructureGroup.DisplayMember = "Key";
            //cbDataStructureGroup.ValueMember = "Value";
            cbDataStructureGroup.DataSource = dsGroupAndWorstDataStructures;


            SCG.List <KeyValuePair <string, string> > crudWorkloadPrograms = new SCG.List <KeyValuePair <string, string> >();
            crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Small Program #1", @"CRUD Workloads\SmallRandomApplication1.csv"));
            crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Small Program #2", @"CRUD Workloads\SmallRandomApplication2.csv"));
            crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Small Program #3", @"CRUD Workloads\SmallRandomApplication3.csv"));
            crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Small Program #4", @"CRUD Workloads\SmallRandomApplication4.csv"));
            crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Simulated Program #1", @"CRUD Workloads\RandomApplication1.csv"));
            crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Simulated Program #2", @"CRUD Workloads\RandomApplication2.csv"));
            crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Simulated Program #3", @"CRUD Workloads\RandomApplication3.csv"));
            crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Simulated Program #4", @"CRUD Workloads\RandomApplication4.csv"));
            crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Simulated Program #5", @"CRUD Workloads\RandomApplication5.csv"));
            crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Simulated Program #6", @"CRUD Workloads\RandomApplication6.csv"));
            crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Simulated Program #7", @"CRUD Workloads\RandomApplication7.csv"));
            crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Simulated Program #8", @"CRUD Workloads\RandomApplication8.csv"));
            crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Simulated Program #9", @"CRUD Workloads\RandomApplication9.csv"));
            crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Simulated Program #10", @"CRUD Workloads\RandomApplication10.csv"));
            crudWorkloadPrograms.Add(new KeyValuePair <string, string>("A* Path Finder - Custom", @"CRUD Workloads\AStarPathFinderProgram_Custom_Formula.csv"));
            crudWorkloadPrograms.Add(new KeyValuePair <string, string>("A* Path Finder - Diagnal Shortcut", @"CRUD Workloads\AStarPathFinderProgram_DiagonalShortcut_Formula.csv"));
            crudWorkloadPrograms.Add(new KeyValuePair <string, string>("A* Path Finder - Euclidean", @"CRUD Workloads\AStarPathFinderProgram_Euclidean_Formula.csv"));
            crudWorkloadPrograms.Add(new KeyValuePair <string, string>("A* Path Finder - Manhatan", @"CRUD Workloads\AStarPathFinderProgram_Manhatan_Formula.csv"));
            crudWorkloadPrograms.Add(new KeyValuePair <string, string>("A* Path Finder - Max Dx Dy", @"CRUD Workloads\AStarPathFinderProgram_MaxDXDY_Formula.csv"));
            crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Genetic Algorithm - Fitness Table", @"CRUD Workloads\GA-FittnessTableProgram.csv"));
            crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Genetic Algorithm - Next Generation", @"CRUD Workloads\GA-NextGenerationProgram.csv"));
            crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Genetic Algorithm - This Generation", @"CRUD Workloads\GA-ThisGenerationProgram.csv"));
            crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Huffman Encoding", @"CRUD Workloads\HuffmanCodingProgram.csv"));


            cbPrograms.DataSource    = new BindingSource(crudWorkloadPrograms, null);
            cbPrograms.DisplayMember = "Key";
            //cbPrograms.ValueMember = "Value";
            //set the values to the program potion dropdownlist

            //set data structure options to a Static Mode selection
            cbStartDataStructure.DataSource = c5DSs;

            //Set run mode
            cbRunMode.DataSource   = Enum.GetValues(typeof(DataStructureMode));
            cbRunMode.SelectedItem = DataStructureMode.Dynamic;


            if (cbDataStructureGroup.SelectedItem != null)
            {
                KeyValuePair <DataStructureGroup, C5DataStructure> dsg = (KeyValuePair <DataStructureGroup, C5DataStructure>)cbDataStructureGroup.SelectedItem;
                CurrentDataStructureGroup         = dsg.Key;
                StartDataStructure                = dsg.Value;
                CurrentC5DataStructure            = dsg.Value;
                lbCurrentDataStructure.Text       = "Current Data Structure: " + CurrentC5DataStructure.ToString();
                cbStartDataStructure.SelectedItem = StartDataStructure;
            }

            if (cbPrograms.SelectedItem != null)
            {
                CurrentProgram = (KeyValuePair <string, string>)cbPrograms.SelectedItem;
            }

            startMode = false;
            bool ok = LoadProgram();
        }