private void Awake()
    {
        type   = SubjectInfo.testType;
        angleT = new GameObject().transform;

        soundCue.transform.position = path.Next();

        pathDistance = path.TotalDistance();
        lastPosition = subject.position;

        pathTime = pathDistance / subject.GetComponent <Movement>().GetSpeed();

        // csv file to record raw data
        string filepath = "TestResults/" + SubjectInfo.name;
        string csvFile  = "/" + SceneManager.GetActiveScene().name + ".csv";

        Directory.CreateDirectory(filepath);
        if (File.Exists(filepath + csvFile))
        {
            File.Delete(filepath + csvFile);
        }

        raw = File.CreateText(filepath + csvFile);
        raw.WriteLine("Time, Distance From Path, Angle From Next Waypoint");
    }
Exemple #2
0
        public WorkflowParameters(ArgumentParser.ParseOptions parseOptions)
        {
            ParseParams = new ParseWorkflowParameters();

            ExpType                      = ExperimentType.DDA;
            MgfIntensityCutoff           = parseOptions.IntensityCutoff;
            MgfMassCutoff                = parseOptions.MassCutOff;
            InputFiles                   = parseOptions.InputFiles;
            RawFileDirectory             = parseOptions.InputDirectory;
            RefineMassCharge             = parseOptions.RefineMassCharge;
            ParseParams.Chromatogram     = parseOptions.Chromatogram;
            ParseParams.LabelingReagents = String.Empty;
            ParseParams.LabelingReagents = parseOptions.LabelingReagents;
            ParseParams.Metrics          = parseOptions.Metrics;
            ParseParams.Parse            = parseOptions.ParseData;
            ParseParams.Quant            = parseOptions.Quant;
            ParseParams.UnlabeledQuant   = parseOptions.UnlabeledQuant;
            ParseParams.WriteMgf         = parseOptions.WriteMGF;

            if (parseOptions.OutputDirectory != null)
            {
                if (!Path.IsPathRooted(parseOptions.OutputDirectory))
                {
                    parseOptions.OutputDirectory = Path.Combine(Directory.GetCurrentDirectory(), parseOptions.OutputDirectory);
                }
            }

            ParseParams.OutputDirectory = parseOptions.OutputDirectory;
        }
        public RawFileConverter(string rawFile, string outFolder, string[] outFileTypes, ExperimentType expType, bool exportChargeState)
        {
            _rawReader = (IXRawfile5) new MSFileReader_XRawfile();
            Console.WriteLine("_rawReader created successfully.");
            int pnMajorVersion = -1, pnMinorVersion = -1, pnSubMinorVersion = -1, nBuilderNumber = -1;

            _rawReader.Version(ref pnMajorVersion, ref pnMinorVersion, ref pnSubMinorVersion, ref nBuilderNumber);
            Console.WriteLine("pnMajorVersion = " + pnMajorVersion);
            Console.WriteLine("pnMinorVersion = " + pnMinorVersion);
            Console.WriteLine("pnSubMinorVersion = " + pnSubMinorVersion);
            Console.WriteLine("nBuilderNumber = " + nBuilderNumber);

            _rawReader.Open(rawFile);
            Console.WriteLine("_rawReader open file successfully.");
            _rawReader.SetCurrentController(0, 1);

            rawFileName = rawFile;

            // get the numbers of the first and the last scans used in MSn file headers;
            _rawReader.GetFirstSpectrumNumber(ref FirstScanNum);
            _rawReader.GetLastSpectrumNumber(ref LastScanNum);
            outFolder = Path.GetDirectoryName(rawFile);
            InitWriters(Path.GetFileName(rawFile), outFolder, outFileTypes, expType, exportChargeState);

            this.expType = expType;
        }
Exemple #4
0
 protected override void RuntimeExperiment(ExperimentType et, ExperimentScenario es, DataDescription data,
                                           int tcase)
 {
     Run(et == ExperimentType.Streaming
         ? GetOnlineProcess(data, tcase, Experiment.Runtime)
         : GetOfflineProcess(data, tcase, Experiment.Runtime));
 }
        public int UpdateExperimentType(ExperimentType data)
        {
            string strSql = "update  ExperimentType set TypeName1=@TypeName1,TypeName2=@TypeName2,TypeDescribe=@TypeDescribe,UpdateDateTime=@UpdateDateTime where TypeId=@TypeId";

            return(DBFactory.GetDB(DBType.SQLITE, m_strConn).ExecuteNonQuery(strSql, new DbParameter[] {
                new SQLiteParameter()
                {
                    Value = data.TypeId, ParameterName = "@TypeId"
                },
                new SQLiteParameter()
                {
                    Value = data.TypeName1, ParameterName = "@TypeName1"
                },
                new SQLiteParameter()
                {
                    Value = data.TypeName2, ParameterName = "@TypeName2"
                },
                new SQLiteParameter()
                {
                    Value = data.TypeDescribe, ParameterName = "@TypeDescribe"
                },
                new SQLiteParameter()
                {
                    Value = data.UpdateDateTime, ParameterName = "@UpdateDateTime"
                },
            }));
        }
