/// <summary>
        /// Initialise the form with the Worker Object
        /// </summary>
        /// <param name="currentWorker"></param>
        public FormWorkerOrCommunityDetail(Worker currentWorker, ExperimentModel relatedExperimentItem)
        {
            InitializeComponent();
            this.currentWorker = currentWorker;

            //Display the workerId in the form title
            this.Text = "[Worker]" + currentWorker.WorkerId;
            this.relatedExperimentItem = relatedExperimentItem;
            this.labelForWorkerId.Text = currentWorker.WorkerId;
            this.labelModelDetail.Text = relatedExperimentItem.ToString();
            RunType[] runTypesHaveWorkerMatrices = { RunType.DawidSkene, RunType.BCC, RunType.CBCC };

            //Only display the confusion matrices if it matches the runType
            if (runTypesHaveWorkerMatrices.Contains(relatedExperimentItem.runType))
            {
                indexOfExperimentItem    = MainPage.mainPageForm.currentExperimentSetting.GetExperimenModelIndex(relatedExperimentItem);
                printableConfusionMatrix = MainPage.mainPageForm.currentExperimentSetting.getWorkerResults(indexOfExperimentItem, currentWorker.WorkerId);
                LoadConfusionMatrix();
                //SetUpChart();
                labelConfusionMatrix.Text   = MainPage.mainPageForm.currentExperimentSetting.getConfusionMatrixString(printableConfusionMatrix);
                textBoxConfusionMatrix.Text = labelConfusionMatrix.Text;
                //start background thread to update the confusion matrice accordingly if it is activeLearning
                if (MainPage.mainPageForm.currentExperimentSetting.experimentType == ExperimentType.ActiveLearning)
                {
                    backgroundUpdateConfusionMatrix.RunWorkerAsync();
                }
            }
            else //for the RunType that does not have confusion matrix
            {
                //hide all controls related to confusion matrix
                confusionMatrixGraph.Visible   = false;
                textBoxConfusionMatrix.Visible = false;
            }
        }
        /// <summary>
        /// Initialise the form with the Worker Object
        /// </summary>
        /// <param name="currentWorker"></param>
        public FormTaskDetails(string taskId, ExperimentModel relatedExperimentItem)
        {
            InitializeComponent();

            this.taskId = taskId;
            //Display the workerId in the form title
            this.Text = "[Task]" + taskId;
            this.relatedExperimentItem = relatedExperimentItem;
            this.labelForTaskId.Text = taskId;
            this.labelModelDetail.Text = relatedExperimentItem.ToString();

            //load data
            labelConfusionMatrix.Text = probabilityText;
            indexOfExperimentItem = MainPage.mainPageForm.currentExperimentSetting.GetExperimenModelIndex(relatedExperimentItem);
            probabilitiesArray = MainPage.mainPageForm.currentExperimentSetting.GetTaskTrueLabel(indexOfExperimentItem, taskId);
            labelHeader = "";
            int labelCount = 0;

            //Initialise the probabilitiesArray
            if (probabilitiesArray != null)
            {
                labelCount = probabilitiesArray.Dimension;
                Enumerable.Range(1, labelCount).ToList().ForEach(i => labelHeader += "Label" + i + "       ");
                // labelForDataHeader.Text = labelHeader;
                SetUpChart();

                //Only sync the background thread if it is activeLearning
                if (MainPage.mainPageForm.currentExperimentSetting.experimentType == ExperimentType.ActiveLearning)
                {
                    backgroundTaskValues.RunWorkerAsync();
                }
            }// End if the probabilitiesArray is not null
        } // End Constructor
