Advertisement
Guest User

Untitled

a guest
Apr 25th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.05 KB | None | 0 0
  1. private static double estimateModifiedReliablility(double numberOfSimulations, double p, double T_max) {
  2. double failures = 0;
  3. Random random = new Random();      
  4. for (int i = 0; i < numberOfSimulations; i++) {        
  5.   SimpleWeightedGraph test_Graph = new SimpleWeightedGraph;
  6.   test_Graph = (SimpleWeightedGraph<Integer, DefaultWeightedEdge>) G.clone();
  7.   Object[] edgesArray = test_Graph.edgeSet().toArray();
  8.                    
  9.   for (int j = 0; j < edgesArray.length; j++) {
  10.      DefaultWeightedEdge edge = (DefaultWeightedEdge) edgesArray[j];
  11.      if (random.nextFloat() > p)
  12.        test_Graph.removeEdge(edge);
  13.   }
  14.            
  15.   connectivityInspector = new ConnectivityInspector(test_Graph);           
  16.   if (connectivityInspector.isGraphConnected()) {                  
  17.     if (testGraph()) {             
  18.       if (delay(test_Graph) > T_max)
  19.         failures++;                
  20.       }
  21.     else {
  22.       System.out.println("Przepływ jest większy od przepustowości");
  23.       return 0;
  24.     }
  25.   }
  26.   else {
  27.     failures++;
  28.   }
  29.  }      
  30. return (numberOfSimulations - failures) / numberOfSimulations;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement