위험 분석 도구

위험 분석 수행

C ++ API 용 Tasks는 Microsoft Project (MPP/XML) 파일에 대한 위험 분석 수행을 지원합니다. 이는 다양한 확률 분포 및 상관 관계를 지원하는 Monte Carlo 시뮬레이션을 기반으로합니다. Aspose.Tasks .riskanalysis.riskanalyzer 클래스를 사용하여 프로젝트 일정 (작업 시간 및 시작/마감 날짜)을 기반으로하는 위험 분석을 수행 할 수 있습니다. 따라서 프로젝트 마감 날짜는 이러한 분석의 출력이 될 수 있습니다. 다음 코드 예제는이 기능을 단계별로 보여줍니다.

분석 준비

1System::SharedPtr<RiskAnalysisSettings> settings = System::MakeObject<RiskAnalysisSettings>();
2    
3// Set number of iterations for Monte Carlo simulation (the default value is 100).
4settings->set_IterationsCount(200);

Identifying the Input of Analysis

 1System::SharedPtr<Project> project = System::MakeObject<Project>(dataDir + u"Software Development Plan-1.mpp");
 2System::SharedPtr<Task> task = project->get_RootTask()->get_Children()->GetById(17);
 3    
 4// Initialize a risk pattern
 5System::SharedPtr<RiskPattern> pattern = System::MakeObject<RiskPattern>(task);
 6    
 7// Select a distribution type for the random number generator to generate possible values from (only two types currently supported, namely normal and uniform)            
 8// For more details see here: https://en.wikipedia.org/wiki/Normal_distribution)
 9pattern->set_Distribution(Aspose::Tasks::RiskAnalysis::ProbabilityDistributionType::Normal);
10    
11// Set the percentage of the most likely task duration which can happen in the best possible project scenario 
12// The default value is 75, which means that if the estimated specified task duration is 4 days then the optimistic duration will be 3 days
13pattern->set_Optimistic(70);
14    
15// Set the percentage of the most likely task duration which can happen in the worst possible project scenario 
16// The defaut value is 125, which means that if the estimated specified task duration is 4 days then the pessimistic duration will be 5 days.
17pattern->set_Pessimistic(130);
18    
19// Set a confidence level that correspond to the percentage of the time the actual values will be within optimistic and pessimistic estimates. 
20// You can think of it as a value of standard deviation: the more uncertain about your estimates you are, the more the value of standard deviation used in random number generator is
21pattern->set_ConfidenceLevel(Aspose::Tasks::RiskAnalysis::ConfidenceLevel::CL75);
22    
23settings->get_Patterns()->Add(pattern);
1// Analyze the project risks
2System::SharedPtr<RiskAnalyzer> analyzer = System::MakeObject<RiskAnalyzer>(settings);
3System::SharedPtr<RiskAnalysisResult> analysisResult = analyzer->Analyze(project);

Use the Results of the Analysis

 1// Select the desired output (here we get early finish of the root task)
 2System::SharedPtr<RiskItemStatistics> rootEarlyFinish = analysisResult->GetRiskItems(Aspose::Tasks::RiskAnalysis::RiskItemType::EarlyFinish)->Get(project->get_RootTask());
 3    
 4System::Console::WriteLine(u"Expected value: {0}", System::ObjectExt::Box<System::DateTime>(rootEarlyFinish->get_ExpectedValue()));
 5System::Console::WriteLine(u"StandardDeviation: {0}", System::ObjectExt::Box<Duration>(rootEarlyFinish->get_StandardDeviation()));
 6System::Console::WriteLine(u"10% Percentile: {0}", System::ObjectExt::Box<System::DateTime>(rootEarlyFinish->GetPercentile(10)));
 7System::Console::WriteLine(u"50% Percentile: {0}", System::ObjectExt::Box<System::DateTime>(rootEarlyFinish->GetPercentile(50)));
 8System::Console::WriteLine(u"90% Percentile: {0}", System::ObjectExt::Box<System::DateTime>(rootEarlyFinish->GetPercentile(90)));
 9System::Console::WriteLine(u"Minimum: {0}", System::ObjectExt::Box<System::DateTime>(rootEarlyFinish->get_Minimum()));
10System::Console::WriteLine(u"Maximum: {0}", System::ObjectExt::Box<System::DateTime>(rootEarlyFinish->get_Maximum()));
11    
12// Save PDF report which is rendered for Project Root Task Finish date
13analysisResult->SaveReport(dataDir + u"AnalysisReport_out.pdf");
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.