예제 #3
0
        /// <summary>
        /// Initialise the form with the Worker Object
        /// </summary>
        /// <param name="currentWorker"></param>
        public FormTaskDetails(string taskId, ExperimentModel relatedExperimentItem)
        {
            InitializeComponent();

            this.taskId = taskId;
            //Display the workerId in the form title
            this.Text = "[Task]" + taskId;
            this.relatedExperimentItem = relatedExperimentItem;
            this.labelForTaskId.Text   = taskId;
            this.labelModelDetail.Text = relatedExperimentItem.ToString();

            //load data
            labelConfusionMatrix.Text = probabilityText;
            indexOfExperimentItem     = MainPage.mainPageForm.currentExperimentSetting.GetExperimenModelIndex(relatedExperimentItem);
            probabilitiesArray        = MainPage.mainPageForm.currentExperimentSetting.GetTaskTrueLabel(indexOfExperimentItem, taskId);
            labelHeader = "";
            int labelCount = 0;

            //Initialise the probabilitiesArray
            if (probabilitiesArray != null)
            {
                labelCount = probabilitiesArray.Dimension;
                Enumerable.Range(1, labelCount).ToList().ForEach(i => labelHeader += "Label" + i + "       ");
                // labelForDataHeader.Text = labelHeader;
                SetUpChart();

                //Only sync the background thread if it is activeLearning
                if (MainPage.mainPageForm.currentExperimentSetting.experimentType == ExperimentType.ActiveLearning)
                {
                    backgroundTaskValues.RunWorkerAsync();
                }
            } // End if the probabilitiesArray is not null
        }     // End Constructor
        /// <summary>
        /// Add the model into temporary experimentItem List
        /// </summary>
        private void AddModel()
        {
            Dataset currentDataset = GlobalVariables.loadedDatasets[comboBoxForSelectingDataset.SelectedIndex];

            currentStartingLabelPoints = currentDataset.GetLabelStartingPoints();

            //Add ExperimentModel when it is ActiveLearning Experiment
            if (currentExperimentType == ExperimentType.ActiveLearning)
            {
                ExperimentModel currentExpItem = getExperimentItem((RunType)(comboBoxListOfRunTypes.SelectedIndex), (TaskSelectionMethod)comboBoxListOfTaskSelectionMethods.SelectedIndex,
                                                                   (WorkerSelectionMethod)dropDownListOfWorkerSelectionMethod.SelectedIndex, currentStartingLabelPoints);

                //add to the experimentList
                currentListOfExperimentModels.Add(currentExpItem);
                Object[] tempRow = { (RunType)comboBoxListOfRunTypes.SelectedIndex, (TaskSelectionMethod)comboBoxListOfTaskSelectionMethods.SelectedIndex, (WorkerSelectionMethod)dropDownListOfWorkerSelectionMethod.SelectedIndex };
                dataGridViewOfCurrentModels.Rows.Add(tempRow);
            } //Add ExperimentModel when it is BatchRunning Experiment
            else if (currentExperimentType == ExperimentType.BatchRunning)
            {
                ExperimentModel currentExpItem = getExperimentItem((RunType)(comboBoxListOfRunTypes.SelectedIndex), (TaskSelectionMethod)comboBoxListOfTaskSelectionMethods.SelectedIndex,
                                                                   (WorkerSelectionMethod)dropDownListOfWorkerSelectionMethod.SelectedIndex, currentStartingLabelPoints);

                //add to the experimentList
                currentListOfExperimentModels.Add(currentExpItem);
                Object[] tempRow = { (RunType)(comboBoxListOfRunTypes.SelectedIndex), (TaskSelectionMethod)comboBoxListOfTaskSelectionMethods.SelectedIndex, (WorkerSelectionMethod)dropDownListOfWorkerSelectionMethod.SelectedIndex };
                //add to the grid view
                dataGridViewOfCurrentModels.Rows.Add(tempRow);
            }
        } //End AddModel
        /// <summary>
        /// Restore to set previous experiment setting
        /// </summary>
        /// <param name="exprSetting"></param>
        public void setPreviousExperimentSetting(ExperimentSetting exprSetting)
        {
            currentListOfExperimentModels = new List <ExperimentModel>();
            dataGridViewOfCurrentModels.Rows.Clear();
            comboBoxForSelectingDataset.SelectedIndex = GlobalVariables.getDatasetIndex(exprSetting.currentDataset);

            //for each experimentItem in the experimentSetting
            for (int i = 0; i < exprSetting.GetNumberOfExperiemntModels(); i++)
            {
                ExperimentModel currentExperimentItem = exprSetting.GetExperimentModel(i);

                //add to the experimentList
                currentListOfExperimentModels.Add(currentExperimentItem);
                //add to the grid view
                Object[] tempRow = { currentExperimentItem.runType, currentExperimentItem.taskSelectionMethod, currentExperimentItem.WorkerSelectionMethod };
                dataGridViewOfCurrentModels.Rows.Add(tempRow);
            } //End for
        }
        /// <summary>
        /// Initialise the form with the Worker Object
        /// </summary>
        /// <param name="currentWorker"></param>
        public FormWorkerOrCommunityDetail(int communityIndex, ExperimentModel relatedExperimentItem)
        {
            InitializeComponent();
            isWorker            = false;
            this.communityIndex = communityIndex;

            //Display the workerId in the form title
            this.Text = "[Community]" + (communityIndex);
            this.labelForWorkerId.Text = "Community " + (communityIndex);
            labelTypeName.Text         = "Community";

            this.relatedExperimentItem = relatedExperimentItem;
            this.labelModelDetail.Text = relatedExperimentItem.ToString();

            //The RunType that has Community Matrix
            RunType[] runTypesHaveCommunityMatrices = { RunType.CBCC };

            //Only display the confusion matrices if it matches the runType
            if (runTypesHaveCommunityMatrices.Contains(relatedExperimentItem.runType))
            {
                indexOfExperimentItem = MainPage.mainPageForm.currentExperimentSetting.GetExperimenModelIndex(relatedExperimentItem);

                //get printableConfusionMatrix
                printableConfusionMatrix = MainPage.mainPageForm.currentExperimentSetting.getCommunityResults(indexOfExperimentItem, communityIndex);
                LoadConfusionMatrix();

                labelConfusionMatrix.Text   = MainPage.mainPageForm.currentExperimentSetting.getConfusionMatrixString(printableConfusionMatrix);
                textBoxConfusionMatrix.Text = labelConfusionMatrix.Text;
                //start background thread to update the confusion matrice accordingly
                backgroundUpdateConfusionMatrix.RunWorkerAsync();
            }
            else
            {
                //hide all controls related to confusion matrix
                confusionMatrixGraph.Visible   = false;
                textBoxConfusionMatrix.Visible = false;
            }
        } // End the constructor for the community
        /// <summary>
        /// Initialise the form with the Worker Object
        /// </summary>
        /// <param name="currentWorker"></param>
        public FormWorkerOrCommunityDetail(Worker currentWorker, ExperimentModel relatedExperimentItem)
        {
            InitializeComponent();
            this.currentWorker = currentWorker;

            //Display the workerId in the form title
            this.Text = "[Worker]" + currentWorker.WorkerId;
            this.relatedExperimentItem = relatedExperimentItem;
            this.labelForWorkerId.Text = currentWorker.WorkerId;
            this.labelModelDetail.Text = relatedExperimentItem.ToString();
            RunType[] runTypesHaveWorkerMatrices = { RunType.DawidSkene, RunType.BCC, RunType.CBCC };

            //Only display the confusion matrices if it matches the runType
            if (runTypesHaveWorkerMatrices.Contains(relatedExperimentItem.runType))
            {
                indexOfExperimentItem = MainPage.mainPageForm.currentExperimentSetting.GetExperimenModelIndex(relatedExperimentItem);
                printableConfusionMatrix = MainPage.mainPageForm.currentExperimentSetting.getWorkerResults(indexOfExperimentItem, currentWorker.WorkerId);
                LoadConfusionMatrix();
                //SetUpChart();
                labelConfusionMatrix.Text = MainPage.mainPageForm.currentExperimentSetting.getConfusionMatrixString(printableConfusionMatrix);
                textBoxConfusionMatrix.Text = labelConfusionMatrix.Text;
                //start background thread to update the confusion matrice accordingly if it is activeLearning
                if (MainPage.mainPageForm.currentExperimentSetting.experimentType == ExperimentType.ActiveLearning)
                {
                    backgroundUpdateConfusionMatrix.RunWorkerAsync();
                }

            }
            else //for the RunType that does not have confusion matrix 
            {
                //hide all controls related to confusion matrix
                confusionMatrixGraph.Visible = false;
                textBoxConfusionMatrix.Visible = false;
            }

        }
