public ModelUnderTestAdvancedCCSettingsForm(CCTestWorkspace testWorkspace)
        {
            this.testWorkspace = testWorkspace;

            InitializeComponent();

            parentAdvancedCCSettingsForm = new ParentAdvancedCCSettingsForm();
            parentAdvancedCCSettingsForm.LoadAdvancedCCSettings(testWorkspace.advancedCCSettings);
            this.Controls.Add(parentAdvancedCCSettingsForm);
            ////////////////////////////////////
            this.btnNext.Click     += new System.EventHandler(this.btnNext_Click);
            this.btnPrevious.Click += new System.EventHandler(this.btnPrevious_Click);
            this.btnCancel.Click   += new System.EventHandler(this.btnCancel_Click);
        }
        public override void RunAsync()
        {
            MatlabAsyncProgram.KillMatlab();
            CCTestWorkspace ccTestWorkspace = (CCTestWorkspace)testWorkspace;

            if (Directory.Exists(tempPath))
            {
                Directory.Delete(tempPath, true);
            }
            Directory.CreateDirectory(tempPath);
            File.Delete(outputLogPath);

            MatlabCommand modelSettingsCommand = MatlabCommandBuilder.GetModelSettingsMatlabCommand(ccTestWorkspace.modelSettings);

            modelSettingsCommand.SaveToMatlabScript(tempPath + "\\" + MatlabCommandBuilder.ModelSettingsScriptFileName + ".m");

            CompositeMatlabCommand mainScriptCommand = new CompositeMatlabCommand();

            mainScriptCommand.LoadFromMatlabScript(templatePath + "\\RandomExploration\\RandomExplorationRun-Common.m");
            CompositeMatlabCommand GenerateNewValueCommand = new CompositeMatlabCommand();

            if (ccTestWorkspace.advancedCCSettings.randomExplorationAlgorithm == RandomExplorationAlgorithmsEnum.RandomSearch)
            {
                GenerateNewValueCommand.LoadFromMatlabScript(templatePath + "\\RandomExploration\\RandomExplorationRun-RandomSearchGenerateValues.m");
            }
            else if (ccTestWorkspace.advancedCCSettings.randomExplorationAlgorithm == RandomExplorationAlgorithmsEnum.AdaptiveRandomSearch)
            {
                GenerateNewValueCommand.LoadFromMatlabScript(templatePath + "\\RandomExploration\\RandomExplorationRun-AdaptiveRandomSearchGenerateNewValues.m");
                GenerateNewValueCommand.ReplaceInTemplate("[NumCandidatePointsInAdaptiveRandomVal]", "5");
            }
            mainScriptCommand.ReplaceInTemplate("[MiLTester_GenerateNewValuesCode]", GenerateNewValueCommand);
            mainScriptCommand.ReplaceInTemplate("[MiLTester_CodeRootVal]", codePath);
            mainScriptCommand.ReplaceInTemplate("[MiLTester_SimulationTimeVal]", testWorkspace.GetSimulationTime().ToString());
            mainScriptCommand.ReplaceInTemplate("[MiLTester_SimulinkModelPathVal]", testWorkspace.modelSettings.SimulinkModelPath);
            mainScriptCommand.ReplaceInTemplate("[MiLTester_DesiredValueVar]", ccTestWorkspace.GetDesiredValueVariable().parameterName);
            mainScriptCommand.ReplaceInTemplate("[MiLTester_ActualValueVar]", ccTestWorkspace.GetActualValueVariable().parameterName);
            mainScriptCommand.ReplaceInTemplate("[MiLTester_MinAlgorithmIterationsVal]", ccTestWorkspace.GetRandomExplorationMinAlgorithmIterations().ToString());
            mainScriptCommand.ReplaceInTemplate("[MiLTester_MaxAlgorithmIterationsVal]", ccTestWorkspace.GetRandomExplorationMaxAlgorithmIterations().ToString());
            mainScriptCommand.ReplaceInTemplate("[MiLTester_NumberOfPointsInEachRegionVal]", ccTestWorkspace.ccSettings.numberOfPointsInEachRegion.ToString());
            mainScriptCommand.ReplaceInTemplate("[MiLTester_HeatMapDiagramDivisionFactorVal]", ccTestWorkspace.ccSettings.heatMapDiagramDivisionFactor.ToString());
            mainScriptCommand.ReplaceInTemplate("[MiLTester_RangeStartVal]", ccTestWorkspace.GetDesiredValueVariable().from.ToString());
            mainScriptCommand.ReplaceInTemplate("[MiLTester_RangeStopVal]", ccTestWorkspace.GetDesiredValueVariable().to.ToString());
            mainScriptCommand.ReplaceInTemplate("[MiLTester_CalibrationVariablesNamesVar]", ccTestWorkspace.GetCalibrationVariableNamesStr());
            mainScriptCommand.ReplaceInTemplate("[MiLTester_CalibrationVariablesMinimumsVal]", ccTestWorkspace.GetCalibrationVariableMinimumsStr());
            mainScriptCommand.ReplaceInTemplate("[MiLTester_CalibrationVariablesMaximumsVal]", ccTestWorkspace.GetCalibrationVariableMaximumsStr());

            mainScriptCommand.SaveToMatlabScript(tempPath + "\\" + MatlabCommandBuilder.MainScriptFileName + ".m");

            AsyncRunMainScript();
        }
 public ModelUnderTestCCSettings(CCTestWorkspace testWorkspace)
 {
     this.testWorkspace = testWorkspace;
     InitializeComponent();
     ////////////////////////////////////
     float from = 0,to = 0;
     TestParameter desiredVariable = testWorkspace.GetDesiredValueVariable();
     from = desiredVariable.from;
     to = desiredVariable.to;
     
     parentCCSettingsForm = new ParentCCSettingsForm(this, from, to);
     parentCCSettingsForm.LoadCCSettings(((CCTestWorkspace)testWorkspace).ccSettings);
     this.Controls.Add(parentCCSettingsForm);
     ////////////////////////////////////
     this.btnPrevious.Click += new System.EventHandler(this.btnPrevious_Click);
     this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
 }
