Outil d'analyse des risques pour les développeurs Java

Effectuer une analyse des risques

Aspose.Tasks pour l’API Java prend en charge pour effectuer une analyse des risques sur un fichier de données de projet. Ceci est basé sur la simulation Monte Carlo qui prend en charge différentes distributions de probabilité et corrélations. La classe RiskAnalyzer peut être utilisée pour effectuer l’analyse des risques basée sur un calendrier de projet (durée des tâches et leurs dates de début / fin). Ainsi, une date de fin du projet peut être la sortie d’une telle analyse. L’exemple suivant illustre cette fonctionnalité étape par étape.

1. Préparation des paramètres d’analyse

1// For complete examples and data files, please go to https://github.com/aspose-tasks/Aspose.Tasks-for-Java
2RiskAnalysisSettings settings = new RiskAnalysisSettings();
3// set a number of iterations for Monte Carlo simulation (the default value is 100).
4settings.setIterationsCount(200);

2. Identifying the Input of Analysis

 1// For complete examples and data files, please go to https://github.com/aspose-tasks/Aspose.Tasks-for-Java
 2Project project = new Project("NewProductDev.mpp"); // attached test project
 3
 4// Initialize a risk pattern
 5Task task = project.getRootTask().getChildren().getById(14);
 6
 7RiskPattern pattern = new RiskPattern(task);
 8// Select a distribution type for the random number generator to generate possible values from (only two types currently supported, namely normal and uniform)
 9// note that the normal distributions are often used in the natural and social sciences to represent real-valued random variables whose distributions are not known,
10// thus this distribution is set to default (for more details see here: https://en.wikipedia.org/wiki/Normal_distribution)
11pattern.setDistribution (ProbabilityDistributionType.Normal);
12// Set the percentage of the most likely task duration which can happen in the best possible project scenario
13// (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)
14pattern.setOptimistic(70);
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.setPessimistic(130);
18// Set a confidence level that correspond to the percentage of the time the actual values will be within optimistic and pessimistic estimates.
19// 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
20pattern.setConfidenceLevel(ConfidenceLevel.CL75);
21
22// you can add as many risk patterns as needed to model expected project risks
23settings.getPatterns().add(pattern);

3. Analyze the Risks

1RiskAnalyzer analyzer = new RiskAnalyzer(settings);
2RiskAnalysisResult analysisResult = analyzer.analyze(project);

4. Use the Results of the Analysis

 1// For complete examples and data files, please go to https://github.com/aspose-tasks/Aspose.Tasks-for-Java
 2//Select the desired output (here we get early finish of the root task)
 3RiskItemStatistics rootEarlyFinish = analysisResult.getRiskItems(RiskItemType.EarlyFinish).get(project.getRootTask());
 4
 5System.out.println("Expected value: "+ rootEarlyFinish.getExpectedValue());
 6System.out.println("StandardDeviation: " + rootEarlyFinish.getStandardDeviation());
 7System.out.println("10% Percentile: " +rootEarlyFinish.getPercentile(10));
 8System.out.println("50% Percentile: " + rootEarlyFinish.getPercentile(50));
 9System.out.println("90% Percentile: " + rootEarlyFinish.getPercentile(90));
10System.out.println("Minimum: " + rootEarlyFinish.getMinimum());
11System.out.println("Maximum: " + rootEarlyFinish.getMaximum());
12
13// Also pdf report can be saved (it is rendered for Project Root Task Finish date):
14analysisResult.saveReport("AnalysisReport.pdf");
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.