예제 #8
0
        /// <summary>
        /// Background Thread for running the active learning experiment
        /// <param name="worker"></param>
        /// <param name="e"></param>
        public void RunParallelActiveLearning(
            System.ComponentModel.BackgroundWorker worker,
            System.ComponentModel.DoWorkEventArgs e)
        {
            //Create a state of the Thread
            CurrentParallelState currentState = new CurrentParallelState();

            //Set setting in the experimentSetting Class
            int totalNumberOfModels = GetNumberOfExperiemntModels();

            //Clear previous results
            ActiveLearning.ResetParallelAccuracyList(totalNumberOfModels);

            //obtain the accuracy list reference
            accuracyArrayOfAllExperimentModels = ActiveLearning.accuracyArray;

            //The RunTypes that have Worker Confusion Matrices
            RunType[] runTypesHaveWorkerMatrices = { RunType.DawidSkene, RunType.BCC, RunType.CBCC };

            //Set the models selected in the setting pane
            string[]                currentModelNames             = new string[totalNumberOfModels];
            RunType[]               currentRunTypes               = new RunType[totalNumberOfModels];
            TaskSelectionMethod[]   currentTaskSelectionMethods   = new TaskSelectionMethod[totalNumberOfModels];
            WorkerSelectionMethod[] currentWorkerSelectionMethods = new WorkerSelectionMethod[totalNumberOfModels];
            BCC[] currentBCCModels = new BCC[totalNumberOfModels];

            //for each ExperimentModel, set runTypeArray, taskSelectionMethodArray, workerSelectionMethodArray...
            for (int i = 0; i < totalNumberOfModels; i++)
            {
                ExperimentModel currentExperimentModel = GetExperimentModel(i);
                RunType         currentRunType         = currentExperimentModel.runType;
                currentRunTypes[i] = currentRunType;

                //set the task selection method
                currentTaskSelectionMethods[i] = currentExperimentModel.taskSelectionMethod;

                //Add into worker selection method array if the runType can have worker selection
                if (runTypesHaveWorkerMatrices.Contains(currentRunType))
                {
                    currentWorkerSelectionMethods[i] = currentExperimentModel.WorkerSelectionMethod;

                    //Add corresponding model
                    //if the RunType is BCC, add into BCC model array
                    if (currentRunType == RunType.BCC)
                    {
                        currentBCCModels[i] = new BCC();
                    }//CBCC Model
                    else if (currentRunType == RunType.CBCC)
                    {
                        CBCC currentBCCmodel = new CBCC();
                        currentBCCModels[i] = currentBCCmodel;
                    }
                } //end if the runType has worker confusion matrices
            }     //end for

            currentModelNames = currentModelNames.Select((s, i) => CrowdsourcingModels.Program.GetModelName(currentDataset.GetDataSetNameWithoutExtension(), currentRunTypes[i])).ToArray();

            //run RunParallelActiveLearning in the ActiveLearning
            ActiveLearning.RunParallelActiveLearning(currentDataset.LoadData(), currentModelNames, currentRunTypes,
                                                     currentBCCModels, currentTaskSelectionMethods, currentWorkerSelectionMethods,
                                                     communityCount, numberOfLabellingRound);

            currentState.isRunningComplete = true;
            Debug.WriteLine("RunParallelActiveLearning Complete");
            //isSimulationComplete = true;
            //worker.ReportProgress(0, currentState);
        }//end function RunParallelActiveLearning
