27 #ifndef SRC_METHODS_BLP_NO_EDGE_LABELS_IPP_ 28 #define SRC_METHODS_BLP_NO_EDGE_LABELS_IPP_ 33 template<
class UserNodeLabel,
class UserEdgeLabel>
34 BLPNoEdgeLabels<UserNodeLabel, UserEdgeLabel>::
37 template<
class UserNodeLabel,
class UserEdgeLabel>
38 BLPNoEdgeLabels<UserNodeLabel, UserEdgeLabel>::
39 BLPNoEdgeLabels(
const GEDData<UserNodeLabel, UserEdgeLabel> & ged_data) :
40 MIPBasedMethod<UserNodeLabel, UserEdgeLabel>(ged_data),
45 template<
class UserNodeLabel,
class UserEdgeLabel>
56 double min_edge_ins_del_cost{std::min(this->
ged_data_.min_edge_del_cost(g), this->
ged_data_.min_edge_ins_cost(h))};
62 NodeMap::Assignment key;
80 x_[key] = model.addVar(0, 1, 0, variable_type_());
82 s_[key] = model.addVar(0, 1, min_edge_ins_del_cost / 2, variable_type_());
83 t_[key] = model.addVar(0, 1, min_edge_ins_del_cost / 2, variable_type_());
96 model.addConstr(lhs, GRB_EQUAL, 1);
105 model.addConstr(lhs, GRB_EQUAL, 1);
113 lhs = s_.at(key) - t_.at(key);
116 key.first = g.
head(*ij);
123 key.second = h.
head(*kl);
127 model.addConstr(lhs, GRB_EQUAL, 0);
134 template<
class UserNodeLabel,
class UserEdgeLabel>
140 std::vector<bool> delete_node(g.
num_nodes(),
true);
141 std::vector<bool> insert_node(h.
num_nodes(),
true);
145 for (
auto it = x_.begin(); it != x_.end(); it++) {
147 k = it->first.second;
148 if ((i < g.
num_nodes()) and (k < h.
num_nodes()) and (it->second.get(GRB_DoubleAttr_X) > 0)) {
150 delete_node[i] =
false;
151 insert_node[k] =
false;
157 if (delete_node.at(i)) {
164 if (insert_node.at(k)) {
170 this->
ged_data_.compute_induced_cost(g, h, node_map);
174 template<
class UserNodeLabel,
class UserEdgeLabel>
179 for (
auto it = x_.begin(); it != x_.end(); it++) {
180 i = std::min(it->first.first, g.
num_nodes());
181 k = std::min(it->first.second, h.
num_nodes());
182 lsape_instance(i, k) -= it->second.get(GRB_DoubleAttr_X);
187 template<
class UserNodeLabel,
class UserEdgeLabel>
192 return GRB_CONTINUOUS;
bool relax_
If true, the model populated by mip_populate_model_() must be continuous.
std::size_t num_nodes() const
Returns the number of nodes.
std::vector< GEDGraph >::size_type GraphID
Type of internally used graph IDs.
const GEDData< UserNodeLabel, UserEdgeLabel > & ged_data_
The data on which the method is run.
NodeID head(EdgeID edge) const
Returns the head of an edge.
virtual bool mip_model_to_lsape_projection_problem_(const GEDGraph &g, const GEDGraph &h, GRBModel &model, DMatrix &lsape_instance) final
Given a, possibly sub-optimally, solved model, this method constructs an LSAPE instance for projectin...
LabelID get_node_label(NodeID node) const
Returns the label of a given node.
static NodeID dummy_node()
Returns a dummy node.
Binary linear programming formulation of the graph edit distance without edge labels.
std::pair< incident_edge_iterator, incident_edge_iterator > incident_edges(NodeID node) const
Provides access to all incident edges of a node.
virtual void mip_populate_model_(const GEDGraph &g, const GEDGraph &h, GRBModel &model) final
Runs the local search from an initial node map.
The normalized input graphs used by GEDLIB. All labels are integers.
void add_assignment(GEDGraph::NodeID i, GEDGraph::NodeID k)
Add node substitution, insertion, or deletion to the node map.
constexpr LabelID dummy_label()
Returns a dummy label.
Global namespace for GEDLIB.
virtual void mip_model_to_node_map_(const GEDGraph &g, const GEDGraph &h, GRBModel &model, NodeMap &node_map) final
Given a, possibly sub-optimally, solved unrelaxed model, this method constructs a node map and sets i...
std::size_t NodeID
Internally used vertex ID type.
bool map_root_to_root_
If true, the model populated by mip_populate_model_() must enforce that the nodes with ID 0 are mappe...