51 #ifndef _ZOLTAN2_MATCHINGPROBLEM_HPP_ 52 #define _ZOLTAN2_MATCHINGPROBLEM_HPP_ 57 #include <Zoltan2_MatchingAlgorithms.hpp> 65 using Teuchos::rcp_dynamic_cast;
90 template<
typename Adapter>
91 class MatchingProblem :
public Problem<Adapter>
95 typedef typename Adapter::scalar_t scalar_t;
96 typedef typename Adapter::gno_t gno_t;
97 typedef typename Adapter::lno_t lno_t;
98 typedef typename Adapter::user_t user_t;
99 typedef typename Adapter::base_adapter_t base_adapter_t;
101 #ifdef HAVE_ZOLTAN2_MPI 102 typedef Teuchos::OpaqueWrapper<MPI_Comm> mpiWrapper_t;
107 virtual ~MatchingProblem() {};
110 #ifdef HAVE_ZOLTAN2_MPI 113 MatchingProblem(Adapter *A, ParameterList *p, MPI_Comm comm)
114 : Problem<Adapter>(A, p, comm)
117 createMatchingProblem();
123 MatchingProblem(Adapter *A, ParameterList *p) : Problem<Adapter>(A, p)
126 createMatchingProblem();
145 void solve(
bool updateInputData=
true);
151 MatchingSolution<Adapter> *getSolution() {
153 return solution_.getRawPtr();
157 void createMatchingProblem();
159 RCP<MatchingSolution<Adapter> > solution_;
161 RCP<Comm<int> > problemComm_;
162 RCP<const Comm<int> > problemCommConst_;
164 #ifdef HAVE_ZOLTAN2_MPI 171 template <
typename Adapter>
172 void MatchingProblem<Adapter>::solve(
bool newData)
176 size_t nVtx = this->baseModel_->getLocalNumObjects();
180 this->solution_ = rcp(
new MatchingSolution<Adapter>(nVtx));
187 std::string method = this->params_->template get<std::string>(
"color_method",
"SerialGreedy");
192 if (method.compare(
"SerialGreedy") == 0)
194 AlgSerialGreedy<Adapter> alg(this->graphModel_, this->params_,
195 this->env_, problemComm_);
196 alg.color(this->solution_);
199 else if (method.compare(
"speculative") == 0)
201 AlgGM<base_adapter_t> alg(this->graphModel_, problemComm_);
202 alg.color(this->solution_, this->params_);
223 template <
typename Adapter>
224 void MatchingProblem<Adapter>::createMatchingProblem()
227 using Teuchos::ParameterList;
235 problemComm_ = this->comm_->duplicate();
236 problemCommConst_ = rcp_const_cast<
const Comm<int> > (problemComm_);
239 #ifdef HAVE_ZOLTAN2_MPI 243 Comm<int> *c = problemComm_.getRawPtr();
244 Teuchos::MpiComm<int> *mc =
dynamic_cast<Teuchos::MpiComm<int> *
>(c);
246 RCP<const mpiWrapper_t> wrappedComm = mc->getRawMpiComm();
247 mpiComm_ = (*wrappedComm.getRawPtr())();
250 mpiComm_ = MPI_COMM_SELF;
262 std::bitset<NUM_MODEL_FLAGS> graphFlags;
263 std::bitset<NUM_MODEL_FLAGS> idFlags;
270 this->graphModel_ = rcp(
new GraphModel<base_adapter_t>(
271 this->baseInputAdapter_, this->envConst_, problemCommConst_, graphFlags));
273 this->baseModel_ = rcp_implicit_cast<
const Model<base_adapter_t> >(
282 cout <<
__func__zoltan2__ <<
" Model type " << modelType <<
" not yet supported."
ModelType
An identifier for the general type of model.
#define Z2_FORWARD_EXCEPTIONS
Forward an exception back through call stack.
algorithm requires no self edges
Defines the Problem base class.
Gathering definitions used in software development.
Defines the GraphModel interface.
model represents graph within only one rank
#define __func__zoltan2__