50 #ifndef _ZOLTAN2_ORDERINGPROBLEM_HPP_
51 #define _ZOLTAN2_ORDERINGPROBLEM_HPP_
60 #ifdef HAVE_ZOLTAN2_OVIS
70 using Teuchos::rcp_dynamic_cast;
94 template<
typename Adapter>
100 typedef typename Adapter::gno_t
gno_t;
101 typedef typename Adapter::lno_t
lno_t;
105 #ifdef HAVE_ZOLTAN2_MPI
106 typedef Teuchos::OpaqueWrapper<MPI_Comm> mpiWrapper_t;
114 const RCP<
const Teuchos::Comm<int> > &comm) :
118 createOrderingProblem();
121 #ifdef HAVE_ZOLTAN2_MPI
126 rcp<const Comm<int> >(new Teuchos::MpiComm<int>(
127 Teuchos::opaqueWrapper(mpicomm))))
142 #ifdef INCLUDE_ZOLTAN2_EXPERIMENTAL
146 RCP<Teuchos::StringValidator> order_method_Validator =
147 Teuchos::rcp(
new Teuchos::StringValidator(
148 Teuchos::tuple<std::string>(
"rcm",
"minimum_degree",
"natural",
149 "random",
"sorted_degree",
"scotch",
"nd" )));
150 pl.set(
"order_method",
"rcm",
"order algorithm",
151 order_method_Validator);
153 RCP<Teuchos::StringValidator> order_method_type_Validator =
154 Teuchos::rcp(
new Teuchos::StringValidator(
155 Teuchos::tuple<std::string>(
"local",
"global",
"both" )));
156 pl.set(
"order_method_type",
"local",
"local or global or both",
157 order_method_type_Validator);
159 RCP<Teuchos::StringValidator> order_package_Validator = Teuchos::rcp(
160 new Teuchos::StringValidator(
161 Teuchos::tuple<std::string>(
"amd",
"package2",
"package3" )));
162 pl.set(
"order_package",
"amd",
"package to use in ordering",
163 order_package_Validator);
182 void solve(
bool updateInputData=
true);
189 if(localOrderingSolution_ == Teuchos::null) {
190 throw std::logic_error(
"OrderingProblem was not created with local"
191 " ordering. Set parameter order_method_type to local or both."
192 " Or use getGlobalOrderingSolution()." );
194 return setupSolution(localOrderingSolution_);
202 if(globalOrderingSolution_ == Teuchos::null) {
203 throw std::logic_error(
"OrderingProblem was not created with global"
204 " ordering. Set parameter order_method_type to global or both."
205 " Or use getLocalOrderingSolution()." );
207 return setupSolution(globalOrderingSolution_);
211 template<
typename ordering_solution_t>
212 ordering_solution_t *setupSolution(RCP<ordering_solution_t> solution) {
216 if (!(solution->havePerm()))
217 solution->computePerm();
218 if (!(solution->haveInverse()))
219 solution->computeInverse();
220 return solution.getRawPtr();
223 void createOrderingProblem();
226 RCP<LocalOrderingSolution<lno_t> > localOrderingSolution_;
227 RCP<GlobalOrderingSolution<gno_t> > globalOrderingSolution_;
232 template <
typename Adapter>
237 size_t nVtx = this->baseModel_->getLocalNumObjects();
242 std::string method_type = this->params_->template
243 get<std::string>(
"order_method_type",
"local");
245 if(method_type ==
"local" || method_type ==
"both") {
248 if(method_type ==
"global" || method_type ==
"both") {
258 std::string method = this->params_->template
259 get<std::string>(
"order_method",
"rcm");
268 #define ZOLTAN2_COMPUTE_ORDERING \
269 if(localOrderingSolution_ != Teuchos::null) { \
270 alg.localOrder(localOrderingSolution_); \
272 if(globalOrderingSolution_ != Teuchos::null) { \
273 alg.globalOrder(globalOrderingSolution_); \
276 if (method.compare(
"rcm") == 0) {
280 else if (method.compare(
"natural") == 0) {
285 else if (method.compare(
"random") == 0) {
290 else if (method.compare(
"sorted_degree") == 0) {
295 else if (method.compare(
"minimum_degree") == 0) {
296 std::string pkg = this->params_->template get<std::string>(
297 "order_package",
"amd");
298 if (pkg.compare(
"amd") == 0)
301 this->params_, this->comm_);
305 else if (method.compare(
"scotch") == 0) {
307 this->baseInputAdapter_);
311 #ifdef INCLUDE_ZOLTAN2_EXPERIMENTAL
312 else if (method.compare(
"nd") == 0) {
313 AlgND<Adapter> alg(this->envConst_, this->comm_, this->graphModel_,
314 this->coordinateModel_,this->baseInputAdapter_);
336 template <
typename Adapter>
340 using Teuchos::ParameterList;
348 std::string method = this->params_->template
349 get<std::string>(
"order_method",
"rcm");
351 if ((method == std::string(
"rcm")) ||
352 (method == std::string(
"sorted_degree")) ||
353 (method == std::string(
"minimum_degree"))) {
357 #ifdef INCLUDE_ZOLTAN2_EXPERIMENTAL
358 if ((method == std::string(
"nd")))
367 std::bitset<NUM_MODEL_FLAGS> graphFlags;
368 std::bitset<NUM_MODEL_FLAGS> idFlags;
379 this->graphModel_ = rcp(
new GraphModel<base_adapter_t>(
380 this->baseInputAdapter_, this->envConst_, this->comm_, graphFlags));
382 this->baseModel_ = rcp_implicit_cast<
const Model<base_adapter_t> >(
389 this->identifierModel_ = rcp(
new IdentifierModel<base_adapter_t>(
390 this->baseInputAdapter_, this->envConst_, this->comm_, idFlags));
392 this->baseModel_ = rcp_implicit_cast<
const Model<base_adapter_t> >(
393 this->identifierModel_);
400 <<
" Model type " << modelType <<
" not yet supported."
Zoltan2::BaseAdapter< userTypes_t > base_adapter_t
ModelType
An identifier for the general type of model.
virtual ~OrderingProblem()
Destructor.
#define Z2_FORWARD_EXCEPTIONS
Forward an exception back through call stack.
Defines the OrderingSolution class.
static void getValidParameters(ParameterList &pl)
Set up validators specific to this algorithm.
OrderingProblem sets up ordering problems for the user.
algorithm requires no self edges
#define ZOLTAN2_COMPUTE_ORDERING
OrderingProblem(Adapter *A, ParameterList *p, const RCP< const Teuchos::Comm< int > > &comm)
OrderingProblem(Adapter *A, ParameterList *p)
Constructor that uses a default communicator.
Problem base class from which other classes (PartitioningProblem, ColoringProblem, OrderingProblem, MatchingProblem, etc.) derive.
void solve(bool updateInputData=true)
Direct the problem to create a solution.
Adapter::scalar_t scalar_t
Defines the Problem base class.
Adapter::base_adapter_t base_adapter_t
Defines the Zoltan2_EvaluateOrdering.hpp class.
GlobalOrderingSolution< gno_t > * getGlobalOrderingSolution()
Get the global ordering solution to the problem.
Defines the GraphModel interface.
static void getValidParameters(ParameterList &pl)
Set up validators specific to this Problem.
model represents graph within only one rank
#define __func__zoltan2__
LocalOrderingSolution< lno_t > * getLocalOrderingSolution()
Get the local ordering solution to the problem.
Zoltan2::BasicUserTypes< zscalar_t, zlno_t, zgno_t > user_t