示例#4
0
        private void RunCCTestCase()
        {
            CCTestWorkspace ccTestWorkspace = (CCTestWorkspace)testWorkspace;

            CompositeMatlabCommand mainScriptCommand = new CompositeMatlabCommand();

            mainScriptCommand.LoadFromMatlabScript(templatePath + "\\SingleTestRun.m");
            mainScriptCommand.ReplaceInTemplate("[MiLTester_CodeRootVal]", codePath);
            mainScriptCommand.ReplaceInTemplate("[MiLTester_SimulationTimeVal]", testWorkspace.GetSimulationTime().ToString());
            mainScriptCommand.ReplaceInTemplate("[MiLTester_SimulinkModelPathVal]", testWorkspace.modelSettings.SimulinkModelPath);
            mainScriptCommand.ReplaceInTemplate("[MiLTester_InitialDesiredVal]", ccTestCase.initialDesired.ToString());
            mainScriptCommand.ReplaceInTemplate("[MiLTester_FinalDesiredVal]", ccTestCase.finalDesired.ToString());
            mainScriptCommand.ReplaceInTemplate("[MiLTester_DesiredValueVar]", ccTestWorkspace.GetDesiredValueVariable().parameterName);
            mainScriptCommand.ReplaceInTemplate("[MiLTester_ActualValueVar]", ccTestWorkspace.GetActualValueVariable().parameterName);
            mainScriptCommand.ReplaceInTemplate("[MiLTester_CalibrationVariablesNamesVar]", ccTestWorkspace.GetCalibrationVariableNamesStr());
            mainScriptCommand.ReplaceInTemplate("[MiLTester_CalibrationVariablesValuesVal]", ccTestWorkspace.GetCalibrationVariableValuesStr());

            mainScriptCommand.SaveToMatlabScript(tempPath + "\\" + MatlabCommandBuilder.MainScriptFileName + ".m");
        }
