Інструмент аналізу ризику
Contents
[
Hide
Show
]Проведення аналізу ризику
Aspose.Tasks для C ++ API підтримує проведення аналізу ризиків у файлах Microsoft Project (MPP/XML). Це ґрунтується на моделюванні Монте -Карло, яке підтримує різні розподіли і кореляцій ймовірності. 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");