Exemplo n.º 1
0
        public void PET_File_Recorder_via_MasterInterpreter()
        {
            string objectAbsPath = "/@Testing/@ParametricExploration/@TestFileRecorder";

            //Run CyPhyPET
            var result = CyPhyMasterInterpreterRunner.RunMasterInterpreterAndReturnResults(
                projectPath: this.mgaFile,
                absPath: objectAbsPath,
                configPath: objectAbsPath,
                postToJobManager: false,
                keepTempModels: false);

            Assert.True(result.Success, "CyPhyMasterInterpreter run should have succeeded, but did not.");
            var outputDir = result.OutputDirectory;

            //Run run_mdao
            string stderr  = "<did not start process>";
            int    retcode = Run("Unused Parameter?", outputDir, out stderr);

            Assert.True(0 == retcode, "run_mdao failed: " + stderr);

            //Compare values in 'output.csv' to 'file_x.txt'
            var lines = File.ReadAllLines(Path.Combine(outputDir, "output.csv"));

            Assert.True(lines[0] == "GUID,x", "Header doesn't match.");
            foreach (var line in lines.Skip(1))
            {
                var values   = line.Split(',');
                var filepath = Path.Combine(outputDir, "artifacts", values[0], "file_x.txt");
                Assert.True(File.ReadAllLines(filepath)[0] == values[1], "Values didn't match between 'output.csv' and 'file_x.txt'.");
            }
        }
Exemplo n.º 2
0
        public void Support_FEA_Test_Bench_Via_MasterInterpreter()
        {
            //string outputDir = "BallisticTestBench_BallisticHasTestInjectionPoint_Invalid";
            string objectAbsPath = "/@Testing/@ParametricExploration/@TestFEA";
            string configAbsPath = "/@Designs/@Box";

            var success = CyPhyMasterInterpreterRunner.RunMasterInterpreter(
                projectPath: this.mgaFile,
                absPath: objectAbsPath,
                configPath: configAbsPath,
                postToJobManager: false,
                keepTempModels: false);

            Assert.True(success, "CyPhyMasterInterpreter run should have succeeded, but did not.");
        }
Exemplo n.º 3
0
        public void Kinematic_Excavator_CyPhy2CADFail()
        {
            //string outputDir = "MI_10_TestBench_MSD_om_DS_MassSpringDamper_cfg4";
            string objectAbsPath = "/@Testing/@TestFail/@Kinematic_Excavator_CyPhy2CADFail";
            string configAbsPath = "/@ComponentAssemblies/@TestFail/@Excavator_CyPhy2CADFail";

            Assert.True(File.Exists(mgaFile), "Failed to generate the mga.");

            var success = CyPhyMasterInterpreterRunner.RunMasterInterpreter(
                projectPath: mgaFile,
                absPath: objectAbsPath,
                configPath: configAbsPath,
                postToJobManager: false,
                keepTempModels: false);

            Assert.False(success, "CyPhyMasterInterpreter run should have failed, but did not.");
        }
Exemplo n.º 4
0
        public void PET_OptimizerConstraintIntermediate_via_MasterInterpreter()
        {
            string objectAbsPath = "/@Testing/@ParametricExploration/@TestOptimizerIntermediateValueConstraint";

            //Run CyPhyPET
            var result = CyPhyMasterInterpreterRunner.RunMasterInterpreterAndReturnResults(
                projectPath: this.mgaFile,
                absPath: objectAbsPath,
                configPath: objectAbsPath,
                postToJobManager: false,
                keepTempModels: false);

            Assert.True(result.Success, "CyPhyMasterInterpreter run should have succeeded, but did not.");
            var outputDir = result.OutputDirectory;

            //Check mdao_config.json
            var configContents = File.ReadAllText(Path.Combine(outputDir, "mdao_config.json"));
            var config         = JsonConvert.DeserializeObject <AVM.DDP.PETConfig>(configContents);

            Assert.Equal(config.drivers["Optimizer"].constraints["constraint"].source[0], "Paraboloid");
            Assert.Equal(config.drivers["Optimizer"].constraints["constraint"].source[1], "f_xy");
            Assert.Equal(config.drivers["Optimizer"].intermediateVariables["z"].source[0], "Add2");
            Assert.Equal(config.drivers["Optimizer"].intermediateVariables["z"].source[1], "y");

            ////Run run_mdao
            string stderr  = "<did not start process>";
            int    retcode = Run(null, outputDir, out stderr);

            Assert.True(0 == retcode, "run_mdao failed: " + stderr);

            //Check output.csv results
            var lines = File.ReadAllLines(Path.Combine(outputDir, "output.csv"));

            Assert.Equal("GUID,z,f_xy,constraint,x,y", lines[0]);

            //Check final optimized answer
            var final_values = lines[lines.Count() - 1].Split(',');

            Assert.Equal(6.6667, Double.Parse(final_values[1]), 4);
            Assert.Equal(-27.3333, Double.Parse(final_values[2]), 4);
            Assert.Equal(-27.3333, Double.Parse(final_values[3]), 4);
            Assert.Equal(4.6667, Double.Parse(final_values[4]), 4);
            Assert.Equal(-7.3333, Double.Parse(final_values[5]), 4);
        }
Exemplo n.º 5
0
        public void Test__TestTestBench_With_Files__MasterInterpreter()
        {
            string objectAbsPath = "/@Testing/@ParametricExploration/@TestTestBench_With_Files";
            string configAbsPath = "/@Designs/@SimpleSystem";

            var result = CyPhyMasterInterpreterRunner.RunMasterInterpreterAndReturnResults(
                projectPath: this.mgaFile,
                absPath: objectAbsPath,
                configPath: configAbsPath,
                postToJobManager: false,
                keepTempModels: false);

            Assert.True(result.Success, "CyPhyMasterInterpreter run should have succeeded, but did not.");

            var configContents = File.ReadAllText(Path.Combine(result.OutputDirectory, "mdao_config.json"));
            var config         = JsonConvert.DeserializeObject <AVM.DDP.PETConfig>(configContents);

            Assert.Equal(objectAbsPath.Replace("@", ""), config.PETName);
        }