示例#5
0
        private bool CreateTestWorkSpace()
        {
            bool InvalidName = false;

            foreach (char c in tbWorkspaceName.Text)
            {
                if (Path.GetInvalidFileNameChars().Contains(c))
                {
                    InvalidName = true;
                    break;
                }
            }
            if (InvalidName)
            {
                MessageBox.Show("The Test Workspace Name is Invalid! Select a name that can be used as the name of a Windows folder.",
                                "Invalid Test Workspace Name", MessageBoxButtons.OK);
                tbWorkspaceName.Focus();
                tbWorkspaceName.SelectAll();
                return(false);
            }

            if (!TestWorkspaceDataProvider.
                GetTestWorkspaceDataProvider().IsWorkspaceNameUnique(tbWorkspaceName.Text))
            {
                MessageBox.Show("The Test Workspace Name is Duplicate!",
                                "Dupllicate Test Workspace Name", MessageBoxButtons.OK);
                return(false);
            }
            if (rbContinuousController.Checked)
            {
                testWorkspace = new CCTestWorkspace(tbWorkspaceName.Text);
            }
            else if (rbSimulink.Checked)
            {
                testWorkspace = new SLTestWorkspace(tbWorkspaceName.Text);
            }
            else
            {
                testWorkspace = new IOTestWorkspace(tbWorkspaceName.Text);
            }
            return(true);
        }
示例#6
0
 private void SaveCCTestWorkspaceData(CCTestWorkspace cctestWorkspace, XmlWriter xmlTestWorkspaceWriter)
 {
     foreach (TestParameter ccTestParameter in cctestWorkspace.GetAllCCTestParameteres())
     {
         xmlTestWorkspaceWriter.WriteStartElement("Parameter");
         xmlTestWorkspaceWriter.WriteStartElement("Name");
         xmlTestWorkspaceWriter.WriteValue(ccTestParameter.parameterName);
         xmlTestWorkspaceWriter.WriteEndElement();
         xmlTestWorkspaceWriter.WriteStartElement("Type");
         xmlTestWorkspaceWriter.WriteValue(ccTestParameter.parameteresType.ToString());
         xmlTestWorkspaceWriter.WriteEndElement();
         xmlTestWorkspaceWriter.WriteStartElement("From");
         xmlTestWorkspaceWriter.WriteValue(ccTestParameter.from);
         xmlTestWorkspaceWriter.WriteEndElement();
         xmlTestWorkspaceWriter.WriteStartElement("To");
         xmlTestWorkspaceWriter.WriteValue(ccTestParameter.to);
         xmlTestWorkspaceWriter.WriteEndElement();
         xmlTestWorkspaceWriter.WriteStartElement("ValueForTest");
         xmlTestWorkspaceWriter.WriteValue(ccTestParameter.valueForTest);
         xmlTestWorkspaceWriter.WriteEndElement();
         xmlTestWorkspaceWriter.WriteEndElement();
     }
     return;
 }
