Inheritance: EventType
Ejemplo n.º 1
0
        /// <summary>
        /// Runs a model with the full gold set.
        /// </summary>
        /// <param name="dataSet">The data.</param>
        /// <param name="runType">The model run type.</param>
        /// <param name="model">The model instance.</param>
        /// <param name="communityCount">The number of communities (only for CBCC).</param>
        /// <returns>The inference results</returns>
        static Results RunGold(string dataSet, RunType runType, BCC model, int communityCount = 3)
        {
            // Reset the random seed so results can be duplicated for the paper
            Rand.Restart(12347);
            var data = Datum.LoadData(@".\Data\" + dataSet + ".csv");

            string  modelName = GetModelName(dataSet, runType, TaskSelectionMethod.EntropyTask, WorkerSelectionMethod.RandomWorker);
            Results results   = new Results();

            switch (runType)
            {
            case RunType.VoteDistribution:
                results.RunMajorityVote(data, true, true);
                break;

            case RunType.MajorityVote:
                results.RunMajorityVote(data, true, false);
                break;

            case RunType.DawidSkene:
                results.RunDawidSkene(data, true);
                break;

            default:
                results.RunBCC(ResultsDir + modelName, data, data, model, Results.RunMode.ClearResults, false, communityCount, false, false);
                break;
            }

            // Write the inference results on a csv file
            using (StreamWriter writer = new StreamWriter(ResultsDir + "endpoints.csv", true))
            {
                writer.WriteLine("{0},{1:0.000},{2:0.0000}", modelName, results.Accuracy, results.NegativeLogProb);
            }
            return(results);
        }
Ejemplo n.º 2
0
    //public static void RunIntervalTypeInsert(string myRun, bool dbconOpened)
    public static new int Insert(RunType t, string tableName, bool dbconOpened)
    {
        //done here for not having twho dbconsOpened
        //double distance = t.Distance;

        //string [] myStr = myRun.Split(new char[] {':'});
        if(! dbconOpened) {
            dbcon.Open();
        }
        dbcmd.CommandText = "INSERT INTO " + tableName +
                " (uniqueID, name, distance, tracksLimited, fixedValue, unlimited, description, distancesString)" +
                " VALUES (NULL, '" +
                /*
                myStr[0] + "', " + myStr[1] + ", " +	//name, distance
                myStr[2] + ", " + myStr[3] + ", " +	//tracksLimited, fixedValue
                myStr[4] + ", '" + myStr[5] + ", " +	//unlimited, description
                myStr[6] + "')" ;			//distancesString
                */
                //t.Name + 	"', " + distance + ", " + t.TracksLimited + 	", " + t.FixedValue + ", " +
                t.Name + 	"', " + t.Distance + ", " + Util.BoolToInt(t.TracksLimited) + 	", " + t.FixedValue + ", " +
                Util.BoolToInt(t.Unlimited) + 	", '" + t.Description +	"', '" + t.DistancesString + 	"')" ;
        Log.WriteLine(dbcmd.CommandText.ToString());
        dbcmd.ExecuteNonQuery();

        //int myLast = dbcon.LastInsertRowId;
        //http://stackoverflow.com/questions/4341178/getting-the-last-insert-id-with-sqlite-net-in-c
        string myString = @"select last_insert_rowid()";
        dbcmd.CommandText = myString;
        int myLast = Convert.ToInt32(dbcmd.ExecuteScalar()); // Need to type-cast since `ExecuteScalar` returns an object.

        if(! dbconOpened) {
            dbcon.Close();
        }
        return myLast;
    }
Ejemplo n.º 3
0
        internal async Task <Tuple <bool, string> > ConfigureAgentJobStep(
            string ownerUri,
            AgentJobStepInfo stepInfo,
            ConfigAction configAction,
            RunType runType)
        {
            return(await Task <Tuple <bool, string> > .Run(() =>
            {
                try
                {
                    if (string.IsNullOrWhiteSpace(stepInfo.JobName))
                    {
                        return new Tuple <bool, string>(false, "JobId cannot be null");
                    }

                    JobData jobData;
                    CDataContainer dataContainer;
                    CreateJobData(ownerUri, stepInfo.JobName, out dataContainer, out jobData);

                    using (var jobStep = new JobStepsActions(dataContainer, jobData, stepInfo, configAction))
                    {
                        var executionHandler = new ExecutonHandler(jobStep);
                        executionHandler.RunNow(runType, this);
                    }

                    return new Tuple <bool, string>(true, string.Empty);
                }
                catch (Exception ex)
                {
                    // log exception here
                    return new Tuple <bool, string>(false, ex.ToString());
                }
            }));
        }
Ejemplo n.º 4
0
 protected override async Task _runOnce(RunType runType, CancellationToken ctk = default)
 {
     using (var scope = AsyncScopedLifestyle.BeginScope(_container))
     {
         await base._runOnce(runType, ctk);
     }
 }
Ejemplo n.º 5
0
        internal async Task <Tuple <bool, string> > ConfigureAgentJob(
            string ownerUri,
            string originalJobName,
            AgentJobInfo jobInfo,
            ConfigAction configAction,
            RunType runType)
        {
            return(await Task <Tuple <bool, string> > .Run(() =>
            {
                try
                {
                    JobData jobData;
                    CDataContainer dataContainer;
                    CreateJobData(ownerUri, originalJobName, out dataContainer, out jobData, configAction, jobInfo);

                    using (JobActions actions = new JobActions(dataContainer, jobData, configAction))
                    {
                        ExecuteAction(actions, runType);
                    }

                    return new Tuple <bool, string>(true, string.Empty);
                }
                catch (Exception ex)
                {
                    return new Tuple <bool, string>(false, ex.ToString());
                }
            }));
        }
Ejemplo n.º 6
0
        public ActionResult <bool> Move(MirDirection mirDirection, RunType runType)
        {
            int x = 0, y = 0;

            switch (mirDirection)
            {
            case MirDirection.Up:
                y = -70;
                break;

            case MirDirection.UpRight:
                y = -70;
                x = 70;
                break;

            case MirDirection.Right:
                x = 90;
                break;

            case MirDirection.DownRight:
                y = 70;
                x = 70;
                break;

            case MirDirection.Down:
                y = 70;
                break;

            case MirDirection.DownLeft:
                y = 70;
                x = -70;
                break;

            case MirDirection.Left:
                x = -90;
                break;

            case MirDirection.UpLeft:
                x = -70;
                y = -70;
                break;
            }
            //dmsoft.MoveTo(mirContext.MouseCenter.X, mirContext.MouseCenter.Y);
            //Thread.Sleep(2000);
            dmsoft.MoveTo(mirContext.MouseCenter.X + x, mirContext.MouseCenter.Y + y);
            Thread.Sleep(10);
            if (runType == RunType.Normal)
            {
                dmsoft.LeftDown();
                Thread.Sleep(200);
                dmsoft.LeftUp();
            }
            else
            {
                dmsoft.RightDown();
                Thread.Sleep(300);
                dmsoft.RightUp();
            }
            return(new ActionResult <bool>(true));
        }
        public bool IsEgligible(RunAggregateData runData)
        {
            RunType runType = runData.GetRunTypeEnum();

            switch (SelectedRunType)
            {
            case TYPE_STANDARD:
                return(runType == RunType.Class && runData.GetSpChallengeId().IsNullOrEmpty());

            case TYPE_EXPERT:
                return(runType == RunType.Class && !runData.GetSpChallengeId().IsNullOrEmpty());

            case TYPE_DAILY:
                return(runType == RunType.Daily);

            case TYPE_HELLRUSH:
                return(runType == RunType.Matchmaker);

            case TYPE_CUSTOM:
                return(runType == RunType.Custom);

            case TYPE_SHARE:
                return(runType == RunType.Share);

            default:
                return(true);
            }
        }
Ejemplo n.º 8
0
        public static IEnumerator RestartBattleCoroutine(BattleHud battleHud)
        {
            // Get managers from battleHud private fields
            CombatManager    combatManager    = Traverse.Create(battleHud).Field("combatManager").GetValue <CombatManager>();
            GameStateManager gameStateManager = Traverse.Create(combatManager).Field("gameStateManager").GetValue <GameStateManager>();
            SaveManager      saveManager      = Traverse.Create(combatManager).Field("saveManager").GetValue <SaveManager>();
            ScreenManager    screenManager    = Traverse.Create(battleHud).Field("screenManager").GetValue <ScreenManager>();
            CardManager      cardManager      = Traverse.Create(battleHud).Field("cardManager").GetValue <CardManager>();
            CardStatistics   cardStatistics   = Traverse.Create(cardManager).Field("cardStatistics").GetValue <CardStatistics>();

            // Get the current type of run that you're playing
            RunType runType   = Traverse.Create(saveManager).Field("activeRunType").GetValue <RunType>();
            string  sharecode = Traverse.Create(saveManager).Field("activeSharecode").GetValue <string>();

            // Return to the main menu
            // Note: Copied from PauseDialog.ReturnToMainMenu()
            gameStateManager.LeaveGame();
            screenManager.ReturnToMainMenu();
            cardStatistics.ResetAllStats();

            // Wait until the main menu is loaded
            yield return(new WaitUntil(() => SceneManager.GetActiveScene().name == "main_menu" && SceneManager.GetActiveScene().isLoaded));

            yield return(null);

            yield return(null);

            yield return(null);

            // Resume your battle from the main menu
            gameStateManager.ContinueRun(runType, sharecode);
        }
Ejemplo n.º 9
0
            public void Initialize(RunType type, RunTextType textType, uint kind, int length, int value)
            {
                InternalDebug.Assert(length <= MaxRunLength && value < MaxRunValue && (kind > MaxRunValue || kind == 0));

                this.lengthAndType = (uint)length | (uint)type | (uint)textType;
                this.valueAndKind  = (uint)value | (uint)kind;
            }
Ejemplo n.º 10
0
        internal void AddAllProjectIssues()
        {
            if (CodeRush.Source.ActiveProject == null)
            {
                Error(null, new ErrorArgs(new Exception("You must have a file open in the project you wish to scan.")));
            }
            else
            {
                try
                {
                    runType        = RunType.Project;
                    processedFiles = 0;
                    CodeIssues.Clear();
                    activeProject = CodeRush.Source.ActiveProject;
                    totalFiles    = CodeRush.Source.ActiveProject.AllFiles.Count;

                    foreach (SourceFile file in CodeRush.Source.ActiveProject.AllFiles)
                    {
                        CheckIssues(file);
                    }
                }
                catch (Exception err)
                {
                    Debug.Assert(false, "Error Scanning Project", err.Message);
                }
            }
        }
Ejemplo n.º 11
0
        public void PopulationRenwalManagerGetsRightInfoTest(RunType runType)
        {
            var generation = 0;
            var populationRenwalManager = A.Fake <IPopulationRenwalManager>();

            A.CallTo(() => populationRenwalManager.ShouldRenew(A <Population> ._, A <IEnvironment> ._, A <int> ._)).Invokes(
                (Population p, IEnvironment e, int g) =>
            {
                Assert.AreEqual(generation, g, "Wrong generation");
                foreach (var chromosome in p.GetChromosomes())
                {
                    Assert.AreEqual(generation + 1, chromosome.Evaluate(), "Wrong chromosome");
                }
                foreach (var evaluation in p.GetEvaluations())
                {
                    Assert.AreEqual(generation + 1, evaluation, "Wrong evaluation");
                }
                generation++;
            });
            var populationManager = new TestPopulationManager(new[]
                                                              { new double[] { 1, 1, 1 }, new double[] { 2, 2, 2 }, new double[] { 3, 3, 3 } });

            using (var engine = new TestGeneticSearchEngineBuilder(POPULATION_SIZE, 3, populationManager)
                                .AddPopulationRenwalManager(populationRenwalManager).IncludeAllHistory().Build())
            {
                engine.Run(runType);
            }
        }
Ejemplo n.º 12
0
        private async Task Run(RunType runType)
        {
            if (!InitializiedInterpretor() || _interpreter == null)
            {
                MessageBox.Show("Interpretorの作成に失敗しました");
                return;
            }
            var interpreter = _interpreter;

            MemoryVM.IsReadOnly  = true;
            EditrVM.RunningState = Editor.RunningState.Running;
            await Task.Run(() => interpreter.ExecuteNextCode(runType));

            var state = interpreter.State switch
            {
                RunnningState.Runnning => Editor.RunningState.Running,
                RunnningState.Pause => Editor.RunningState.Pause,
                _ => Editor.RunningState.Stop
            };

            EditrVM.RunningState = state;

            MemoryVM.IsReadOnly = false;
            StopInterpretorRunEvent?.Invoke(interpreter);
            UpdateDebuggerState();
        }
Ejemplo n.º 13
0
        /// <summary>
        /// </summary>
        /// <param name="runType"></param>
        /// <param name="sender"></param>
        /// <returns>execution result</returns>
        public ExecutionMode Run(RunType runType, object sender)
        {
            //dispatch the call to the right method
            switch (runType)
            {
            case RunType.RunNow:
                this.managementAction.OnRunNow(sender);
                break;

            case RunType.ScriptToWindow:
                this.managementAction.OnScript(sender);
                break;

            default:
                throw new InvalidOperationException(SR.UnexpectedRunType);
            }

            if ((this.managementAction.LastExecutionResult == ExecutionMode.Failure) ||
                (this.managementAction.LastExecutionResult == ExecutionMode.Cancel))
            {
                return(this.managementAction.LastExecutionResult);
            }

            // if we're here, everything went fine
            return(ExecutionMode.Success);
        }
Ejemplo n.º 14
0
 /// <summary>
 /// determines whether given run type corresponds to scripting or not
 /// </summary>
 /// <param name="runType"></param>
 /// <returns></returns>
 private bool IsScripting(RunType runType)
 {
     return(runType == RunType.ScriptToClipboard ||
            runType == RunType.ScriptToFile ||
            runType == RunType.ScriptToWindow ||
            runType == RunType.ScriptToJob);
 }
Ejemplo n.º 15
0
        internal async Task <Tuple <bool, string> > ConfigureCredential(
            string ownerUri,
            CredentialInfo credential,
            ConfigAction configAction,
            RunType runType)
        {
            return(await Task <Tuple <bool, string> > .Run(() =>
            {
                try
                {
                    ConnectionInfo connInfo;
                    ConnectionServiceInstance.TryFindConnection(ownerUri, out connInfo);
                    CDataContainer dataContainer = CDataContainer.CreateDataContainer(connInfo, databaseExists: true);

                    using (CredentialActions actions = new CredentialActions(dataContainer, credential, configAction))
                    {
                        var executionHandler = new ExecutonHandler(actions);
                        executionHandler.RunNow(runType, this);
                    }

                    return new Tuple <bool, string>(true, string.Empty);
                }
                catch (Exception ex)
                {
                    return new Tuple <bool, string>(false, ex.ToString());
                }
            }));
        }
Ejemplo n.º 16
0
 public RunModel(string title, string content, RunType type, Object obj)
 {
     Title   = title;
     Content = content;
     Type    = type;
     Data    = obj;
 }
Ejemplo n.º 17
0
    public void DetermineRunType(float v, float h)
    {
        bool vflag = false;
        bool hflag = false;

        if (v > 0.05f || v < -0.05f)
        {
            vflag = true;
        }
        else
        {
            vflag = false;
        }

        if (h > 0.05f || h < -0.05f)
        {
            hflag = true;
        }
        else
        {
            hflag = false;
        }
        if ((vflag && !hflag) || (!vflag && hflag))
        {
            runtype = RunType.STRAIGHT;
        }
        if (vflag && hflag)
        {
            runtype = RunType.TURN;
        }
    }
Ejemplo n.º 18
0
 /// <summary>
 /// called by IExecutionAwareSqlControlCollection.PreProcessExecution to enable derived
 /// classes to take over execution of the dialog and do entire execution in this method
 /// rather than having the framework to execute dialog views one by one.
 ///
 /// NOTE: it might be called from non-UI thread
 /// </summary>
 /// <param name="runType"></param>
 /// <param name="executionResult"></param>
 /// <returns>
 /// true if regular execution should take place, false if everything,
 /// has been done by this function
 /// </returns>
 protected virtual bool DoPreProcessExecution(RunType runType, out ExecutionMode executionResult)
 {
     //ask the framework to do normal execution by calling OnRunNOw methods
     //of the views one by one
     executionResult = ExecutionMode.Success;
     return(true);
 }
Ejemplo n.º 19
0
        internal static async Task DeleteNotebook(
            AgentService agentServiceInstance,
            string ownerUri,
            AgentNotebookInfo notebook,
            RunType runType)
        {
            ConnectionInfo connInfo;

            agentServiceInstance.ConnectionServiceInstance.TryFindConnection(ownerUri, out connInfo);

            // deleting job from sql agent
            var deleteJobResult = await agentServiceInstance.ConfigureAgentJob(
                ownerUri,
                notebook.Name,
                notebook,
                ConfigAction.Drop,
                runType);

            if (!deleteJobResult.Item1)
            {
                throw new Exception(deleteJobResult.Item2);
            }
            // deleting notebook metadata from target database
            await DeleteNotebookMetadata(
                connInfo,
                notebook.JobId,
                notebook.TargetDatabase);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// called before dialog's host executes actions on all panels in the dialog one by one.
        /// If something fails inside this function and the execution should be aborted,
        /// it can either raise an exception [in which case the framework will show message box with exception text]
        /// or set executionResult out parameter to be ExecutionMode.Failure
        /// NOTE: it might be called from worker thread
        /// </summary>
        /// <param name="executionInfo">information about execution action</param>
        /// <param name="executionResult">result of the execution</param>
        /// <returns>
        /// true if regular execution should take place, false if everything
        /// has been done by this function
        /// NOTE: in case of returning false during scripting operation
        /// PreProcessExecutionInfo.Script property of executionInfo parameter
        /// MUST be set by this function [if execution result is success]
        /// </returns>
        public bool PreProcessExecution(PreProcessExecutionInfo executionInfo, out ExecutionMode executionResult)
        {
            //we start from failure
            executionResult = ExecutionMode.Failure;

            //OK, we do server switching for scripting for SQL/Analysis Server execution here
            RunType runType = executionInfo.RunType;

            if (IsScripting(runType))
            {
                if (!PreProcessScripting(executionInfo, out executionResult))
                {
                    return(false);
                }
            }

            if (DataContainer != null)
            {
                //we take over execution here. We substitute the server here for AMO and SQL
                //dialogs
                if (DataContainer.ContainerServerType == CDataContainer.ServerType.SQL)
                {
                    ExecuteForSql(executionInfo, out executionResult);
                    return(false);//execution of the entire control was done here
                }
            }


            // call virtual function to do regular execution
            return(DoPreProcessExecution(executionInfo.RunType, out executionResult));
        }
Ejemplo n.º 21
0
 public RunInfo(RunType type, TId jobId, TId requestId, StagePath path)
 {
     Type      = type;
     JobId     = jobId;
     RequestId = requestId;
     Path      = new StagePath(path);
 }
Ejemplo n.º 22
0
        public ThreadedViterbi(List<Block> UnfilteredBlocks, RunType runType, List<UserState> userStates, string file_path, string fileSha1)
        {
            _unfilteredBlocks = UnfilteredBlocks;
            _userStates = userStates;
            _filePath = file_path;
            _machines = new List<StateMachine>();
            _states = new List<State>();
            _viterbiResults = new ViterbiResult();
            _viterbiResults.Fields = new List<ViterbiField>();
            _fileSha1 = fileSha1;
            _viterbiResults.MemoryId = this._fileSha1;
            _runType = runType;

            //TODO: (RJW) I am not convinced this bit of code loads the machines as Shaksham intended. 
            // This call is to load _machines, _states, _startState and _userStates variables, so that we do not execute same code for every block to load values
            // into these variables, since they are the same for all blocks.
            if (_runType == RunType.GeneralParse)
            {
                Viterbi viterbi = new Viterbi(RunType.GeneralParse, true, ref _machines, ref _states, ref _startState, ref _userStates);
            }
            else if (_runType == RunType.Meta)
            {
                Viterbi viterbi = new Viterbi(RunType.Meta, false, ref _machines, ref _states, ref _startState, ref _userStates);
                _unfilteredBlocks = Split_On_Binary_Large_Fields(_unfilteredBlocks[0].Bytes);
            }
            else
            {
                Viterbi viterbi = new Viterbi(_runType, false, ref _machines, ref _states, ref _startState, ref _userStates);
            }

        }
Ejemplo n.º 23
0
        private void handleToolStripMenuClick(RunType runType)
        {
            this.reset();

            tbElapsedTime.Text = " Running...";
            tbCostOfTour.Text  = " Running...";
            Refresh();

            Solver solver;

            if (runType == RunType.BRANCH_AND_BOUND)
            {
                BranchAndBoundSolver babs = new BranchAndBoundSolver(CityData);
                CityData = babs.solve();
            }
            else if (runType == RunType.GREEDY)
            {
                CityData = GreedySolver.solve(CityData);
            }
            else if (runType == RunType.FANCY)
            {
                solver   = new FancySolver();
                CityData = solver.solve(CityData);
            }
            else  // runType == RunType.DEFAULT
            {
                solver   = new DefaultSolver();
                CityData = solver.solve(CityData);
            }

            tbCostOfTour.Text   = CityData.bssf.costOfRoute.ToString();
            tbElapsedTime.Text  = CityData.timeElasped.ToString();
            tbNumSolutions.Text = CityData.solutions.ToString();
            Invalidate();                          // force a refresh.
        }
Ejemplo n.º 24
0
 public void GameStartedListener(RunType type)
 {
     if (currentSave != null)
     {
         DeckChangedNotification(currentSave.GetDeckState(), currentSave.GetVisibleDeckCount());
     }
 }
Ejemplo n.º 25
0
        internal async Task <Tuple <bool, string> > ConfigureAgentOperator(
            string ownerUri,
            AgentOperatorInfo operatorInfo,
            ConfigAction configAction,
            RunType runType)
        {
            return(await Task <Tuple <bool, string> > .Run(() =>
            {
                try
                {
                    ConnectionInfo connInfo;
                    ConnectionServiceInstance.TryFindConnection(ownerUri, out connInfo);
                    CDataContainer dataContainer = CDataContainer.CreateDataContainer(connInfo, databaseExists: true);
                    STParameters param = new STParameters(dataContainer.Document);
                    param.SetParam("operator", operatorInfo.Name);

                    using (AgentOperatorActions actions = new AgentOperatorActions(dataContainer, operatorInfo, configAction))
                    {
                        ExecuteAction(actions, runType);
                    }

                    return new Tuple <bool, string>(true, string.Empty);
                }
                catch (Exception ex)
                {
                    return new Tuple <bool, string>(false, ex.ToString());
                }
            }));
        }
Ejemplo n.º 26
0
        public void Update(RunType runType)
        {
            var entity = _dbContext
                         .Query <RunTypeEntity>()
                         .Include(o => o.RunTypeAnalysisGroups)
                         .Include(o => o.RunLandmarkScheduleSettings)
                         .FirstOrDefault(o => o.Id == runType.Id);

            if (entity != null)
            {
                if (entity.RunTypeAnalysisGroups != null && entity.RunTypeAnalysisGroups.Any())
                {
                    _dbContext.RemoveRange(entity.RunTypeAnalysisGroups.ToArray());
                    entity.RunTypeAnalysisGroups.Clear();
                }

                if (entity.RunLandmarkScheduleSettings != null)
                {
                    entity.RunLandmarkScheduleSettings.DaysOfWeek = null;
                }

                _mapper.Map(runType, entity);
                _dbContext.Update(entity, post => post.MapTo(runType), _mapper);
            }
        }
Ejemplo n.º 27
0
        internal async Task <Tuple <bool, string> > ConfigureAgentJob(
            string ownerUri,
            AgentJobInfo jobInfo,
            ConfigAction configAction,
            RunType runType)
        {
            return(await Task <Tuple <bool, string> > .Run(() =>
            {
                try
                {
                    JobData jobData;
                    CDataContainer dataContainer;
                    CreateJobData(ownerUri, jobInfo.Name, out dataContainer, out jobData, jobInfo);

                    using (JobActions jobActions = new JobActions(dataContainer, jobData, configAction))
                    {
                        var executionHandler = new ExecutonHandler(jobActions);
                        executionHandler.RunNow(runType, this);
                    }

                    return new Tuple <bool, string>(true, string.Empty);
                }
                catch (Exception ex)
                {
                    return new Tuple <bool, string>(false, ex.ToString());
                }
            }));
        }
Ejemplo n.º 28
0
    //Called from initialize
    public static int Insert(RunType t, string tableName, bool dbconOpened, SqliteCommand mycmd)
    {
        //string [] myStr = myRun.Split(new char[] {':'});
        if (!dbconOpened)
        {
            Sqlite.Open();
        }
        mycmd.CommandText = "INSERT INTO " + tableName +
                            " (uniqueID, name, distance, description)" +
                            " VALUES (NULL, \"" +

                            /*
                             * myStr[0] + "\", " + myStr[1] + ", \"" +	//name, distance
                             * myStr[2] + "\")" ;	//description
                             */
                            t.Name + "\", " + Util.ConvertToPoint(t.Distance) + ", \"" + t.Description + "\")";
        LogB.SQL(mycmd.CommandText.ToString());
        mycmd.ExecuteNonQuery();

        //int myLast = dbcon.LastInsertRowId;
        //http://stackoverflow.com/questions/4341178/getting-the-last-insert-id-with-sqlite-net-in-c
        string myString = @"select last_insert_rowid()";

        mycmd.CommandText = myString;
        int myLast = Convert.ToInt32(mycmd.ExecuteScalar());         // Need to type-cast since `ExecuteScalar` returns an object.

        if (!dbconOpened)
        {
            Sqlite.Close();
        }
        return(myLast);
    }
Ejemplo n.º 29
0
        internal async Task <Tuple <bool, string> > ConfigureAgentAlert(
            string ownerUri,
            AgentAlertInfo alert,
            ConfigAction configAction,
            RunType runType)
        {
            return(await Task <Tuple <bool, string> > .Run(() =>
            {
                try
                {
                    ConnectionInfo connInfo;
                    ConnectionServiceInstance.TryFindConnection(ownerUri, out connInfo);
                    CDataContainer dataContainer = CDataContainer.CreateDataContainer(connInfo, databaseExists: true);
                    STParameters param = new STParameters(dataContainer.Document);
                    param.SetParam("alert", alert.JobName);

                    if (alert != null && !string.IsNullOrWhiteSpace(alert.JobName))
                    {
                        using (AgentAlertActions agentAlert = new AgentAlertActions(dataContainer, alert, configAction))
                        {
                            var executionHandler = new ExecutonHandler(agentAlert);
                            executionHandler.RunNow(runType, this);
                        }
                    }

                    return new Tuple <bool, string>(true, string.Empty);
                }
                catch (Exception ex)
                {
                    return new Tuple <bool, string>(false, ex.ToString());
                }
            }));
        }
Ejemplo n.º 30
0
    //Called from initialize
    public static new int Insert(RunType t, string tableName, bool dbconOpened, SqliteCommand mycmd)
    {
        //done here for not having twho Sqlite.Opened
        //double distance = t.Distance;

        if (!dbconOpened)
        {
            Sqlite.Open();
        }
        mycmd.CommandText = "INSERT INTO " + tableName +
                            " (uniqueID, name, distance, tracksLimited, fixedValue, unlimited, description, distancesString)" +
                            " VALUES (NULL, \"" +
                            t.Name + "\", " + Util.ConvertToPoint(t.Distance) + ", " + Util.BoolToInt(t.TracksLimited) + ", " + t.FixedValue + ", " +
                            Util.BoolToInt(t.Unlimited) + ", \"" + t.Description + "\", \"" + t.DistancesString + "\")";
        LogB.SQL(mycmd.CommandText.ToString());
        mycmd.ExecuteNonQuery();

        //int myLast = dbcon.LastInsertRowId;
        //http://stackoverflow.com/questions/4341178/getting-the-last-insert-id-with-sqlite-net-in-c
        string myString = @"select last_insert_rowid()";

        mycmd.CommandText = myString;
        int myLast = Convert.ToInt32(mycmd.ExecuteScalar());         // Need to type-cast since `ExecuteScalar` returns an object.

        if (!dbconOpened)
        {
            Sqlite.Close();
        }
        return(myLast);
    }
Ejemplo n.º 31
0
        internal async Task <Tuple <bool, string> > ConfigureAgentSchedule(
            string ownerUri,
            AgentScheduleInfo schedule,
            ConfigAction configAction,
            RunType runType)
        {
            return(await Task <bool> .Run(() =>
            {
                try
                {
                    JobData jobData;
                    CDataContainer dataContainer;
                    CreateJobData(ownerUri, schedule.JobName, out dataContainer, out jobData);

                    const string UrnFormatStr = "Server[@Name='{0}']/JobServer[@Name='{0}']/Job[@Name='{1}']/Schedule[@Name='{2}']";
                    string serverName = dataContainer.Server.Name.ToUpper();
                    string scheduleUrn = string.Format(UrnFormatStr, serverName, jobData.Job.Name, schedule.Name);

                    STParameters param = new STParameters(dataContainer.Document);
                    param.SetParam("urn", scheduleUrn);

                    using (JobSchedulesActions actions = new JobSchedulesActions(dataContainer, jobData, schedule, configAction))
                    {
                        var executionHandler = new ExecutonHandler(actions);
                        executionHandler.RunNow(runType, this);
                    }

                    return new Tuple <bool, string>(true, string.Empty);
                }
                catch (Exception ex)
                {
                    return new Tuple <bool, string>(false, ex.ToString());
                }
            }));
        }
Ejemplo n.º 32
0
        internal async Task <Tuple <bool, string> > ConfigureAgentProxy(
            string ownerUri,
            string accountName,
            AgentProxyInfo proxy,
            ConfigAction configAction,
            RunType runType)
        {
            return(await Task <bool> .Run(() =>
            {
                try
                {
                    ConnectionInfo connInfo;
                    ConnectionServiceInstance.TryFindConnection(ownerUri, out connInfo);
                    CDataContainer dataContainer = CDataContainer.CreateDataContainer(connInfo, databaseExists: true);
                    STParameters param = new STParameters(dataContainer.Document);
                    param.SetParam("proxyaccount", accountName);

                    using (AgentProxyAccountActions agentProxy = new AgentProxyAccountActions(dataContainer, proxy, configAction))
                    {
                        var executionHandler = new ExecutonHandler(agentProxy);
                        executionHandler.RunNow(runType, this);
                    }

                    return new Tuple <bool, string>(true, string.Empty);
                }
                catch (Exception ex)
                {
                    return new Tuple <bool, string>(false, ex.ToString());
                }
            }));
        }
Ejemplo n.º 33
0
        /// <summary>
        /// Calls static methods of StateMachine to prepare the state machines with their emission/transition probabilities for inference, according to the Runtype.
        /// </summary>
        /// <param name="type">The Run type, whether field level, record level, only for phone numbers etc.</param>
        /// <param name="isAnchor"></param>
        /// <param name="userStates">Any user defined state machines.</param>
        public Viterbi(RunType type, bool isAnchor, List<UserState> userStates=null)
        {
            #if !PRINT_FIELD
            Console.WriteLine("Not Printing fields!");
            #endif

            _runType = type;
            _isAnchor = isAnchor;

            _machines = new List<StateMachine>();
            _states = new List<State>();
            _startState = new State();
            _textList = new List<string>();
            _fieldList = new List<ViterbiField>();
            _userStates = userStates ?? new List<UserState>();

            switch (_runType)
            {
                case RunType.BinaryOnly:
                    StateMachine.TestBinaryOnly(ref _machines, ref _states, ref _startState);
                    break;
                case RunType.GeneralParse:
                    StateMachine.GeneralParse(ref _machines, ref _states, ref _startState, _userStates);
                    break;

                case RunType.PhoneNumberOnly:
                    StateMachine.TestPhoneOnly(ref _machines, ref _states, ref _startState);
                    break;

                case RunType.PhoneNumberAndText:
                    //StateMachine.TestPhoneNumberAndText(ref _machines, ref _states, ref _startState);
                    StateMachine.TestPhoneNumberAndTextMachine(ref _machines, ref _states, ref _startState);
                    break;

                case RunType.TextOnly:
                    StateMachine.TestTextOnly(ref _machines, ref _states, ref _startState);
                    break;

                case RunType.PhoneNumberTextAndTimeStamp:
                    StateMachine.TestPhoneNumberTextAndTimeStamp(ref _machines, ref _states, ref _startState);
                    break;

                case RunType.Meta:
                    StateMachine.TestMeta(ref _machines, ref _states, ref _startState);
                    break;

                case RunType.AnchorPoints:
                    StateMachine.TestAnchorFieldsOnly(ref _machines, ref _states, ref _startState, _userStates);
                    break;

                case RunType.Moto:
                    StateMachine.TestMoto(ref _machines, ref _states, ref _startState);
                    break;
                default:
                    throw new ArgumentOutOfRangeException("type");
            }

            Console.WriteLine("Viterbi set to {0}", Convert.ToString(type));
        }
Ejemplo n.º 34
0
 public RunMessage(RunType runtype, string runmsg, IThrowMessage sender)
 {
     runType = runtype;
     runMsg = runmsg;
     runTime = DateTime.Now;
     senderList = new List<IThrowMessage>();
     senderList.Add(sender);
 }
Ejemplo n.º 35
0
        public AOURouter()
        {
            logMessages = new List<AOULogMessage>();
            powerValues = new List<Power>();

            runMode = RunType.None;
            startTime = DateTime.Now;
            aouLogFile = new AOULogFile(startTime);
        }
Ejemplo n.º 36
0
        public int ReadFrom(byte[] buffer, int offset)
        {
            Type = (RunType)Utilities.ToUInt32BigEndian(buffer, offset + 0);
            SectorStart = Utilities.ToInt64BigEndian(buffer, offset + 8);
            SectorCount = Utilities.ToInt64BigEndian(buffer, offset + 16);
            CompOffset = Utilities.ToInt64BigEndian(buffer, offset + 24);
            CompLength = Utilities.ToInt64BigEndian(buffer, offset + 32);

            return 40;
        }
Ejemplo n.º 37
0
 public WorkspaceInfo(string id, string name, string description, RunType runType)
 {
     ID = id;
     Name = name;
     Description = description;
     Zoom = 1.0;
     X = 0;
     Y = 0;
     RunType = runType;
     RunPeriod = RunSettings.DefaultRunPeriod;
     HasRunWithoutCrash = true;
 }
Ejemplo n.º 38
0
        /// <summary>
        /// Constructor, initializing members of AnchorViterbi.
        /// </summary>
        /// <param name="runType">Determines the kind of run, whether GeneralParse (for regular field level inference), Meta (for record level inference), etc.</param>
        /// <param name="filePath">Path to phone's memory file.</param>
        /// <param name="userStates">User-defined state machines.</param>
        public AnchorViterbi(RunType runType, string filePath, List<UserState> userStates)
        {
            _filePath = filePath;

            var info = new FileInfo(filePath);

            _fileLength = info.Length;

            _runType = runType;

            _userStates = (userStates == null) ? new List<UserState>() : userStates;
        }
Ejemplo n.º 39
0
 public void Run(int limit, RunType runType)
 {
     switch (runType) {
     case RunType.IterationsLimit:
         Run(int.MaxValue, limit);
         break;
     case RunType.TimeLimit:
         Run(limit, int.MaxValue);
         break;
     default:
         break;
     }
 }
Ejemplo n.º 40
0
        /// <summary>
        /// Constructor, initializing members of AnchorViterbi.
        /// </summary>
        /// <param name="runType">Determines the kind of run, whether GeneralParse (for regular field level inference), Meta (for record level inference), etc.</param>
        /// <param name="filePath">Path to phone's memory file.</param>
        public AnchorViterbi(RunType runType, string filePath)
        {
            _filePath = filePath;

            var info = new FileInfo(filePath);

            _fileLength = info.Length;

            _runType = runType;

            // No user-defined state machines.
            _userStates = new List<UserState>();
        }
        public ExperimentModel(RunType runType, int numberOfLabellingRound, int labelStartingPoint)
        {
            //set current TaskSelectionMethod to default of the TaskSelectionMethod enum
            this.taskSelectionMethod = default(TaskSelectionMethod);
            this.runType = runType;
            this.labelStartingPoint = labelStartingPoint;
            this.numberOfLabellingRound = numberOfLabellingRound;
            accuracyOfTheExperimentModel = new List<double>();

            isSimulationComplete = false;

            //initial the BindingList
            resultsBindingList = new BindingList<ActiveLearningResult>();
        }
Ejemplo n.º 42
0
    private RunType previousRunType; //used on More to turnback if cancel or delete event is pressed

    #endregion Fields

    #region Methods

    //creates and if is not predefined, checks database to gather all the data
    //simple == true  for normal runs, and false for intervallic
    private RunType createRunType(string name, bool simple)
    {
        RunType t = new RunType(name);

        if(! t.IsPredefined) {
            if(simple) {
                t = SqliteRunType.SelectAndReturnRunType(name, false);
                t.ImageFileName = SqliteEvent.GraphLinkSelectFileName(Constants.RunTable, name);
            } else {
                t = SqliteRunIntervalType.SelectAndReturnRunIntervalType(name, false);
                t.ImageFileName = SqliteEvent.GraphLinkSelectFileName(Constants.RunIntervalTable, name);
            }
        }
        return t;
    }
Ejemplo n.º 43
0
        protected object BaseExecuteCommand(RunType runSelector)
        {
            if (!Client.IsAvailable())
                return null;

            try
            {
                Client?.GetConnectionHandler()?.SetExecuting();

                return CommandTypeSelector(runSelector);
            }
            catch
            {
                Client?.GetConnectionHandler()?.SetOpened();

                return null;
            }
            finally
            {
                Client.GetConnectionHandler().SetOpened();
            }
        }
Ejemplo n.º 44
0
        /// <summary>
        /// Runs a model with the full gold set.
        /// </summary>
        /// <param name="dataSet">The dataset name.</param>
        /// <param name="data">The data.</param>
        /// <param name="runType">The model run type.</param>
        /// <param name="model">The model instance.</param>
        /// <param name="numCommunities">The number of communities (only for CBCC).</param>
        /// <returns>The inference results</returns>
        public static Results RunGold(string dataSet, IList<Datum> data, RunType runType, BCC model, int numCommunities = 2)
        {

            string modelName = Program.GetModelName(dataSet, runType);
            Results results = new Results();

            switch (runType)
            {
                case RunType.VoteDistribution:
                    results.RunMajorityVote(data, data, true, true);
                    break;
                case RunType.MajorityVote:
                    results.RunMajorityVote(data, data, true, false);
                    break;
                case RunType.DawidSkene:
                    results.RunDawidSkene(data, data, true);
                    break;
                default:
                    results.RunBCC(modelName, data, data, model, RunMode.ClearResults, true, numCommunities, false, false);
                    break;
            }
            
            return results;
        }
Ejemplo n.º 45
0
        private object CommandTypeSelector(RunType runSelector)
        {
            try
            {
                switch (runSelector)
                {
                    case RunType.Insert:
                        Command?.ExecuteScalar();

                        return Command?.LastInsertedId;
                    case RunType.Normal:
                    case RunType.Fast:
                        return Command?.ExecuteNonQuery();
                    default:
                        return null;
                }
            }
            catch
            {
                Client?.GetConnectionHandler()?.SetOpened();

                return null;
            }
        }
        // Marks a text run as clean or dirty.
        private void MarkRange(ITextPointer start, ITextPointer end, RunType runType)
        {
            if (start.CompareTo(end) == 0)
            {
                return;
            }

            int startIndex;
            int endIndex;

            Invariant.Assert(runType == RunType.Clean || runType == RunType.Dirty);

            startIndex = FindIndex(start.CreateStaticPointer(), LogicalDirection.Forward);
            endIndex = FindIndex(end.CreateStaticPointer(), LogicalDirection.Backward);

            // We don't expect start/end to ever point off the edge of the document.
            Invariant.Assert(startIndex >= 0);
            Invariant.Assert(endIndex >= 0);

            // Remove wholly covered runs.
            if (startIndex + 1 < endIndex)
            {
                // Tell the HighlightLayer about any error runs that are going away.
                for (int i = startIndex + 1; i < endIndex; i++)
                {
                    NotifyHighlightLayerBeforeRunChange(i);
                }

                _runList.RemoveRange(startIndex + 1, endIndex - startIndex - 1);
                endIndex = startIndex + 1;
            }

            // Merge the bordering edge runs.

            if (startIndex == endIndex)
            {
                // We're contained in a single run.
                AddRun(startIndex, start, end, runType);
            }
            else
            {
                // We cover two runs.
                Invariant.Assert(startIndex == endIndex - 1);

                // Handle the first run.
                AddRun(startIndex, start, end, runType);

                // Recalc endIndex, since it may have changed in the merge.
                endIndex = FindIndex(end.CreateStaticPointer(), LogicalDirection.Backward);
                Invariant.Assert(endIndex >= 0);
                // Handle the second run.
                AddRun(endIndex, start, end, runType);
            }
        }
Ejemplo n.º 47
0
 public AOURouter(AOUSettings.RemoteSetting remoteSetting) : this()
 {
     runMode = RunType.Serial;
     aouData = new AOURemoteData(remoteSetting);
     aouData.Connect();
 }
Ejemplo n.º 48
0
 public AOURouter(AOUSettings.SerialSetting serialSetting, AOUSettings.DebugMode dbgMode) : this()
 {
     runMode = RunType.Serial;
     aouData = new AOUSerialData(serialSetting, dbgMode);
     aouData.Connect();
 }
Ejemplo n.º 49
0
 public string UploadRunType(RunType type, int evalSID)
 {
     object[] results = this.Invoke("UploadRunType", new object[] {
                 type,
                 evalSID});
     return ((string)(results[0]));
 }
Ejemplo n.º 50
0
 public void UploadRunTypeAsync(RunType type, int evalSID)
 {
     this.UploadRunTypeAsync(type, evalSID, null);
 }
        } //End AddModel


        /// <summary>
        /// Initial the experimentItem according to the previous setting
        /// </summary>
        /// <param name="currentRunType"></param>
        /// <param name="currentTaskSelectionMethod"></param>
        /// <param name="currentWorkerSelectionMethod"></param>
        /// <param name="labelStartingPoints"></param>
        /// <param name="totalNumberOfLabels"></param>
        /// <returns></returns>
        private ExperimentModel getExperimentItem(RunType currentRunType, TaskSelectionMethod currentTaskSelectionMethod, WorkerSelectionMethod currentWorkerSelectionMethod, int[] labelStartingPoints)
        {
            //if the RunType is MajorityVote, no TaskSelectionMethods would be selected
            if (currentRunType == RunType.MajorityVote)
            {
                return new ExperimentModel(currentTaskSelectionMethod, WorkerSelectionMethod.RandomWorker, currentRunType, 1, labelStartingPoints[0]);
            }

            //if it is an entropy task, add the different labelling rounds
            if (currentTaskSelectionMethod == TaskSelectionMethod.EntropyTask)
            {
                int currentLabellingRound = trackBarNumberOfLabellingRounds.Value;
                return new ExperimentModel(currentTaskSelectionMethod, currentWorkerSelectionMethod, currentRunType, currentLabellingRound, labelStartingPoints[currentLabellingRound - 1]);
            }
            else//other taskSelectionMethods, or empty in the batch running 
            {
                return new ExperimentModel(currentTaskSelectionMethod, currentWorkerSelectionMethod, currentRunType, 1, labelStartingPoints[0]);
            }//end if  

        }
Ejemplo n.º 52
0
 public void UploadRunTypeAsync(RunType type, int evalSID, object userState)
 {
     if ((this.UploadRunTypeOperationCompleted == null)) {
         this.UploadRunTypeOperationCompleted = new System.Threading.SendOrPostCallback(this.OnUploadRunTypeCompleted);
     }
     this.InvokeAsync("UploadRunType", new object[] {
                 type,
                 evalSID}, this.UploadRunTypeOperationCompleted, userState);
 }
Ejemplo n.º 53
0
 public System.IAsyncResult BeginUploadRunType(RunType type, int evalSID, System.AsyncCallback callback, object asyncState)
 {
     return this.BeginInvoke("UploadRunType", new object[] {
                 type,
                 evalSID}, callback, asyncState);
 }
Ejemplo n.º 54
0
 /// <summary>
 /// This function creates RunSettings with specified run type and run period.
 /// </summary>
 /// <param name="runType">RunType</param>
 /// <param name="period">milliseconds</param>
 public RunSettings(RunType runType, int period)
 {
     RunPeriod = period;
     RunType = runType;
     RunEnabled = true;
 }
 internal Run(ITextPointer position, RunType runType)
 {
     _position = position.GetFrozenPointer(LogicalDirection.Backward);
     _runType = runType;
 }
        // Returns true if the specified character is part of a run of the specified type.
        internal bool IsRunType(StaticTextPointer textPosition, LogicalDirection direction, RunType runType)
        {
            int index = FindIndex(textPosition, direction);

            if (index < 0)
            {
                return false;
            }

            return GetRun(index).RunType == runType;
        }
Ejemplo n.º 57
0
 public AOURouter(AOUSettings.RandomSetting randomSetting) : this()
 {
     runMode = RunType.Random;
     aouData = new AOURandomData(randomSetting);
     aouData.Connect();
 }
        // Returns the type and end of the Run intersecting position.
        internal bool GetRun(StaticTextPointer position, LogicalDirection direction, out RunType runType, out StaticTextPointer end)
        {
            int index = FindIndex(position, direction);

            runType = RunType.Clean;
            end = StaticTextPointer.Null;

            if (index < 0)
            {
                return false;
            }

            Run run = GetRun(index);

            runType = run.RunType;
            end = (direction == LogicalDirection.Forward) ? GetRunEndPosition(index) : run.Position.CreateStaticPointer();

            return true;
        }
Ejemplo n.º 59
0
 public AOURouter(AOUSettings.FileSetting fileSetting) : this()
 {
     runMode = RunType.File;
     aouData = new AOUFileData(fileSetting);
     aouData.Connect();
 }
        // Adds a new run into an old one, merging the two.
        private void AddRun(int index, ITextPointer start, ITextPointer end, RunType runType)
        {
            Run run;
            Run newRun;
            RunType oppositeRunType;

            // We don't expect runType.Error, just clean or dirty.
            Invariant.Assert(runType == RunType.Clean || runType == RunType.Dirty);
            // We don't expect empty runs here.
            Invariant.Assert(start.CompareTo(end) < 0);

            oppositeRunType = (runType == RunType.Clean) ? RunType.Dirty : RunType.Clean;
            run = GetRun(index);

            if (run.RunType == runType)
            {
                // Existing run value matches new one.
                TryToMergeRunWithNeighbors(index);
            }
            else if (run.RunType == oppositeRunType)
            {
                // We're merging a new clean run with an old dirty one, or vice versa.

                // Split the run, insert a new run in the middle.
                if (run.Position.CompareTo(start) >= 0)
                {
                    if (GetRunEndPosition(index).CompareTo(end) <= 0)
                    {
                        // We entirely cover this run, just flip the RunType.
                        run.RunType = runType;

                        TryToMergeRunWithNeighbors(index);
                    }
                    else
                    {
                        // We cover the left half.
                        if (index > 0 && GetRun(index - 1).RunType == runType)
                        {
                            // Previous run matches the new value, merge with it.
                            run.Position = end;
                        }
                        else
                        {
                            run.RunType = runType;
                            newRun = new Run(end, oppositeRunType);
                            _runList.Insert(index + 1, newRun);
                        }
                    }
                }
                else if (GetRunEndPosition(index).CompareTo(end) <= 0)
                {
                    // We cover the right half.
                    if (index < _runList.Count - 1 && GetRun(index + 1).RunType == runType)
                    {
                        // Following run matches the new value, merge with it.
                        GetRun(index + 1).Position = start;
                    }
                    else
                    {
                        // Insert new run.
                        newRun = new Run(start, runType);
                        _runList.Insert(index + 1, newRun);
                    }
                }
                else
                {
                    // We're in the middle of the run.
                    // Split the run, adding a new run and a new second
                    // half of the original run.
                    newRun = new Run(start, runType);
                    _runList.Insert(index + 1, newRun);
                    newRun = new Run(end, oppositeRunType);
                    _runList.Insert(index + 2, newRun);
                }
            }
            else
            {
                ITextPointer errorStart;
                ITextPointer errorEnd;

                // We hit an error run, the whole thing becomes dirty/clean.
                run.RunType = runType;

                errorStart = run.Position;
                errorEnd = GetRunEndPositionDynamic(index);

                // This call might remove run...
                TryToMergeRunWithNeighbors(index);

                // Tell the HighlightLayer about this change.
                _highlightLayer.FireChangedEvent(errorStart, errorEnd);
            }
        }