TEST_F(AnalysisDriverFixture,SimpleProject_Create) { openstudio::path projectDir = toPath("AnalysisDriverFixtureData"); if (!boost::filesystem::exists(projectDir)) { boost::filesystem::create_directory(projectDir); } projectDir = projectDir / toPath("NewProject"); boost::filesystem::remove_all(projectDir); OptionalSimpleProject project = SimpleProject::create(projectDir); ASSERT_TRUE(project); EXPECT_TRUE(boost::filesystem::exists(projectDir)); EXPECT_TRUE(boost::filesystem::is_directory(projectDir)); EXPECT_TRUE(boost::filesystem::exists(projectDir / toPath("project.osp"))); EXPECT_TRUE(boost::filesystem::exists(projectDir / toPath("run.db"))); EXPECT_TRUE(boost::filesystem::exists(projectDir / toPath("project.log"))); Analysis analysis = project->analysis(); EXPECT_EQ(0,analysis.problem().numVariables()); EXPECT_FALSE(analysis.algorithm()); EXPECT_EQ(0u,analysis.dataPoints().size()); AnalysisRecord analysisRecord = project->analysisRecord(); EXPECT_EQ(0u,analysisRecord.problemRecord().inputVariableRecords().size()); EXPECT_EQ(0u,analysisRecord.dataPointRecords().size()); }
TEST_F(AnalysisDriverFixture, DesignOfExperiments_MeshAnalysis) { openstudio::path rubyLibDirPath = openstudio::toPath(rubyLibDir()); // GET SIMPLE PROJECT SimpleProject project = getCleanSimpleProject("DesignOfExperiments_MeshAnalysis"); Analysis analysis = project.analysis(); // SET PROBLEM Problem problem = retrieveProblem("MixedOsmIdf",false,false); analysis.setProblem(problem); // SET SEED Model model = model::exampleModel(); openstudio::path p = toPath("./example.osm"); model.save(p,true); FileReference seedModel(p); analysis.setSeed(seedModel); // SET ALGORITHM DesignOfExperimentsOptions algOptions(DesignOfExperimentsType::FullFactorial); DesignOfExperiments algorithm(algOptions); analysis.setAlgorithm(algorithm); // RUN ANALYSIS AnalysisDriver driver = project.analysisDriver(); AnalysisRunOptions runOptions = standardRunOptions(project.projectDir()); driver.run(analysis,runOptions); EXPECT_TRUE(driver.waitForFinished()); // CHECK RESULTS AnalysisRecord analysisRecord = project.analysisRecord(); EXPECT_EQ(4,analysisRecord.problemRecord().combinatorialSize(true).get()); EXPECT_EQ(4u, analysisRecord.dataPointRecords().size()); BOOST_FOREACH(const DataPointRecord& dataPointRecord, analysisRecord.dataPointRecords()) { EXPECT_TRUE(dataPointRecord.isComplete()); EXPECT_FALSE(dataPointRecord.failed()); } // get data points by perturbations and vice versa std::vector<DataPointRecord> testDataPoints; std::vector<QVariant> testVariableValues; // all data points are successful testDataPoints = analysisRecord.successfulDataPointRecords(); EXPECT_EQ(4u,testDataPoints.size()); // empty variableValues returns all data points testDataPoints = analysisRecord.getDataPointRecords(testVariableValues); EXPECT_EQ(4u, testDataPoints.size()); // find the baseline testVariableValues.clear(); testVariableValues.push_back(0); testVariableValues.push_back(QVariant(QVariant::Int)); // only one perturbation, null works too testVariableValues.push_back(0); ASSERT_TRUE(testVariableValues[1].isNull()); testDataPoints = analysisRecord.getDataPointRecords(testVariableValues); ASSERT_EQ(1u, testDataPoints.size()); // find model with improved wall and roof testVariableValues.clear(); testVariableValues.push_back(1); testVariableValues.push_back(0); testVariableValues.push_back(1); testDataPoints = analysisRecord.getDataPointRecords(testVariableValues); ASSERT_EQ(1u, testDataPoints.size()); DataPoint testDataPoint = testDataPoints[0].dataPoint(); std::vector<OptionalDiscretePerturbation> perturbations = analysis.problem().getDiscretePerturbations(testVariableValues); ASSERT_EQ(3u,perturbations.size()); ASSERT_TRUE(perturbations[0] && perturbations[1] && perturbations[2]); EXPECT_TRUE(perturbations[0]->uuid() == problem.variables()[0].cast<DiscreteVariable>().perturbations(false)[1].uuid()); EXPECT_TRUE(perturbations[1]->uuid() == problem.variables()[1].cast<DiscreteVariable>().perturbations(false)[0].uuid()); EXPECT_TRUE(perturbations[2]->uuid() == problem.variables()[2].cast<DiscreteVariable>().perturbations(false)[1].uuid()); EXPECT_TRUE(perturbations[0]->optionalCast<RubyPerturbation>()); EXPECT_TRUE(perturbations[1]->optionalCast<RubyPerturbation>()); EXPECT_TRUE(perturbations[2]->optionalCast<RubyPerturbation>()); // find models with improved wall testVariableValues.clear(); testVariableValues.push_back(1); testDataPoints = analysisRecord.getDataPointRecords(testVariableValues); ASSERT_EQ(2u, testDataPoints.size()); // infeasible testVariableValues.clear(); testVariableValues.push_back(0); testVariableValues.push_back(0); testVariableValues.push_back(0); testVariableValues.push_back(0); testDataPoints = analysisRecord.getDataPointRecords(testVariableValues); ASSERT_EQ(0u, testDataPoints.size()); }