示例#7
0
        public void RunSingleStateSearchInRegion(HeatMapRegion heatMapRegion)
        {
            MatlabAsyncProgram.KillMatlab();
            matlabAsyncProgram = new MatlabAsyncProgram(testWorkspace.modelSettings.MatlabExePath);
            CCTestWorkspace ccTestWorkspace = (CCTestWorkspace)testWorkspace;

            if (!Directory.Exists(tempPath))
            {
                Directory.CreateDirectory(tempPath);
            }
            File.Delete(outputLogPath);

            MatlabCommand modelSettingsCommand = MatlabCommandBuilder.GetModelSettingsMatlabCommand(ccTestWorkspace.modelSettings);

            modelSettingsCommand.SaveToMatlabScript(tempPath + "\\" + MatlabCommandBuilder.ModelSettingsScriptFileName + ".m");

            CompositeMatlabCommand mainScriptCommand = new CompositeMatlabCommand();

            mainScriptCommand.LoadFromMatlabScript(templatePath + "\\SingleStateSearch\\SingleStateSearch-Common.m");
            CompositeMatlabCommand GenerateNewValuesCommand = new CompositeMatlabCommand();
            CompositeMatlabCommand ReplaceValuesCommand     = new CompositeMatlabCommand();

            if (ccTestWorkspace.advancedCCSettings.singelStateSearchAlgorithm == SingelStateSearchAlgorithmsEnum.RandomSearch)
            {
                GenerateNewValuesCommand.LoadFromMatlabScript(templatePath + "\\SingleStateSearch\\RandomSearch\\SingleStateSearch-RandomSearchGenerateValues.m");
                ReplaceValuesCommand.LoadFromMatlabScript(templatePath + "\\SingleStateSearch\\RandomSearch\\SingleStateSearch-RandomSearchReplaceValues.m");
            }
            else if (ccTestWorkspace.advancedCCSettings.singelStateSearchAlgorithm == SingelStateSearchAlgorithmsEnum.HillClimbing)
            {
                GenerateNewValuesCommand.LoadFromMatlabScript(templatePath + "\\SingleStateSearch\\HillClimbing\\SingleStateSearch-HillClimbingGenerateValues.m");
                GenerateNewValuesCommand.ReplaceInTemplate("[MiLTester_EASigmalVal]", ccTestWorkspace.GetSigmaForSingleStateSearch().ToString());
                ReplaceValuesCommand.LoadFromMatlabScript(templatePath + "\\SingleStateSearch\\HillClimbing\\SingleStateSearch-HillClimbingReplaceValues.m");
            }
            else if (ccTestWorkspace.advancedCCSettings.singelStateSearchAlgorithm == SingelStateSearchAlgorithmsEnum.HCRR)
            {
                GenerateNewValuesCommand.LoadFromMatlabScript(templatePath + "\\SingleStateSearch\\HCRR\\SingleStateSearch-HillClimbingGenerateValues.m");
                GenerateNewValuesCommand.ReplaceInTemplate("[MiLTester_EASigmalVal]", ccTestWorkspace.GetSigmaForSingleStateSearch().ToString());
                ReplaceValuesCommand.LoadFromMatlabScript(templatePath + "\\SingleStateSearch\\HCRR\\SingleStateSearch-HillClimbingReplaceValues.m");
            }
            else if (ccTestWorkspace.advancedCCSettings.singelStateSearchAlgorithm == SingelStateSearchAlgorithmsEnum.SimulatedAnnealing)
            {
                GenerateNewValuesCommand.LoadFromMatlabScript(templatePath + "\\SingleStateSearch\\SimulatedAnnealing\\SingleStateSearch-SimulatedAnnealingGenerateValues.m");
                GenerateNewValuesCommand.ReplaceInTemplate("[MiLTester_EASigmalVal]", ccTestWorkspace.GetSigmaForSingleStateSearch().ToString());
                ReplaceValuesCommand.LoadFromMatlabScript(templatePath + "\\SingleStateSearch\\SimulatedAnnealing\\SingleStateSearch-SimulatedAnnealingReplaceValues.m");
                ReplaceValuesCommand.ReplaceInTemplate("[MiLTester_AnnealingScheduleVal]", ccTestWorkspace.GetAnnealingScheduleForSingleStateSearch().ToString());
            }

            mainScriptCommand.ReplaceInTemplate("[MiLTester_GenerateNewValuesCode]", GenerateNewValuesCommand);
            mainScriptCommand.ReplaceInTemplate("[MiLTester_ReplaceValuesCode]", ReplaceValuesCommand);
            mainScriptCommand.ReplaceInTemplate("[MiLTester_CodeRootVal]", codePath);
            mainScriptCommand.ReplaceInTemplate("[MiLTester_SimulationTimeVal]", testWorkspace.GetSimulationTime().ToString());
            mainScriptCommand.ReplaceInTemplate("[MiLTester_SimulinkModelPathVal]", testWorkspace.modelSettings.SimulinkModelPath);
            mainScriptCommand.ReplaceInTemplate("[MiLTester_SearchVariablesCntVal]", ccTestWorkspace.GetSearchVariablesCnt().ToString());
            mainScriptCommand.ReplaceInTemplate("[MiLTester_RegionWidthRangeStartVal]", heatMapRegion.xStart.ToString());
            mainScriptCommand.ReplaceInTemplate("[MiLTester_RegionWidthRangeStopVal]", heatMapRegion.xEnd.ToString());
            mainScriptCommand.ReplaceInTemplate("[MiLTester_RegionHeightRangeStartVal]", heatMapRegion.yStart.ToString());
            mainScriptCommand.ReplaceInTemplate("[MiLTester_RegionHeightRangeStopVal]", heatMapRegion.yEnd.ToString());
            mainScriptCommand.ReplaceInTemplate("[MiLTester_WorstPointFromRandomExplorationInitialDesiredVal]", heatMapRegion.worstCasePointFromRandomExploration.x.ToString());
            mainScriptCommand.ReplaceInTemplate("[MiLTester_WorstPointFromRandomExplorationFinalDesiredVal]", heatMapRegion.worstCasePointFromRandomExploration.y.ToString());
            mainScriptCommand.ReplaceInTemplate("[MiLTester_AlgorithmRoundsVal]", ccTestWorkspace.advancedCCSettings.algorithmRounds.ToString());
            mainScriptCommand.ReplaceInTemplate("[MiLTester_AlgorithmIterationsVal]", ccTestWorkspace.advancedCCSettings.algorithmIterations.ToString());
            mainScriptCommand.ReplaceInTemplate("[MiLTester_SelectedObjectiveFunction]", heatMapRegion.requirementName);
            mainScriptCommand.ReplaceInTemplate("[MiLTester_DesiredValueVar]", ccTestWorkspace.GetDesiredValueVariable().parameterName);
            mainScriptCommand.ReplaceInTemplate("[MiLTester_ActualValueVar]", ccTestWorkspace.GetActualValueVariable().parameterName);
            mainScriptCommand.ReplaceInTemplate("[MiLTester_RegionWidthIndexVal]", heatMapRegion.indexX.ToString());
            mainScriptCommand.ReplaceInTemplate("[MiLTester_RegionHeightIndexVal]", heatMapRegion.indexY.ToString());
            mainScriptCommand.ReplaceInTemplate("[MiLTester_RangeStartVal]", ccTestWorkspace.GetDesiredValueVariable().from.ToString());
            mainScriptCommand.ReplaceInTemplate("[MiLTester_RangeStopVal]", ccTestWorkspace.GetDesiredValueVariable().to.ToString());
            mainScriptCommand.ReplaceInTemplate("[MiLTester_AnnealingStartTemprature]", ccTestWorkspace.GetAnnealingStartTemprature().ToString());

            mainScriptCommand.SaveToMatlabScript(tempPath + "\\" + MatlabCommandBuilder.MainScriptFileName + ".m");

            AsyncRunMainScript();
        }
