add cost matrix handling with 4 different methods