예제 #9
0
 /// <summary>
 /// Get the index of the experimentModel
 /// </summary>
 /// <param name="experItem"></param>
 /// <returns>the index of the experimentModel in current ExperimentSetting</returns>
 public int GetExperimenModelIndex(ExperimentModel experItem)
 {
     return(experimentModels.IndexOf(experItem));
 }
예제 #10
0
 /// <summary>
 /// Add ExperimentModel into the Experiment
 /// </summary>
 /// <param name="expModel"></param>
 public void AddExperimentModel(ExperimentModel expModel)
 {
     experimentModels.Add(expModel);
 }
예제 #11
0
        /// <summary>
        /// [Active Learning] Set Task Values of the selected experiment model
        /// </summary>
        /// <param name="currentExperimentModel"></param>
        /// <param name="changeBindingSource"></param>
        private void SetTaskValues(ExperimentModel currentExperimentModel)
        {
   
            //Binding list into Worker
            BindingSource bsForWorker = new BindingSource();
            List<System.Linq.IGrouping<string, CrowdsourcingModels.ActiveLearningResult>> customQuery = (from alr in currentExperimentModel.resultsBindingList
                                                                                                        group alr by alr.TaskId into TaskIdgroup
                                                                                                        select TaskIdgroup).ToList();


            BindingList<List<System.Linq.IGrouping<string, CrowdsourcingModels.ActiveLearningResult>>> workerValuesList = new BindingList<List<System.Linq.IGrouping<string, CrowdsourcingModels.ActiveLearningResult>>>();
            workerValuesList.Add(customQuery);
            bsForWorker.DataSource = workerValuesList;

     
            int scrollPosition = dataGridViewForTaskValue.FirstDisplayedScrollingRowIndex;
            int rowIndex = -1;

            if (dataGridViewForTaskValue.SelectedRows.Count > 0)
            {
                rowIndex = dataGridViewForTaskValue.SelectedRows[0].Index;
            }


            bsForWorker.DataSource = customQuery;
            dataGridViewForTaskValue.DataSource = bsForWorker;

            if (scrollPosition != -1)
            {
                if (dataGridViewForTaskValue.FirstDisplayedScrollingRowIndex != -1)
                {
                    dataGridViewForTaskValue.FirstDisplayedScrollingRowIndex = scrollPosition;
                }

                if (rowIndex != -1 && rowIndex < dataGridViewForTaskValue.Rows.Count)
                {

                    dataGridViewForTaskValue.CurrentCell = dataGridViewForTaskValue.Rows[rowIndex].Cells[0];
                    dataGridViewForTaskValue.Rows[rowIndex].Selected = true;

                }

            }

            dataGridViewForTaskValue.Columns[0].HeaderText = "Task Id";
            SetDataGridViewHeaderToBold(dataGridViewForTaskValue);
            Debug.WriteLine("Inner Worker Court" + dataGridViewForTaskValue.ColumnCount + "");

            dataGridViewForTaskValue.AutoGenerateColumns = false;

        }