示例#8
0
 public CCTestWorkspaceResultsForm(CCTestWorkspace ccTestWorkspace)
 {
     this.ccTestWorkspace = ccTestWorkspace;
     InitializeComponent();
     InitValues();
 }
示例#9
0
        private void LoadCCTestWorkspace(CCTestWorkspace ccTestWorkspace)
        {
            XmlReaderSettings xmlSettings = new XmlReaderSettings();

            xmlSettings.ValidationType = ValidationType.None;
            string testWorkspaceName = ccTestWorkspace.ToString();

            ccTestWorkspace.ccSettings = SettingFilesManager.LoadCCSettings(
                GetWorkspacePath(testWorkspaceName));
            ccTestWorkspace.advancedCCSettings = SettingFilesManager.LoadAdvancedCCSettings(
                GetWorkspacePath(testWorkspaceName));
            XmlReader workspaceReader = XmlReader.Create(
                GetWorkspaceInfoFilePath(testWorkspaceName), xmlSettings);

            while (workspaceReader.Read())
            {
                if (workspaceReader.NodeType == XmlNodeType.Element &&
                    workspaceReader.Name == "Parameter")
                {
                    do
                    {
                        workspaceReader.Read();
                    }while (workspaceReader.Name != "Name");
                    workspaceReader.Read();
                    string paremeterName = workspaceReader.Value;
                    do
                    {
                        workspaceReader.Read();
                    }while (workspaceReader.Name != "Type");
                    workspaceReader.Read();
                    ParameteresType paremeterType =
                        (ParameteresType)Enum.Parse(typeof(ParameteresType), workspaceReader.Value, true);
                    do
                    {
                        workspaceReader.Read();
                    }while (workspaceReader.Name != "From");
                    workspaceReader.Read();
                    float from = float.Parse(workspaceReader.Value);

                    do
                    {
                        workspaceReader.Read();
                    }while (workspaceReader.Name != "To");
                    workspaceReader.Read();
                    float to = float.Parse(workspaceReader.Value);

                    do
                    {
                        workspaceReader.Read();
                    }while (workspaceReader.Name != "ValueForTest");
                    workspaceReader.Read();
                    float valueForTest = float.Parse(workspaceReader.Value);

                    if (paremeterType == ParameteresType.DesiredVariable)
                    {
                        ccTestWorkspace.SetDesiredValueVariable(new TestParameter(paremeterName,
                                                                                  paremeterType, from, to));
                    }
                    else if (paremeterType == ParameteresType.ActualVariable)
                    {
                        ccTestWorkspace.SetActualValueVariable(new TestParameter(paremeterName,
                                                                                 paremeterType, from, to));
                    }
                    else if (paremeterType == ParameteresType.CalibrationVariable)
                    {
                        ccTestWorkspace.AddCalibrationVariable(new TestParameter(paremeterName,
                                                                                 paremeterType, from, to, valueForTest));
                    }
                    workspaceReader.Read();
                }
            }
            workspaceReader.Close();
            return;
        }
