def test_gauss_seidel_2(self):
     print 'test gauss_seidel 2'
     g1,g2,d1,d2 = braess_heterogeneous(.25, .25)
     fs = gauss_seidel([g1,g2], [d1,d2], solver_2)
     a = np.array([[.125,.25],[.125,.0],[.0, .25],[.125, .0],[.125, .25]])
     self.check(fs, a, 1e-3)
     g1,g2,d1,d2 = braess_heterogeneous(1., 1.)
     a = np.array([[.5,.5],[.5,.5],[.0, .0],[.5, .5],[.5, .5]])
     fs = gauss_seidel([g1,g2], [d1,d2], solver_2) 
     self.check(fs, a, 1e-3)      
     g1,g2,d1,d2 = braess_heterogeneous(.75, .75)
     fs = gauss_seidel([g1,g2], [d1,d2], solver_2, max_iter=200)
     a = np.array([[.375, .625],[.375, .125],[.0, .5],[.375, .125],[.375, .625]])
     self.check(fs, a, 1e-3)
Exemplo n.º 2
0
 def test_fw_heterogeneous_2(self):
     print 'test fw_heterogeneous 2'
     g1,g2,d1,d2 = braess_heterogeneous(.25, .25)
     fs = fw_heterogeneous_2([g1,g2], [d1,d2], q=10, past=10)
     a = np.array([[.125,.25],[.125,.0],[.0, .25],[.125, .0],[.125, .25]])
     self.check(fs, a, 1e-2)
     g1,g2,d1,d2 = braess_heterogeneous(1., 1.)
     a = np.array([[.5,.5],[.5,.5],[.0, .0],[.5, .5],[.5, .5]])
     fs = fw_heterogeneous_2([g1,g2], [d1,d2], q=10, past=10) 
     self.check(fs, a, 1e-2)      
     g1,g2,d1,d2 = braess_heterogeneous(.75, .75)
     fs = fw_heterogeneous_2([g1,g2], [d1,d2], q=200, past=10, max_iter=200)
     a = np.array([[.375, .625],[.375, .125],[.0, .5],[.375, .125],[.375, .625]])
     self.check(np.sum(fs,1), np.sum(a,1), 1e-2) 
 def test_gauss_seidel_3(self):
     print 'test gauss_seidel 3'
     g1,g2,d1,d2 = braess_heterogeneous(.25, .25)
     fs = gauss_seidel([g1,g2], [d1,d2], solver_3)
     a = np.array([[.125,.25],[.125,.0],[.0, .25],[.125, .0],[.125, .25]])
     #print fs
     #print a
     self.check(fs, a, 1e-3)
     g1,g2,d1,d2 = braess_heterogeneous(1., 1.)
     a = np.array([[.5,.5],[.5,.5],[.0, .0],[.5, .5],[.5, .5]])
     fs = gauss_seidel([g1,g2], [d1,d2], solver_3) 
     self.check(fs, a, 1e-3)      
     g1,g2,d1,d2 = braess_heterogeneous(.75, .75)
     fs = gauss_seidel([g1,g2], [d1,d2], solver_3, q=50)
     a = np.array([[.375, .625],[.375, .125],[.0, .5],[.375, .125],[.375, .625]])
     self.check(fs, a, 1e-3)