Exemple #1
0
        }//end function RunParallelActiveLearning

        /// <summary>
        /// RunBatchRunning experiment in background thread
        /// </summary>
        /// <param name="worker"></param>
        /// <param name="e"></param>
        public void RunBatchRunningExperiment(
            System.ComponentModel.BackgroundWorker worker,
            System.ComponentModel.DoWorkEventArgs e)
        {
            CurrentParallelState currentState;
            //Get the number of the total experiment Items
            int totalNumberOfModels = GetNumberOfExperiemntModels();

            //A List of Results array ofreport all experimentItems
            results = new List <Results>();

            currentState = new CurrentParallelState();

            //Running the current experimentSetting lists and runGold accordinglyb
            foreach (ExperimentModel currentExpItem in experimentModels)
            {
                //currentState.currentExperimentModel = currentExpItem;
                if (MainPage.mainPageForm.isExperimentComplete)
                {
                    return;
                }

                currentState = new CurrentParallelState();
                currentState.currentExperimentModelIndex = GetExperimenModelIndex(currentExpItem);
                currentState.isCurrentModelCompleted     = false;
                //Pass the started currentIndex to the mainpage, such that this currentExpItem is started
                worker.ReportProgress(0, currentState);

                //Create a BCC/CBCC model of the Batch Running Experiment
                BCC currentModel = null;
                if (currentExpItem.runType == RunType.BCC)
                {
                    currentModel = new BCC();
                }
                else if (currentExpItem.runType == RunType.CBCC)
                {
                    currentModel = new CBCC();
                    ((CBCC)currentModel).SetCommunityCount(MainPage.mainPageForm.currentExperimentSetting.communityCount);
                }

                //When the experiment is not running
                while (!MainPage.mainPageForm.isExperimentRunning)
                {
                }

                if (MainPage.mainPageForm.isExperimentComplete)
                {
                    return;
                }
                results.Add(CrowdsourcingModels.Program.RunBatchLearning(currentDataset.DatasetPath, currentExpItem.runType, currentModel, MainPage.mainPageForm.currentExperimentSetting.communityCount));

                //When the experiment is not running
                while (!MainPage.mainPageForm.isExperimentRunning)
                {
                }


                if (MainPage.mainPageForm.isExperimentComplete)
                {
                    return;
                }
                //add the results into the List<Results[]>
                //convert the lists into a single array of results (using LINQ)
                //notify the mainPage UI while it is completed
                currentState.isCurrentModelCompleted = true;
                worker.ReportProgress(0, currentState);
            } // For each experimentItem

            //The Batch Running is completed
            currentState.isRunningComplete = true;
        }
Exemple #2
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