58 explicit AssignmentState(
const size_t n = 0)
59 :
row(0), total_cost(0), used_columns(n, 0), assigned_column(n, -1)
65class AssignmentBBDomain
73 using State = AssignmentState;
74 using Objective =
int;
82 bool is_complete(
const State &state)
const
84 return state.row == costs_.size();
87 Objective objective_value(
const State &state)
const
89 return state.total_cost;
92 Objective bound(
const State &state)
const
96 for (
size_t row = state.row;
row < costs_.size(); ++
row)
109 void apply(State &state,
const Move &move)
const
111 state.total_cost += costs_[state.row][move.col];
112 state.used_columns[move.col] = 1;
113 state.assigned_column[state.row] =
static_cast<int>(move.col);
117 void undo(State &state,
const Move &move)
const
120 state.total_cost -= costs_[state.row][move.col];
121 state.used_columns[move.col] = 0;
122 state.assigned_column[state.row] = -1;
125 template <
typename Visitor>
126 bool for_each_successor(
const State &state,
Visitor visit)
const
128 if (state.row >= costs_.size())
131 for (
size_t col = 0;
col < costs_[state.row].size(); ++
col)
144 std::cout <<
"Assignment:";
145 for (
size_t row = 0;
row < state.assigned_column.size(); ++
row)
146 std::cout <<
" row" <<
row <<
"->col" << state.assigned_column[
row];
164 policy.
strategy = Search::ExplorationPolicy::Strategy::Best_First;
167 auto result =
engine.search(AssignmentState(
costs.size()));
169 std::cout <<
"Optimal assignment cost: " << result.incumbent.best_value() <<
'\n';
170 std::cout <<
"Visited states: " << result.stats.visited_states <<
'\n';
171 std::cout <<
"Pruned by bound: " << result.stats.pruned_by_bound <<
'\n';
Umbrella header for the implicit state-space search framework.
Simple dynamic array with automatic resizing and functional operations.
Reusable branch-and-bound engine over implicit state spaces.
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
User-facing facade exported by the umbrella search header.
and
Check uniqueness with explicit hash + equality functors.
Exploration controls shared across engines.
Strategy strategy
Traversal strategy.
Objective policy for minimization problems.
Dynamic array container with automatic resizing.