#include "hungarianoper.h" Eigen::Matrix HungarianOper::Solve(const DYNAMICM &cost_matrix) { int rows = cost_matrix.rows(); int cols = cost_matrix.cols(); Matrix matrix(rows, cols); for (int row = 0; row < rows; row++) { for (int col = 0; col < cols; col++) { matrix(row, col) = cost_matrix(row, col); } } Munkres m; m.solve(matrix); // std::vector> pairs; for (int row = 0; row < rows; row++) { for (int col = 0; col < cols; col++) { int tmp = (int)matrix(row, col); if (tmp == 0) pairs.push_back(std::make_pair(row, col)); } } // int count = pairs.size(); Eigen::Matrix re(count, 2); for (int i = 0; i < count; i++) { re(i, 0) = pairs[i].first; re(i, 1) = pairs[i].second; } return re; }