28 #ifndef SRC_UTIL_LSAP_SOLVER_HPP_ 29 #define SRC_UTIL_LSAP_SOLVER_HPP_ 31 #include "../env/common_types.hpp" 32 #include "../env/matrix.hpp" 109 std::size_t
get_assigned_col(std::size_t row, std::size_t solution_id = 0)
const;
117 std::size_t
get_assigned_row(std::size_t col, std::size_t solution_id = 0)
const;
125 double get_slack(std::size_t row, std::size_t col)
const;
185 bool solve_optimally_;
187 double minimal_cost_;
189 std::vector<std::vector<std::size_t>> row_to_col_assignments_;
191 std::vector<std::vector<std::size_t>> col_to_row_assignments_;
193 std::vector<double> dual_var_rows_;
195 std::vector<double> dual_var_cols_;
199 std::vector<std::size_t> construct_col_to_row_asignment_(
const std::vector<std::size_t>
row_to_col_assignment)
const;
201 void compute_cost_from_assignments_();
203 void compute_cost_from_dual_vars_();
std::size_t num_rows() const
Returns the number of rows of the LSAP problem instance.
See https://doi.org/10.1007/978-3-319-18224-7_1.
GreedyMethod
Selects a greedy method.
void set_greedy_method(const GreedyMethod &greedy_method)
Makes the solver use a greedy method.
ged::LSAPSolver class definition.
See https://doi.org/10.1007/978-3-319-18224-7_1.
double minimal_cost() const
Returns the cost of the computed solutions.
void clear_solution()
Clears a previously computed solution.
See https://doi.org/10.1007/978-3-319-18224-7_1.
void solve(int num_solutions=1)
Solves the LSAP problem instance.
const std::vector< std::size_t > & col_to_row_assignment(std::size_t solution_id=0) const
Returns the assignment from columns to rows.
void set_hungarian_algorithm()
Makes the solver use the Hungarian algorithm for optimal solving.
double get_dual_var_row(std::size_t row) const
Returns the dual variable of a row.
const DMatrix * cost_matrix() const
Returns the LSAP problem instance.
Global namespace for GEDLIB.
This class solves LSAP instances by calling the library lsape available at https://bougleux.users.greyc.fr/lsape/.
std::size_t get_assigned_col(std::size_t row, std::size_t solution_id=0) const
Returns the assigned column.
void set_problem(const DMatrix *cost_matrix)
Sets the LSAP problem instance.
See https://doi.org/10.1007/978-3-319-18224-7_1.
LSAPSolver()
Constructs empty solver.
double get_dual_var_col(std::size_t col) const
Returns the dual variable of a column.
std::size_t num_cols() const
Returns the number of columns of the LSAP problem instance.
See https://doi.org/10.1007/978-3-319-18224-7_1.
std::size_t num_solutions() const
Returns the number of solutions.
double get_slack(std::size_t row, std::size_t col) const
Returns the slack of a cell.
std::size_t get_assigned_row(std::size_t col, std::size_t solution_id=0) const
Returns the assigned row.
const std::vector< std::size_t > & row_to_col_assignment(std::size_t solution_id=0) const
Returns the assignment from rows to columns.