예제 #12
0
        }//end function

        /// <summary>
        /// Set worker values
        /// </summary>
        /// <param name="currentExperimentModel"></param>
        private void SetWorkerValues(ExperimentModel currentExperimentItem)
        {
            //Binging list into Worker
            BindingSource bsForWorker = new BindingSource();
            List<System.Linq.IGrouping<string, CrowdsourcingModels.ActiveLearningResult>> customQuery = (from alr in currentExperimentItem.resultsBindingList
                               group alr by alr.WorkerId into workerIdgroup
                               select workerIdgroup).ToList();


            int scrollPosition = dataGridViewForInnerWorker.FirstDisplayedScrollingRowIndex;
            int rowIndex = -1;

            if (dataGridViewForInnerWorker.SelectedRows.Count > 0) 
            {
                rowIndex = dataGridViewForInnerWorker.SelectedRows[0].Index;    
            }


            dataGridViewForInnerWorker.DataSource = customQuery;

            if (scrollPosition != -1) 
            {
                if (dataGridViewForInnerWorker.FirstDisplayedScrollingRowIndex != -1) 
                {
                    dataGridViewForInnerWorker.FirstDisplayedScrollingRowIndex = scrollPosition;
                }

                if (rowIndex != -1 && rowIndex < dataGridViewForInnerWorker.Rows.Count)
                {

                    dataGridViewForInnerWorker.CurrentCell = dataGridViewForInnerWorker.Rows[rowIndex].Cells[0];
                    dataGridViewForInnerWorker.Rows[rowIndex].Selected = true;

                }

             }

            dataGridViewForInnerWorker.Columns[0].HeaderText = "Worker Id";
            SetDataGridViewHeaderToBold(dataGridViewForInnerWorker);

            dataGridViewForInnerWorker.AutoGenerateColumns = false;

        }
        /// <summary>
        /// Initialise the form with the Worker Object
        /// </summary>
        /// <param name="currentWorker"></param>
        public FormWorkerOrCommunityDetail(int communityIndex, ExperimentModel relatedExperimentItem)
        {
            InitializeComponent();
            isWorker = false;
            this.communityIndex = communityIndex;

            //Display the workerId in the form title
            this.Text = "[Community]" + (communityIndex );
            this.labelForWorkerId.Text = "Community " + (communityIndex );
            labelTypeName.Text = "Community";

            this.relatedExperimentItem = relatedExperimentItem;
            this.labelModelDetail.Text = relatedExperimentItem.ToString();

            //The RunType that has Community Matrix
            RunType[] runTypesHaveCommunityMatrices = { RunType.CBCC };

            //Only display the confusion matrices if it matches the runType
            if (runTypesHaveCommunityMatrices.Contains(relatedExperimentItem.runType))
            {
                indexOfExperimentItem = MainPage.mainPageForm.currentExperimentSetting.GetExperimenModelIndex(relatedExperimentItem);

                //get printableConfusionMatrix 
                printableConfusionMatrix = MainPage.mainPageForm.currentExperimentSetting.getCommunityResults(indexOfExperimentItem, communityIndex);
                LoadConfusionMatrix();
    
                labelConfusionMatrix.Text = MainPage.mainPageForm.currentExperimentSetting.getConfusionMatrixString(printableConfusionMatrix);
                textBoxConfusionMatrix.Text = labelConfusionMatrix.Text;
                //start background thread to update the confusion matrice accordingly
                backgroundUpdateConfusionMatrix.RunWorkerAsync();
            }
            else
            {
                //hide all controls related to confusion matrix
                confusionMatrixGraph.Visible = false;
                textBoxConfusionMatrix.Visible = false;
            }

        } // End the constructor for the community 
 /// <summary>
 /// Get the index of the experimentModel
 /// </summary>
 /// <param name="experItem"></param>
 /// <returns>the index of the experimentModel in current ExperimentSetting</returns>
 public int GetExperimenModelIndex(ExperimentModel experItem)
 {
     return experimentModels.IndexOf(experItem);
 }
 /// <summary>
 /// Add ExperimentModel into the Experiment
 /// </summary>
 /// <param name="expModel"></param>
 public void AddExperimentModel(ExperimentModel expModel) {
     experimentModels.Add(expModel);
 }