15 #ifndef _ZOLTAN2_MATCHINGPROBLEM_HPP_
16 #define _ZOLTAN2_MATCHINGPROBLEM_HPP_
21 #include <Zoltan2_MatchingAlgorithms.hpp>
29 using Teuchos::rcp_dynamic_cast;
54 template<
typename Adapter>
55 class MatchingProblem :
public Problem<Adapter>
59 typedef typename Adapter::scalar_t scalar_t;
65 #ifdef HAVE_ZOLTAN2_MPI
66 typedef Teuchos::OpaqueWrapper<MPI_Comm> mpiWrapper_t;
71 virtual ~MatchingProblem() {};
74 #ifdef HAVE_ZOLTAN2_MPI
77 MatchingProblem(Adapter *A, ParameterList *p, MPI_Comm comm)
78 : Problem<Adapter>(A, p, comm)
81 createMatchingProblem();
87 MatchingProblem(Adapter *A, ParameterList *p) : Problem<Adapter>(A, p)
90 createMatchingProblem();
109 void solve(
bool updateInputData=
true);
115 MatchingSolution<Adapter> *getSolution() {
117 return solution_.getRawPtr();
121 void createMatchingProblem();
123 RCP<MatchingSolution<Adapter> > solution_;
129 template <
typename Adapter>
130 void MatchingProblem<Adapter>::solve(
bool newData)
134 size_t nVtx = this->baseModel_->getLocalNumObjects();
138 this->solution_ = rcp(
new MatchingSolution<Adapter>(nVtx));
145 std::string method = this->params_->template get<std::string>(
"color_method",
"SerialGreedy");
150 if (method.compare(
"SerialGreedy") == 0)
152 AlgSerialGreedy<Adapter> alg(this->graphModel_, this->params_,
153 this->env_, this->comm_);
154 alg.color(this->solution_);
157 else if (method.compare(
"speculative") == 0)
159 AlgGM<base_adapter_t> alg(this->graphModel_, this->comm_);
160 alg.color(this->solution_, this->params_);
181 template <
typename Adapter>
182 void MatchingProblem<Adapter>::createMatchingProblem()
185 using Teuchos::ParameterList;
200 std::bitset<NUM_MODEL_FLAGS> graphFlags;
201 std::bitset<NUM_MODEL_FLAGS> idFlags;
208 this->graphModel_ = rcp(
new GraphModel<base_adapter_t>(
209 this->baseInputAdapter_, this->envConst_, this->comm_, graphFlags));
211 this->baseModel_ = rcp_implicit_cast<
const Model<base_adapter_t> >(
220 std::cout <<
__func__zoltan2__ <<
" Model type " << modelType <<
" not yet supported."
Zoltan2::BaseAdapter< userTypes_t > base_adapter_t
ModelType
An identifier for the general type of model.
#define Z2_FORWARD_EXCEPTIONS
Forward an exception back through call stack.
map_t::global_ordinal_type gno_t
algorithm requires no self edges
Defines the Problem base class.
map_t::local_ordinal_type lno_t
Gathering definitions used in software development.
Defines the GraphModel interface.
model represents graph within only one rank
#define __func__zoltan2__
Zoltan2::BasicUserTypes< zscalar_t, zlno_t, zgno_t > user_t