コード例 #1
0
        public void Algorithm_Sample()
        {
            Model model = CreateModel();

            model.Algorithm.AddCommand(new AlgorithmCommand("engine: set1", "p1=0"));
            var measurement = new Measurement();

            var client = new Client {
                Model = model, Measurement = measurement
            };

            client.Init();

            //
            // user inserts "user-define command" to engine's algorithm;
            //
            // plugin definition (unique and parameters)
            const string commandUnique     = "pluginB_dependency";
            const string commandName       = "Command B";
            const string commandParameters = "parameter1=P1; parameter2=P2; material1=M1; material2=M2; threshold=0.4";

            var command_Plugin_B_v2 = new UserDefinedCommand(client, commandUnique, commandName, commandParameters);

            model.Algorithm.AddCommand(command_Plugin_B_v2);

            var algorithmExecutor = new AlgorithmExecuter(model);

            algorithmExecutor.Run();

            var modelDataEntity = client.DataFramework.GetDataEntity <IModelDataEntity>();

            Assert.AreEqual(0.1, modelDataEntity.GetParameterNominal("P1"));
            Assert.AreEqual(0.4, modelDataEntity.GetParameterNominal("P2"));
        }
コード例 #2
0
        public void Training_CreateModel_SaveToFile()
        {
            var   modelFile = new DataFile(Path.Combine(Path.GetTempPath(), "model.dat"));
            Model model     = CreateModel("trainingModel");

            var client = new Client {
                Model = model, Measurement = new Measurement()
            };

            client.Init();

            var addMessageToHistory = new UserDefinedCommand(client, "message_to_history", "Add message to model history", "message=training");
            var saveModelToFile     = new UserDefinedCommand(client, "save_model_to_file", "Save model to file", String.Format("file={0}", modelFile.File));

            model.Algorithm.AddCommand(addMessageToHistory);
            model.Algorithm.AddCommand(saveModelToFile);
            var algorithmExecutor = new AlgorithmExecuter(model);

            algorithmExecutor.Run();

            Assert.AreEqual("training", model.History);
        }