def setUp(self):
     activities = [activity() for number in range(9)]
     [activities[i].AssignID(i+1) for i in range(9)]
     [activities[i].AssignDuration(10) for i in range(9)]
     [activities[i].AssignDurationRange(MIN=5, ML=9, MAX=40) for i in range(9)]
     [activities[i].AssignSuccsesors(i+2) for i in range(8)]
     self.P = network()
     self.P.AddActivity(*activities)
 def test_Float1(self):
     """Tests total floats in network"""
     activities = [activity() for number in range(3)]
     [activities[i].AssignID(i+1) for i in range(3)]
     [activities[i].AssignDuration(duration) for duration, i in zip([5,10,1], range(3))]
     [activities[i].AssignSuccsesors(3) for i in range(3)]
     P = network()
     P.AddActivity(*activities)
     P.CalculateTotalFloats()
     calculated_floats = [act.GetSlack() for act in P]
     floats = [5,0,0]
     self.assertListEqual(calculated_floats, floats)
 def test_ProbabiliyOfCritical(self):
     """ Tests calculation of probability of criticality of an activity"""
     activities = [activity() for number in range(3)]
     [activities[i].AssignID(i+1) for i in range(3)]
     [activities[i].AssignDuration(duration) for duration, i in zip([100,100,100], range(3))]
     [activities[i].AssignDurationRange(min=50, ml=100, max=150) for i in range(3)]
     [activities[i].AssignSuccsesors(3) for i in range(2)]
     P = network()
     P.AddActivity(*activities)
     P.Simulate(1000)
     for i in range(1,4):
         self.assertGreater(P.GetProbabiltyOfCritical(ID=i), 0)
         self.assertLessEqual(P.GetProbabiltyOfCritical(ID=i), 1)
 def test_Float4(self):
     """Tests total floats in network with on start-start constraint"""
     activities = [activity() for number in range(4)]
     [activities[i].AssignID(i+1) for i in range(4)]
     [activities[i].AssignDuration(duration) for duration, i in zip([5,10,20,3], range(4))]   
     
     activities[0].AssignSuccsesors(2)
     activities[1].AssignSuccsesors('4ss')
     activities[2].AssignSuccsesors(4)  
     
     P = network()
     P.AddActivity(*activities)
     P.CalculateTotalFloats()
     calculated_floats = [act.GetSlack() for act in P]
     floats = [15,15,0,0]
     self.assertListEqual(calculated_floats, floats)
	def setUp(self):
		self.activity = activity()
		self.duration = 10
	def setUp(self):
		self.activity = activity()