@@ -771,3 +771,98 @@ def test_one_node_deterministic_nodeclassmatrix(self):
771771 [Decimal ('15.0' ), ((0 ,),)]
772772 ]
773773 self .assertEqual (Q .statetracker .history , expected_history )
774+
775+ def test_track_history_two_node_two_class (self ):
776+ N = ciw .create_network (
777+ arrival_distributions = {
778+ 'Class 0' : [ciw .dists .Exponential (0.5 ), ciw .dists .Exponential (0.5 )],
779+ 'Class 1' : [ciw .dists .Exponential (0.5 ), ciw .dists .Exponential (0.5 )]},
780+ service_distributions = {
781+ 'Class 0' : [ciw .dists .Exponential (1 ), ciw .dists .Exponential (1 )],
782+ 'Class 1' : [ciw .dists .Exponential (1 ), ciw .dists .Exponential (1 )]},
783+ number_of_servers = [1 , 1 ],
784+ routing = {
785+ 'Class 0' : [[0.2 , 0.2 ], [0.2 , 0.2 ]],
786+ 'Class 1' : [[0.2 , 0.2 ], [0.2 , 0.2 ]]}
787+ )
788+
789+ # System Population
790+ ciw .seed (0 )
791+ Q = ciw .Simulation (N , tracker = ciw .trackers .SystemPopulation ())
792+ Q .simulate_until_max_time (5 )
793+ observed_history = Q .statetracker .history
794+ expected_history = [
795+ [0.00 , 0 ],
796+ [0.60 , 1 ],
797+ [1.09 , 2 ],
798+ [1.32 , 2 ],
799+ [1.64 , 3 ],
800+ [1.96 , 2 ],
801+ [2.67 , 2 ],
802+ [2.84 , 3 ],
803+ [3.39 , 4 ],
804+ [3.41 , 5 ],
805+ [3.72 , 6 ],
806+ [3.80 , 5 ],
807+ [4.07 , 4 ],
808+ [4.15 , 5 ],
809+ [4.17 , 4 ],
810+ [4.28 , 3 ]
811+ ]
812+ self .assertEqual (len (observed_history ), len (expected_history ))
813+ for obs , exp in zip (observed_history , expected_history ):
814+ self .assertEqual ([round (obs [0 ], 2 ), obs [1 ]], exp )
815+
816+ # Node Population
817+ ciw .seed (0 )
818+ Q = ciw .Simulation (N , tracker = ciw .trackers .NodePopulation ())
819+ Q .simulate_until_max_time (5 )
820+ observed_history = Q .statetracker .history
821+ expected_history = [
822+ [0.00 , (0 , 0 )],
823+ [0.60 , (0 , 1 )],
824+ [1.09 , (0 , 2 )],
825+ [1.32 , (0 , 2 )],
826+ [1.64 , (0 , 3 )],
827+ [1.96 , (0 , 2 )],
828+ [2.67 , (0 , 2 )],
829+ [2.84 , (1 , 2 )],
830+ [3.39 , (1 , 3 )],
831+ [3.41 , (2 , 3 )],
832+ [3.72 , (3 , 3 )],
833+ [3.80 , (2 , 3 )],
834+ [4.07 , (2 , 2 )],
835+ [4.15 , (2 , 3 )],
836+ [4.17 , (1 , 3 )],
837+ [4.28 , (0 , 3 )]
838+ ]
839+ self .assertEqual (len (observed_history ), len (expected_history ))
840+ for obs , exp in zip (observed_history , expected_history ):
841+ self .assertEqual ([round (obs [0 ], 2 ), obs [1 ]], exp )
842+
843+ # Node Class Matrix
844+ ciw .seed (0 )
845+ Q = ciw .Simulation (N , tracker = ciw .trackers .NodeClassMatrix ())
846+ Q .simulate_until_max_time (5 )
847+ observed_history = Q .statetracker .history
848+ expected_history = [
849+ [0.00 , ((0 , 0 ), (0 , 0 ))],
850+ [0.60 , ((0 , 0 ), (0 , 1 ))],
851+ [1.09 , ((0 , 0 ), (1 , 1 ))],
852+ [1.32 , ((0 , 0 ), (1 , 1 ))],
853+ [1.64 , ((0 , 0 ), (1 , 2 ))],
854+ [1.96 , ((0 , 0 ), (0 , 2 ))],
855+ [2.67 , ((0 , 0 ), (0 , 2 ))],
856+ [2.84 , ((0 , 1 ), (0 , 2 ))],
857+ [3.39 , ((0 , 1 ), (0 , 3 ))],
858+ [3.41 , ((0 , 2 ), (0 , 3 ))],
859+ [3.72 , ((1 , 2 ), (0 , 3 ))],
860+ [3.80 , ((1 , 1 ), (0 , 3 ))],
861+ [4.07 , ((1 , 1 ), (0 , 2 ))],
862+ [4.15 , ((1 , 1 ), (1 , 2 ))],
863+ [4.17 , ((1 , 0 ), (1 , 2 ))],
864+ [4.28 , ((0 , 0 ), (1 , 2 ))]
865+ ]
866+ self .assertEqual (len (observed_history ), len (expected_history ))
867+ for obs , exp in zip (observed_history , expected_history ):
868+ self .assertEqual ([round (obs [0 ], 2 ), obs [1 ]], exp )
0 commit comments