def test_solver(self): # Frank-Wolfe from Algorithm 1 of Jaggi's paper print 'test solver' graph = np.loadtxt('data/braess_net.csv', delimiter=',', skiprows=1) demand = np.loadtxt('data/braess_od.csv', delimiter=',', skiprows=1) demand = np.reshape(demand, (1, 3)) f = solver(graph, demand, max_iter=300) self.check(f, np.array([1., 1., 0., 1., 1.]), 1e-2) # modify demand demand[0, 2] = 0.5 f = solver(graph, demand) self.check(f, np.array([.5, .0, .5, .0, .5]), 1e-8)
def test_solver(self): # Frank-Wolfe from Algorithm 1 of Jaggi's paper print 'test solver' graph = np.loadtxt('data/braess_net.csv', delimiter=',', skiprows=1) demand = np.loadtxt('data/braess_od.csv', delimiter=',', skiprows=1) demand=np.reshape(demand, (1,3)) f = solver(graph, demand, max_iter=300) self.check(f, np.array([1.,1.,0.,1.,1.]), 1e-2) # modify demand demand[0,2] = 0.5 f = solver(graph, demand) self.check(f, np.array([.5,.0,.5,.0,.5]), 1e-8)
def test_solver_sioux_falls(self): print 'test Frank-Wolfe on Sioux Falls' graph = np.loadtxt('data/SiouxFalls_net.csv', delimiter=',', skiprows=1) demand = np.loadtxt('data/SiouxFalls_od.csv', delimiter=',', skiprows=1) demand[:,2] = demand[:,2] / 4000 f = solver(graph, demand, max_iter=1000) results = np.loadtxt('data/SiouxFalls_results.csv') self.check(f*4000, results, 1e-3)
def test_anaheim(self): print 'test Frank-Wolfe on Anaheim' graph = np.loadtxt('data/Anaheim_net.csv', delimiter=',', skiprows=1) demand = np.loadtxt('data/Anaheim_od.csv', delimiter=',', skiprows=1) demand[:, 2] = demand[:, 2] / 4000 f = solver(graph, demand, max_iter=1000) # print f.shape results = np.loadtxt('data/Anaheim_results.csv') print np.linalg.norm(f * 4000 - results) / np.linalg.norm(results)
def test_anaheim(self): print 'test Frank-Wolfe on Anaheim' graph = np.loadtxt('data/Anaheim_net.csv', delimiter=',', skiprows=1) demand = np.loadtxt('data/Anaheim_od.csv', delimiter=',', skiprows=1) demand[:,2] = demand[:,2] / 4000 f = solver(graph, demand, max_iter=1000) # print f.shape results = np.loadtxt('data/Anaheim_results.csv') print np.linalg.norm(f*4000 - results) / np.linalg.norm(results)
def test_solver_sioux_falls(self): print 'test Frank-Wolfe on Sioux Falls' graph = np.loadtxt('data/SiouxFalls_net.csv', delimiter=',', skiprows=1) demand = np.loadtxt('data/SiouxFalls_od.csv', delimiter=',', skiprows=1) demand[:, 2] = demand[:, 2] / 4000 f = solver(graph, demand, max_iter=1000) results = np.loadtxt('data/SiouxFalls_results.csv') self.check(f * 4000, results, 1e-3)