Exemple #6
0
 protected override void RuntimeExperiment(ExperimentType et, ExperimentScenario es,
                                           DataDescription data, int tcase)
 {
     RunNnmf(et == ExperimentType.Streaming
         ? GetNnmfProcess(data, tcase, "True", "True")
         : GetNnmfProcess(data, tcase, "True", "False")
             );
 }
Exemple #7
0
 public QcDataCollection(string directoryToWatch, string qcDirectory, ExperimentType experimentType)
 {
     DirectoryToWatch  = directoryToWatch;
     QcDirectory       = qcDirectory;
     DataType          = experimentType;
     QcFile            = Path.Combine(new string[] { qcDirectory, "QC.xml" });
     ProcessedRawFiles = new List <string>();
     QcData            = new SerializableDictionary <DateTime, QcDataContainer>();
 }
Exemple #8
0
 // Use this for initialization
 void Start()
 {
     //experimentTypes.RemoveAt(0);
     experimentType = experimentTypes[currentType];
     InitType(experimentType);
     CreateCases();
     CreateTargets();
     ShowAllTargets(false);
 }
        protected override void RuntimeExperiment(ExperimentType et, ExperimentScenario es,
                                                  DataDescription data, int tcase)
        {
            if (et == ExperimentType.Streaming)
            {
                throw new ArgumentException("Batch CD is not suitable for a streaming test.");
            }

            KList.ForEach(k => RunCd(GetRuntimeCdProcess(data.N, data.M, data, tcase, k)));
        }
        public ActionResult GetExperiment(stId ExperimentTypeId)
        {
            ExperimentType listData = ExperimentTypebll.GetExperimentType(ExperimentTypeId.Id);
            var            res      = new ConfigurableJsonResult();

            res.Data = listData;
            HttpContext.Response.AppendHeader("Access-Control-Allow-Origin", "*");

            return(res);
        }
 private static (ValueTuple <int, int, int>[], int[]) GetExperimentSetup(ExperimentType et, ExperimentScenario es,
                                                                         int nlimit)
 {
     switch (et)
     {
     case ExperimentType.Continuous:
         switch (es)
         {
         case ExperimentScenario.Missing:
             return(new[] { (0, -1, -1) }, Utils.ClosedSequence(BlockSize, BlockSize * 8, BlockSize).ToArray());
        public ActionResult IsExistData(ExperimentType data)
        {
            bool result = ExperimentTypebll.IsExistData(data);
            var  res    = new ConfigurableJsonResult();

            res.Data = result == true ? 1 : 0;
            HttpContext.Response.AppendHeader("Access-Control-Allow-Origin", "*");

            return(res);
        }
Exemple #13
0
 /// <summary>
 /// Constructors
 /// </summary>
 /// <param name="initialNumberOfLabelsPerTask"></param>
 /// <param name="currentDataset"></param>
 /// <param name="currentExperimentType"></param>
 /// <param name="numberOfIterations"></param>
 public ExperimentSetting(int initialNumberOfLabelsPerTask, Dataset currentDataset, ExperimentType currentExperimentType, int numberOfIterations = 1)
 {
     this.numberOfLabellingRound        = initialNumberOfLabelsPerTask;
     experimentModels                   = new List <ExperimentModel>();
     this.currentDataset                = currentDataset;
     accuracyArrayOfAllExperimentModels = null;
     SetInitialStartingLabel();
     this.numberOfIterations = numberOfIterations;
     this.experimentType     = currentExperimentType;
 }
        public ActionResult AddExperimentType(ExperimentType data)
        {
            //data.UpdateDateTime = DateTime.Now;
            int result = ExperimentTypebll.AddExperimentType(data);
            var res    = new ConfigurableJsonResult();

            res.Data = result;
            HttpContext.Response.AppendHeader("Access-Control-Allow-Origin", "*");

            return(res);
        }
 protected override void RuntimeExperiment(ExperimentType et, ExperimentScenario es,
                                           DataDescription data, int tcase)
 {
     if (et == ExperimentType.Streaming)
     {
         KList.ForEach(k => RunCd(GetStreamingCdProcess(data.N, data.M, data, tcase, k)));
     }
     else
     {
         KList.ForEach(k => RunCd(GetRuntimeCdProcess(data.N, data.M, data, tcase, k)));
     }
 }
 protected override void RuntimeExperiment(ExperimentType et, ExperimentScenario es,
                                           DataDescription data, int tcase)
 {
     if (et == ExperimentType.Streaming)
     {
         KList.ForEach(k => Run(GetOnlineProcess(data, tcase, k, Experiment.Runtime)));
     }
     else
     {
         KList.ForEach(k => Run(GetOfflineProcess(data, tcase, k, Experiment.Runtime)));
     }
 }
Exemple #17
0
        public WorkflowParameters(ArgumentParser.QcOptions qcOptions)
        {
            QcParams = new QcWorkflowParameters();
            Enum.TryParse(qcOptions.SearchAlgorithm, true, out QcParams.SearchAlgorithm);

            ExpType = ExperimentType.DDA;

            MgfIntensityCutoff = qcOptions.IntensityCutoff;
            MgfMassCutoff      = qcOptions.MassCutOff;
            RawFileDirectory   = qcOptions.DirectoryToQc;
            RefineMassCharge   = qcOptions.RefineMassCharge;

            QcParams.FastaDatabase    = qcOptions.FastaDatabase;
            QcParams.FixedMods        = qcOptions.FixedMods;
            QcParams.FixedScans       = qcOptions.FixedScans;
            QcParams.IdentipyScript   = qcOptions.IdentipyScript;
            QcParams.KMod             = qcOptions.VariableKMod;
            QcParams.NMod             = qcOptions.VariableNMod;
            QcParams.XMod             = qcOptions.VariableXMod;
            QcParams.NumberSpectra    = qcOptions.NumberSpectra;
            QcParams.PythonExecutable = qcOptions.PythonExecutable;
            QcParams.QcDirectory      = qcOptions.QcDirectory;
            QcParams.XTandemDirectory = qcOptions.XTandemDirectory;

            if (QcParams.SearchAlgorithm != SearchAlgorithm.None)
            {
                QcParams.PerformSearch = true;
            }

            if (QcParams.FastaDatabase != null)
            {
                if (!Path.IsPathRooted(QcParams.FastaDatabase))
                {
                    QcParams.FastaDatabase = Path.Combine(Directory.GetCurrentDirectory(), QcParams.FastaDatabase);
                }
            }

            if (QcParams.QcDirectory != null)
            {
                if (!Path.IsPathRooted(QcParams.QcDirectory))
                {
                    QcParams.QcDirectory = Path.Combine(Directory.GetCurrentDirectory(), QcParams.QcDirectory);
                }
            }

            if (QcParams.XTandemDirectory != null)
            {
                if (!Path.IsPathRooted(QcParams.XTandemDirectory))
                {
                    QcParams.XTandemDirectory = Path.Combine(Directory.GetCurrentDirectory(), QcParams.XTandemDirectory);
                }
            }
        }
Exemple #18
0
 protected override void RuntimeExperiment(ExperimentType et, ExperimentScenario es, DataDescription data,
                                           int tcase)
 {
     if (et == ExperimentType.Streaming)
     {
         RunTkcm(GetStreamingTkcmProcess(data, tcase, es));
     }
     else
     {
         RunTkcm(GetRuntimeTkcmProcess(data, tcase, es));
     }
 }
Exemple #19
0
    public static string Description(this ExperimentType type)
    {
        switch (type)
        {
        case ExperimentType.BioMinilab:
            return("Place a mini-greenhouse\nand wait for it to generate data");

        default:
        case ExperimentType.GeoSample:
            return("Sample the regolith\nin a deposit and return the data");
        }
    }
Exemple #20
0
        //
        // Types
        //

        public static string ToShortString(this ExperimentType et)
        {
            switch (et)
            {
            case ExperimentType.Continuous: return("btc-e");

            case ExperimentType.Recovery: return("btc-m");

            case ExperimentType.Streaming: return("str-e");

            default: throw new InvalidDataException();
            }
        }
Exemple #21
0
        public static string ToLongString(this ExperimentType et)
        {
            switch (et)
            {
            case ExperimentType.Continuous: return("batch_end");

            case ExperimentType.Recovery: return("batch_mid");

            case ExperimentType.Streaming: return("streaming_end");

            default: throw new InvalidDataException();
            }
        }
        public static void EnsureFolderStructure(ExperimentType et, List <string> scenarios)
        {
            string root = DataWorks.FolderPlotsRemote + $"{et.ToLongString()}/";

            foreach (var es in EnumMethods.AllExperimentScenarios().Where(x => scenarios.Contains(x.ToLongString())))
            {
                string esDir = $"{root}{es.ToLongString()}/";
                if (!Directory.Exists(esDir))
                {
                    Directory.CreateDirectory(esDir);
                }
            }
        }
Exemple #23
0
    private void InitType(ExperimentType type)
    {
        experimentType = type;
        targets        = new List <GameObject>();
        //alreadyShownTargets = new List<int>();
        cases = new List <Case>();

        currentCase   = 0;
        currentTarget = 0;

        switch (type)
        {
        case ExperimentType.SIMPLE: {
            pointingDevices[0].SetActive(true);
            pointingDevices[1].SetActive(false);
            viveController.gameObject.GetComponent <SphereCollider> ().isTrigger = false;
            if (viveController.GetComponent <Rigidbody> () != null)
            {
                Destroy(viveController.GetComponent <Rigidbody> ());
            }
        } break;

        case ExperimentType.CUTE: {
            pointingDevices[0].SetActive(false);
            pointingDevices[1].SetActive(true);
            viveController.gameObject.GetComponent <SphereCollider> ().isTrigger = false;
            if (viveController.GetComponent <Rigidbody> () != null)
            {
                Destroy(viveController.GetComponent <Rigidbody> ());
            }
        } break;

        case ExperimentType.DEXTERITY: {
            pointingDevices[0].SetActive(true);
            pointingDevices[1].SetActive(false);
            viveController.gameObject.GetComponent <SphereCollider> ().isTrigger = true;
            viveController.gameObject.AddComponent <Rigidbody> ();
            viveController.gameObject.GetComponent <Rigidbody> ().useGravity = false;
        } break;

        case ExperimentType.IMPACT: {
            pointingDevices[0].SetActive(true);
            pointingDevices[1].SetActive(false);
            viveController.gameObject.GetComponent <SphereCollider> ().isTrigger = false;
            if (viveController.GetComponent <Rigidbody> () != null)
            {
                Destroy(viveController.GetComponent <Rigidbody> ());
            }
        } break;
        }
    }
Exemple #24
0
        private static (ValueTuple <int, int, int>[], int[]) GetExperimentSetup(ExperimentType et, ExperimentScenario es,
                                                                                int rows, int columns)
        {
            int blockSize;
            int startOffset;
            int stepSize;

            switch (et)
            {
            case ExperimentType.Continuous:
                switch (es)
                {
                // single-column
                case ExperimentScenario.Missing:
                    blockSize = rows / 10;
                    return(new[] { (0, -1, -1) }, Utils.ClosedSequence(blockSize, blockSize * 8, blockSize).ToArray());
Exemple #25
0
        //
        // multi-purpose
        //
        public static bool IsMatch(this ExperimentType et, ExperimentScenario es)
        {
            switch (et)
            {
            case ExperimentType.Streaming:
                return(es.IsStreaming());

            case ExperimentType.Continuous:
                return(es.IsContinuous());

            case ExperimentType.Recovery:
                return(es.IsBatchMid());

            default:
                return(false);
            }
        }
        private List <ExperimentType> DataTableToList(DataTable dt)
        {
            List <ExperimentType> listInfo = new List <ExperimentType>();

            if (dt != null)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    ExperimentType info = new ExperimentType();
                    info.TypeDescribe = dr["TypeDescribe"] == DBNull.Value ? "" : dr["TypeDescribe"].ToString();
                    info.TypeId       = dr["TypeId"] == DBNull.Value ? -100 : Convert.ToInt32(dr["TypeId"]);
                    info.TypeName1    = dr["TypeName1"] == DBNull.Value ? "" : dr["TypeName1"].ToString();
                    info.TypeName2    = dr["TypeName2"] == DBNull.Value ? "" : dr["TypeName2"].ToString();
                    listInfo.Add(info);
                }
            }

            return(listInfo);
        }
Exemple #27
0
        /// <summary>
        /// Determines with what kind of experiment we're dealing with and instatiates an object of the accurate
        /// subclass derived from the abstract baseclass read the experiments properties and data.
        /// WiffScanTypeEnumeration: Q1, MRM, SimQ1, Q3, SimQ3, Undefined, PrecursorIon, ProductIon, NeutralLoss, TofMS,
        /// TofProductIon, TofPrecursorIon, EnhancedProductIon, EnhancedResolution, MS3, TimeDelayFragmentation, EnhancedMS, EnhancedMulticharge,
        /// </summary>
        /// <param name="msexperiment"> The msexperiment. </param>
        /// <param name="wiffsample"> The wiffsample. </param>
        /// <returns> The newly created, <see cref="WiffExperiment"/> dirived object. </returns>
        public static WiffExperiment CreateWiffExperiment(MSExperiment msexperiment, WiffSample wiffsample)
        {
            ExperimentType expType = msexperiment.Details.ExperimentType;

            WiffExperiment theExperiment;

            switch (expType)
            {
            case ExperimentType.MRM:
            {
                theExperiment = new MrmScanExperiment(msexperiment, wiffsample);
            }

            break;

            case ExperimentType.MS:
            {
                theExperiment = new MsScanExperiment(msexperiment, wiffsample);
            }

            break;

            case ExperimentType.Precursor:
            case ExperimentType.NeutralGainOrLoss:
            case ExperimentType.Product:
            case ExperimentType.SIM:
            {
                theExperiment = new MsScanExperiment(msexperiment, wiffsample);
            }

            break;

            default:
            {
                // TODO -- Check if this is really, really intended...??
                theExperiment = new MrmScanExperiment(msexperiment, wiffsample);
            }

            break;
            }

            return(theExperiment);
        }
        /// <summary>
        /// Call this method when the view is changed, enables/shows the
        /// controls and sets the current Experiment Type
        /// </summary>
        /// <param name="expType">Experiment Type</param>
        public void ViewChanged(ExperimentType expType)
        {
            switch (expType)
            {
            case ExperimentType.MRM:
                this.MsExpControlIsEnabledVisible(false, Visibility.Hidden);
                break;

            case ExperimentType.MS:
            case ExperimentType.NeutralGainOrLoss:
            case ExperimentType.Precursor:
            case ExperimentType.Product:
            case ExperimentType.SIM:
                this.MsExpControlIsEnabledVisible(true, Visibility.Visible);
                break;
            }

            this.CurrentExperimentType = expType;
        }
Exemple #29
0
        private static IExperiment GenerateExperimentData(ExperimentType type)
        {
            Console.WriteLine("Enter minimal element length: ");
            var minElemLength = int.Parse(Console.ReadLine());

            Console.WriteLine("Enter maximal element length: ");
            var maxElemLength = int.Parse(Console.ReadLine());

            Console.WriteLine("Enter start collection length: ");
            var minCollectionLength = int.Parse(Console.ReadLine());

            Console.WriteLine("Enter maximal collection length: ");
            var maxCollectionLength = int.Parse(Console.ReadLine());

            Console.WriteLine($"Enter {type.ToString()} increment: ");
            var increment = type == ExperimentType.Arithmetic
                ? int.Parse(Console.ReadLine())
                : double.Parse(Console.ReadLine());

            Console.WriteLine("Enter repeats amount: ");
            var repeats = int.Parse(Console.ReadLine());

            return(type == ExperimentType.Geometric
                ? new GeometricProgressionExperiment()
            {
                MinimalElementLength = minElemLength,
                MaximalElementLength = maxElemLength,
                StartCollectionLength = minCollectionLength,
                MaximalCollectionLength = maxCollectionLength,
                LengthIncrement = increment,
                Repeats = repeats
            }
                : new ArithmeticProgressionExperiment()
            {
                MinimalElementLength = minElemLength,
                MaximalElementLength = maxElemLength,
                StartCollectionLength = minCollectionLength,
                MaximalCollectionLength = maxCollectionLength,
                LengthIncrement = (int)increment,
                Repeats = repeats
            });
        }
Exemple #30
0
        private static void RunExperiment(IExperiment expData, string filename, ExperimentType expType)
        {
            var data = new List <string>();

            for (var i = 0; i < expData.Repeats; i++)
            {
                var elementsAmount = expData.StartCollectionLength;
                while (elementsAmount <= expData.MaximalCollectionLength)
                {
                    data.Clear();
                    FillListRandomly(data, elementsAmount, expData.MinimalElementLength, expData.MaximalElementLength);
                    var operations = Sort <string> .ByBubble(data).totalOperations;

                    File.AppendAllText($"{filename}_Result.csv", $"{elementsAmount};{operations}\n");
                    elementsAmount = expType == ExperimentType.Arithmetic
                        ? elementsAmount + (int)expData.LengthIncrement
                        : (int)(elementsAmount * expData.LengthIncrement);
                }
            }
        }
        /// <summary>
        /// Open the experiment setting pane with the required experiment Type (ie ActiveLearning, BatchRunning)
        /// </summary>
        /// <param name="currentExperimentType"></param>
        private void OpenExperimentSettingPane(ExperimentType currentExperimentType)
        {
            //If the experiment is not started or is stopped
            if (!isExperimentRunning && isExperimentComplete)
            {
                //Close current experiment settingPane
                CloseExperimentSettingPane();
                experimentSettingForm = new FormExperimentSetting(currentExperimentType);

                //enable the FormActiveLearningSetting window always on the top
                experimentSettingForm.Owner = this;
                experimentSettingForm.Show();
            }
        }
        /// <summary>
        /// Create an ExperimentSetting instance for the selected dataset
        /// </summary>
        /// <param name="datasetPath">the dataset path going to examine</param>
        /// <param name="totalLabellingRound">the total number of labelling round</param>
        /// <pa
        /// ram name="currentTaskSelectionMethods">An array containing the selected task selection methods from user</param>
        /// <param name="currentRunTypes">An array containing the selected run types from user</param>
        /// <param name="mabConstant">The mab constant value for the EntropyMABTask</param>
        public void SetNewExperimentSettings(Dataset currentDataset, int totalLabellingRound, List<ExperimentModel> experimentItemList, ExperimentType experimentType, int numberOfIterations = 1)
        {
            currentExperimentSetting = new ExperimentSetting(totalLabellingRound, currentDataset, experimentType, numberOfIterations);

            if (totalLabellingRound > 1) 
            {
                if (experimentItemList.Count == 1) 
                {
                    currentExperimentSetting.numberOfLabellingRound = experimentItemList[0].numberOfLabellingRound;
                }
            }
            for (int i = 0; i < experimentItemList.Count; i++)
            {
                currentExperimentSetting.AddExperimentModel(experimentItemList[i]);
            }
            InitialiseActiveLearningExperiment();
        }
        }// End Event Handler

        /// <summary>
        /// Check if another experiment is running
        /// </summary>
        /// <param name="currentExperimentType"></param>
        private void CheckIfAnotherExperimentIsRunning(ExperimentType currentExperimentType)
        {
            //pop up a confirm dialog whether to terminate another running experiment
            if (isExperimentRunning && currentExperimentSetting.experimentType != currentExperimentType)
            {

                tabControlForMainPage.SelectedIndex = currentRunningExperimentItemIndex;
            }           
                        
        }
Exemple #34
0
 public static bool SaveDoubleExperimentData(ExperimentType experiment_name, DoubleExperimentData experiment_data)
 {
     string string_of_save_experiment_data = string.Format("insert into `" + experiment_name.ToString() + "` (`ExperimentRecordID`,`Time`,`MilliSecond`,`GroupIndex`," +
         "`LeftSceneNature`,`LeftSceneName`,`RightSceneNature`,`RightSceneName`,`FaceNature`,`FaceName`, `FacePos`, `Judgement`,`TrialTime`) values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}');",
         experiment_data.ExperimentRecordID.ToString(), experiment_data.Time.ToString(), experiment_data.MilliSecond.ToString(), experiment_data.GroupIndex.ToString(),
         Convert.ToInt32(experiment_data.LeftSceneNature).ToString(), experiment_data.LeftSceneName,
         Convert.ToInt32(experiment_data.RightSceneNature).ToString(), experiment_data.RightSceneName,
         Convert.ToInt32(experiment_data.FaceNature).ToString(), experiment_data.FaceName,
         Convert.ToInt32(experiment_data.FacePos).ToString(), Convert.ToInt32(experiment_data.Judgement).ToString(),
         experiment_data.TrialTime.ToString());
     if (_DatabaseInUse == DatabaseType.MySql)
     {
         if (MySql.MySqlHelper.ExecuteCommand(string_of_save_experiment_data) != 1)
             return false;
         return true;
     }
     else
     {
         return false;
     }
 }
Exemple #35
0
        public static bool GetExperimentRecordID(int user_info_ID, ExperimentType experiment_name, int times, out int experiment_record_ID)
        {
            string string_of_query = "select `ExperimentRecordID` from `" + ExperimentRecordTableName + "` where `UserInfoID`='" + user_info_ID.ToString() +
                "' and `ExperimentName`='" + Convert.ToInt32(experiment_name).ToString() + "' and `Times`='" + times.ToString() + "';";
            experiment_record_ID = 0;

            if (_DatabaseInUse == DatabaseType.MySql)
            {
                DataSet dataset = MySql.MySqlHelper.ExecuteQuery(string_of_query);
                if (dataset.Tables[0].Rows.Count == 0)
                    return false;
                DataRow row = dataset.Tables[0].Rows[0];
                DataColumnCollection colums = dataset.Tables[0].Columns;
                experiment_record_ID = Convert.ToInt32(row[colums[0]].ToString());
                return true;
            }
            else
            {
                return false;
            }
        }
Exemple #36
0
 // @count: 某人做某个实验做了多少次
 public static bool GetExperimentRecordCount(int user_info_ID, ExperimentType experiment_name, out int count)
 {
     string string_of_get_count = "select count(`ExperimentRecordID`) from `" + ExperimentRecordTableName + "` where `UserInfoID`='" + user_info_ID.ToString() +
         "' and `ExperimentName`='" + Convert.ToInt32(experiment_name).ToString() + "';";
     count = 0;
     if (_DatabaseInUse == DatabaseType.MySql)
     {
         count = Convert.ToInt32(MySql.MySqlHelper.ExcuteCalculation(string_of_get_count));
         return true;
     }
     else
     {
         return false;
     }
 }
        public FormExperimentSetting(ExperimentType currentExperimentType)
        {
            InitializeComponent();
            this.currentExperimentType = currentExperimentType;
        
            dropDownListOfWorkerSelectionMethod.Items.AddRange(Enum.GetNames(typeof(WorkerSelectionMethod)));

            //set current FormActiveLearningSetting instance pointer
            currentFormInstance = this;
            //Obtain all available datasets
            comboBoxForSelectingDataset.Items.AddRange(GlobalVariables.getAllDatasetNames());
            comboBoxForSelectingDataset.SelectedIndex = 0;

            dropDownListOfWorkerSelectionMethod.SelectedIndex = 0;
            //Run Default Experiment Settings
            RunDefaultExperimentSettings();
            SetComboBoxListOfRunTypesValue();
            currentListOfExperimentModels = new List<ExperimentModel>();

            //change the visibility of the buttons according to the current experiment type
            switch (currentExperimentType)
            {
                case ExperimentType.BatchRunning:
                   
                    btnRunExperiment.Visible = false; 
                    buttonRunBatchRunning.Visible = true;

                    //disable task selection method and worker selection method
                    labelTaskSelectionMethod.Visible = false;
                    comboBoxListOfTaskSelectionMethods.Visible = false;
                    labelWorkerSelectionMethod.Visible = false;
                    dropDownListOfWorkerSelectionMethod.Visible = false;
                    //change the outerbox to the corresponding experiment Type
                    groupBoxExperimentOuterBox.Text = "Batch Running Settings";
                    deleteButtonIndex = 1;
                    groupBoxInitialNumberOfLabelling.Visible = false;

                    //Enlarge the RunType and the AddModel Button
                    comboBoxListOfRunTypes.Width = 727;
                    break;

                case ExperimentType.ActiveLearning:

                    btnRunExperiment.Visible = true;
                    buttonRunBatchRunning.Visible = false;
                    deleteButtonIndex = 3;
                    //Enable task selection method and worker selection method
                    labelTaskSelectionMethod.Visible = true;
                    comboBoxListOfTaskSelectionMethods.Visible = true;
                    labelWorkerSelectionMethod.Visible = true;
                    dropDownListOfWorkerSelectionMethod.Visible = true;
                    groupBoxInitialNumberOfLabelling.Visible = true;
             
                    groupBoxExperimentOuterBox.Text = "Active Learning Settings";

                    //Reset the normal size of the RunType and the AddModel Button
                    comboBoxListOfRunTypes.Width = 256;
                    break;

                default:
                    break;
            }

            initCurrentModels();
        } //end Constructor
        /// <summary>
        /// Restart the experiment
        /// </summary>
        /// <param name="currentExperimentType"></param>
        /// <param name="playAndPauseButton"></param>
        /// <param name="currentProgressBar"></param>
        private void HandleRestartExperiment(ExperimentType currentExperimentType, Button playAndPauseButton, KryptonProgressBar currentProgressBar )
        {
            DialogResult messageBoxResult = MessageBox.Show("Are you sure to restart the simulation?", "Restart Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            // Confirm before stopping the experiment
            if (messageBoxResult == DialogResult.Yes)
            {
                isExperimentComplete = true;
                isExperimentRunning = false;

                // Cancel the asynchronous operation. 
                //Stop backgroundWorkers
                if (currentExperimentType == ExperimentType.ActiveLearning)
                {
                    this.backgroundWorkerForSimulation.CancelAsync();
                    this.backgroundWorkerForAccuracyGraph.CancelAsync();
                    ActiveLearning.isExperimentCompleted = true;
                }
                else if (currentExperimentType == ExperimentType.BatchRunning)
                {
                    this.backgroundWorkerBatchRunning.CancelAsync();
                }

                //Show Stopped message on the progress bar
                currentProgressBar.DisplayText = "Simulation Stopped";

                //initialTheExperiment and pop up the 
                experimentSettingForm = new FormExperimentSetting(currentExperimentType);
                experimentSettingForm.setPreviousExperimentSetting(currentExperimentSetting);
                //enable the FormActiveLearningSetting window always on the top
                experimentSettingForm.Owner = this;
                experimentSettingForm.Show();
                resetDataGridView();
                return;
            }
        
        }
        /// <summary>
        /// Handle Stop Button Event
        /// </summary>
        /// <param name="currentExperimentType"></param>
        /// <param name="playAndPauseButton"></param>
        /// <param name="currentProgressBar"></param>
        private void HandleStopButton(ExperimentType currentExperimentType, Button playAndPauseButton, KryptonProgressBar currentProgressBar )
        {
            DialogResult messageBoxResult = MessageBox.Show("Are you sure? The simulation will be stopped.", "Stop Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            // Confirm before stopping the experiment
            if (messageBoxResult == DialogResult.Yes)
            {
                isExperimentComplete = true;
                isExperimentRunning = false;

                // Cancel the asynchronous operation. 
                //Stop backgroundWorkers if it is the ActiveLearning Experiment 
                if (currentExperimentType == ExperimentType.ActiveLearning)
                {
                    this.backgroundWorkerForSimulation.CancelAsync();
                    this.backgroundWorkerForAccuracyGraph.CancelAsync();
                    ActiveLearning.isExperimentCompleted = true;

                }// when it is the BatchRunning Experiment
                else if(currentExperimentType == ExperimentType.BatchRunning)
                {
                    this.backgroundWorkerBatchRunning.CancelAsync();
                }

                //change the progress bar status
                currentProgressBar.DisplayText = "Simulation Stopped";

                //change to the play icon
                playAndPauseButton.BackgroundImage = global::AcriveCrowdGUI.Properties.Resources.Play_1_Normal_icon;

            } //End if confirm to stop the experiment
        } //End HandleStopButton
        } //end of button handler

        /// <summary>
        /// General Event Handler of playing and pause the experiment
        /// </summary>
        /// <param name="currentExpType"></param>
        private void HandlePlayAndPauseExperiment(ExperimentType currentExpType, Button playAndPauseButton)
        {

            //Change the PlayAndPauseButton according to current ExperimentType,
            //pop up the setting form if the experiment is complete
            if (isExperimentComplete)
            {
                //initial TheExperiment and pop up the 
                experimentSettingForm = new FormExperimentSetting(currentExpType);
                experimentSettingForm.setPreviousExperimentSetting(currentExperimentSetting);
                //enable the FormActiveLearningSetting window always on the top
                experimentSettingForm.Owner = this;
                experimentSettingForm.Show();

                //change to the pause icon
                playAndPauseButton.BackgroundImage = global::AcriveCrowdGUI.Properties.Resources.Pause_Hot_icon;

                return;
            }

            isExperimentRunning = !isExperimentRunning;

            //Pause the experiment
            if (isExperimentRunning)
            {
                //change to the pause icon
                playAndPauseButton.BackgroundImage = global::AcriveCrowdGUI.Properties.Resources.Pause_Hot_icon;
         
            }
            else
            {
                //change to the play icon
                playAndPauseButton.BackgroundImage = global::AcriveCrowdGUI.Properties.Resources.Play_1_Normal_icon;

            }
        
        }
        /// <summary>
        /// Constructors
        /// </summary>
        /// <param name="initialNumberOfLabelsPerTask"></param>
        /// <param name="currentDataset"></param>
        /// <param name="currentExperimentType"></param>
        /// <param name="numberOfIterations"></param>
        public ExperimentSetting(int initialNumberOfLabelsPerTask, Dataset currentDataset, ExperimentType currentExperimentType, int numberOfIterations = 1)
        {

            this.numberOfLabellingRound = initialNumberOfLabelsPerTask;
            experimentModels = new List<ExperimentModel>();
            this.currentDataset = currentDataset;
            accuracyArrayOfAllExperimentModels = null;
            SetInitialStartingLabel();
            this.numberOfIterations = numberOfIterations;
            this.experimentType = currentExperimentType;

        }