示例#10
0
        public TestWorkspace LoadTestWorkspace(string testWorkspaceName)
        {
            XmlReaderSettings xmlSettings = new XmlReaderSettings();

            xmlSettings.ValidationType = ValidationType.None;

            XmlReader workspaceReader = XmlReader.Create(
                GetWorkspaceInfoFilePath(testWorkspaceName), xmlSettings);
            FunctionTypeEnum functionType  = FunctionTypeEnum.Continuous_Controller;
            TestWorkspace    testWorkspace = null;

            while (workspaceReader.Read())
            {
                if (workspaceReader.NodeType == XmlNodeType.Element &&
                    workspaceReader.Name == "FunctionType")
                {
                    workspaceReader.Read();
                    functionType =
                        (FunctionTypeEnum)Enum.Parse(typeof(FunctionTypeEnum), workspaceReader.Value, true);
                    switch (functionType)
                    {
                    case FunctionTypeEnum.Continuous_Controller:
                        testWorkspace = new CCTestWorkspace(testWorkspaceName);
                        break;

                    case FunctionTypeEnum.State_Based_Controller:
                        testWorkspace = new SLTestWorkspace(testWorkspaceName);
                        break;

                    case FunctionTypeEnum.Input_Output:
                        testWorkspace = new IOTestWorkspace(testWorkspaceName);
                        break;
                    }
                    workspaceReader.Read();
                }
                if (workspaceReader.NodeType == XmlNodeType.Element &&
                    workspaceReader.Name == "SimulationTime")
                {
                    workspaceReader.Read();
                    testWorkspace.SetSimulationTime(Int16.Parse(workspaceReader.Value));
                    workspaceReader.Read();
                }
                if (workspaceReader.NodeType == XmlNodeType.Element &&
                    workspaceReader.Name == "ModelRunningTime")
                {
                    workspaceReader.Read();
                    testWorkspace.SetModelRunningTime(Int16.Parse(workspaceReader.Value));
                    workspaceReader.Read();
                }
            }
            workspaceReader.Close();
            switch (testWorkspace.functionType)
            {
            case FunctionTypeEnum.Continuous_Controller:
                testWorkspace.modelSettings = SettingFilesManager.LoadModelSettings(
                    GetWorkspacePath(testWorkspaceName));
                LoadCCTestWorkspace((CCTestWorkspace)testWorkspace);
                break;

            case FunctionTypeEnum.State_Based_Controller:
                testWorkspace.modelSettings = SettingFilesManager.LoadModelSettings(
                    GetWorkspacePath(testWorkspaceName));
                LoadSBTestWorkspace((SLTestWorkspace)testWorkspace);
                break;

            case FunctionTypeEnum.Input_Output:
                break;
            }
            return(testWorkspace);
        }