なるほど、構内の問題には不向き(PuLPの方がいい)だが、構外の問題には良いようだ。
import numpy as np
tensor = np.random.rand(3, 3, 3)
tensor_A_to_B = tensor[:, 0, :]
tensor_B_to_C = tensor[0, :, :]
total_transport = np.einsum('ij,jk->ik', tensor_A_to_B, tensor_B_to_C)
print("Original Tensor (A→B→C):")
print(tensor)
print("\nSimplified Tensor A→B:")
print(tensor_A_to_B)
print("\nSimplified Tensor B→C:")
print(tensor_B_to_C)
print("\nTotal Transport (A→C through B):")
print(total_transport)