Outil d'analyse des risques

Effectuer une analyse des risques

Aspose.Tasks pour l’API C ++ prend en charge la réalisation d’analyses de risques sur les fichiers Microsoft Project (MPP / XML). Ceci est basé sur la simulation Monte Carlo qui prend en charge différentes distributions de probabilité et corrélations. La classe Aspose.Tasks.Riskanalysis. Ainsi, une date de fin du projet peut être la sortie d’une telle analyse. L’exemple de code suivant illustre cette fonctionnalité étape par étape.

Préparation des paramètres d’analyse

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.