27 #ifndef SRC_METHODS_F1_IPP_ 28 #define SRC_METHODS_F1_IPP_ 33 template<
class UserNodeLabel,
class UserEdgeLabel>
34 F1<UserNodeLabel, UserEdgeLabel>::
37 template<
class UserNodeLabel,
class UserEdgeLabel>
38 F1<UserNodeLabel, UserEdgeLabel>::
39 F1(
const GEDData<UserNodeLabel, UserEdgeLabel> & ged_data) :
40 MIPBasedMethod<UserNodeLabel, UserEdgeLabel>(ged_data),
48 template<
class UserNodeLabel,
class UserEdgeLabel>
62 for (
auto i = g.
nodes().first; i != g.
nodes().second; i++) {
67 for (
auto k = h.
nodes().first; k != h.
nodes().second; k++) {
72 std::pair<GEDGraph::NodeID, GEDGraph::NodeID> key_x;
73 for (
auto i = g.
nodes().first; i != g.
nodes().second; i++) {
75 for (
auto k = h.
nodes().first; k != h.
nodes().second; k++) {
87 for (
auto e = g.
edges().first; e != g.
edges().second; e++) {
92 for (
auto f = h.
edges().first; f != h.
edges().second; f++) {
97 std::pair<GEDGraph::EdgeID, GEDGraph::EdgeID> key_y;
98 for (
auto e = g.
edges().first; e != g.
edges().second; e++) {
100 for (
auto f = h.
edges().first; f != h.
edges().second; f++) {
108 for (
auto i = g.
nodes().first; i != g.
nodes().second; i++) {
111 for (
auto k = h.
nodes().first; k != h.
nodes().second; k++) {
115 model.addConstr(lhs, GRB_EQUAL, 1);
117 for (
auto k = h.
nodes().first; k != h.
nodes().second; k++) {
120 for (
auto i = g.
nodes().first; i != g.
nodes().second; i++) {
124 model.addConstr(lhs, GRB_EQUAL, 1);
128 for (
auto e = g.
edges().first; e != g.
edges().second; e++) {
131 for (
auto f = h.
edges().first; f != h.
edges().second; f++) {
135 model.addConstr(lhs, GRB_EQUAL, 1);
137 for (
auto f = h.
edges().first; f != h.
edges().second; f++) {
140 for (
auto e = g.
edges().first; e != g.
edges().second; e++) {
144 model.addConstr(lhs, GRB_EQUAL, 1);
148 for (
auto e = g.
edges().first; e != g.
edges().second; e++) {
152 for (
auto f = h.
edges().first; f != h.
edges().second; f++) {
161 model.addConstr(lhs, GRB_GREATER_EQUAL, y_.at(key_y));
166 model.addConstr(lhs, GRB_GREATER_EQUAL, y_.at(key_y));
172 template<
class UserNodeLabel,
class UserEdgeLabel>
179 for (
auto it = x_.begin(); it != x_.end(); it++) {
180 if (it->second.get(GRB_DoubleAttr_X) > 0) {
182 k = it->first.second;
189 if (u_.at(i).get(GRB_DoubleAttr_X) > 0) {
196 if (v_.at(k).get(GRB_DoubleAttr_X) > 0) {
206 template<
class UserNodeLabel,
class UserEdgeLabel>
211 for (
auto it = x_.begin(); it != x_.end(); it++) {
213 k = it->first.second;
214 lsape_instance(i, k) -= it->second.get(GRB_DoubleAttr_X);
217 lsape_instance(i, h.
num_nodes()) -= u_.at(i).get(GRB_DoubleAttr_X);
220 lsape_instance(g.
num_nodes(), k) -= v_.at(k).get(GRB_DoubleAttr_X);
225 template<
class UserNodeLabel,
class UserEdgeLabel>
230 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.
Mixed integer linear programming formulation of the graph edit distance.
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 void mip_populate_model_(const GEDGraph &g, const GEDGraph &h, GRBModel &model) final
Runs the local search from an initial node map.
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...
NodeID tail(EdgeID edge) const
Returns the tail of an edge.
LabelID get_node_label(NodeID node) const
Returns the label of a given node.
static NodeID dummy_node()
Returns a dummy node.
LabelID get_edge_label(EdgeID edge) const
Returns the label of a given edge.
std::pair< node_iterator, node_iterator > nodes() const
Provides access to all nodes in the graph.
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.
void set_induced_cost(double induced_cost)
Sets the induced cost of the node map.
constexpr LabelID dummy_label()
Returns a dummy label.
Global namespace for GEDLIB.
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...
std::size_t NodeID
Internally used vertex ID type.
std::pair< edge_iterator, edge_iterator > edges() const
Provides access to all edge in the graph.
bool map_root_to_root_
If true, the model populated by mip_populate_model_() must enforce that the nodes with ID 0 are mappe...