GEDLIB  1.0
mip_based_method.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * *
3  * Copyright (C) 2018 by David B. Blumenthal *
4  * *
5  * This file is part of GEDLIB. *
6  * *
7  * GEDLIB is free software: you can redistribute it and/or modify it *
8  * under the terms of the GNU Lesser General Public License as published *
9  * by the Free Software Foundation, either version 3 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * GEDLIB is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU Lesser General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU Lesser General Public *
18  * License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>. *
19  * *
20  ***************************************************************************/
21 
22 
28 #ifndef SRC_METHODS_MIP_BASED_METHOD_HPP_
29 #define SRC_METHODS_MIP_BASED_METHOD_HPP_
30 
31 namespace ged {
32 
47 template<class UserNodeLabel, class UserEdgeLabel>
48 class MIPBasedMethod : public GEDMethod<UserNodeLabel, UserEdgeLabel> {
49 
50 public:
51 
56  virtual ~MIPBasedMethod() = 0;
57 
63 
64 protected:
65 
69  bool relax_;
70 
75 
76 private:
77 
78  std::size_t num_threads_;
79 
80  double time_limit_in_sec_;
81 
82  bool tune_;
83 
84  double tune_time_limit_in_sec_;
85 
86  LSAPESolver::Model lsape_model_;
87 
88  bool project_to_node_map_;
89 
90  // Member functions inherited from GEDMethod.
91 
92  virtual void ged_init_() final;
93 
94  virtual void ged_run_(const GEDGraph & g, const GEDGraph & h, Result & result) final;
95 
96  virtual bool ged_parse_option_(const std::string & option, const std::string & arg) final;
97 
98  virtual std::string ged_valid_options_string_() const final;
99 
100  virtual void ged_set_default_options_() final;
101 
102  // Virtual member functions to be overridden by derived classes.
103 
111  virtual void mip_populate_model_(const GEDGraph & g, const GEDGraph & h, GRBModel & model);
112 
121  virtual void mip_model_to_node_map_(const GEDGraph & g, const GEDGraph & h, GRBModel & model, NodeMap & node_map);
122 
134  virtual bool mip_model_to_lsape_projection_problem_(const GEDGraph & g, const GEDGraph & h, GRBModel & model, DMatrix & lsape_instance);
135 
140  virtual void mip_init_();
141 
149  virtual bool mip_parse_option_(const std::string & option, const std::string & arg);
150 
156  virtual std::string mip_valid_options_string_() const;
157 
162  virtual void mip_set_default_options_();
163 
164 };
165 
166 }
167 
168 #endif /* SRC_METHODS_MIP_BASED_METHOD_HPP_ */
virtual void mip_init_()
Initializes the method.
virtual void ged_init_() final
Initializes the method.
virtual bool mip_parse_option_(const std::string &option, const std::string &arg)
Parses one option that is not among the ones shared by all derived classes of ged::MIPBasedMethod.
virtual void mip_set_default_options_()
Sets all options that are not among the ones shared by all derived classes of ged::MIPBasedMethod to ...
bool relax_
If true, the model populated by mip_populate_model_() must be continuous.
virtual std::string mip_valid_options_string_() const
Returns string of all valid options that are not among the ones shared by all derived classes of ged:...
Contains the standardized input data along with basic functionality.
Definition: ged_data.hpp:55
A class for node maps.
Definition: node_map.hpp:43
virtual void mip_populate_model_(const GEDGraph &g, const GEDGraph &h, GRBModel &model)
Runs the local search from an initial node map.
virtual std::string ged_valid_options_string_() const final
Returns string of all valid options.
MIPBasedMethod(const GEDData< UserNodeLabel, UserEdgeLabel > &ged_data)
Constructor.
A wrapper structure for the result of calls to ged::GEDMethod::run_as_util() and ged::GEDMethod::ged_...
Definition: result.hpp:38
virtual void ged_set_default_options_() final
Sets all options to default values.
Abstract class for the (suboptimal) computation of the graph edit distance.
Definition: ged_method.hpp:40
virtual ~MIPBasedMethod()=0
Pure virtual destructor.
virtual void ged_run_(const GEDGraph &g, const GEDGraph &h, Result &result) final
Runs the method with options specified by set_options().
The normalized input graphs used by GEDLIB. All labels are integers.
Definition: ged_graph.hpp:104
Global namespace for GEDLIB.
virtual void mip_model_to_node_map_(const GEDGraph &g, const GEDGraph &h, GRBModel &model, NodeMap &node_map)
Given a, possibly sub-optimally, solved unrelaxed model, this method constructs a node map and sets i...
virtual bool mip_model_to_lsape_projection_problem_(const GEDGraph &g, const GEDGraph &h, GRBModel &model, DMatrix &lsape_instance)
Given a, possibly sub-optimally, solved model, this method constructs an LSAPE instance for projectin...
virtual bool ged_parse_option_(const std::string &option, const std::string &arg) final
Parses one option.
Model
Selects a model for solving LSAPE with the Hungarian algorithm.
Abstract class for methods that use mixed integer linear programming for exactly or approximatively c...
bool map_root_to_root_
If true, the model populated by mip_populate_model_() must enforce that the nodes with ID 0 are mappe...