50#ifndef _ZOLTAN2_ORDERINGPROBLEM_HPP_
51#define _ZOLTAN2_ORDERINGPROBLEM_HPP_
60#ifdef HAVE_ZOLTAN2_OVIS
70using Teuchos::rcp_dynamic_cast;
94template<
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);
165 RCP<Teuchos::StringValidator> rcm_root_selection_Validator = Teuchos::rcp(
166 new Teuchos::StringValidator(
167 Teuchos::tuple<std::string>(
"pseudoperipheral",
"first",
"smallest_degree" )));
168 pl.set(
"root_method",
"pseudoperipheral",
"method for selecting RCM root",
169 rcm_root_selection_Validator);
188 void solve(
bool updateInputData=
true);
195 if(localOrderingSolution_ == Teuchos::null) {
196 throw std::logic_error(
"OrderingProblem was not created with local"
197 " ordering. Set parameter order_method_type to local or both."
198 " Or use getGlobalOrderingSolution()." );
200 return setupSolution(localOrderingSolution_);
208 if(globalOrderingSolution_ == Teuchos::null) {
209 throw std::logic_error(
"OrderingProblem was not created with global"
210 " ordering. Set parameter order_method_type to global or both."
211 " Or use getLocalOrderingSolution()." );
213 return setupSolution(globalOrderingSolution_);
217 template<
typename ordering_solution_t>
218 ordering_solution_t *setupSolution(RCP<ordering_solution_t> solution) {
222 if (!(solution->havePerm()))
223 solution->computePerm();
224 if (!(solution->haveInverse()))
225 solution->computeInverse();
226 return solution.getRawPtr();
229 void createOrderingProblem();
232 RCP<LocalOrderingSolution<lno_t> > localOrderingSolution_;
233 RCP<GlobalOrderingSolution<gno_t> > globalOrderingSolution_;
238template <
typename Adapter>
243 size_t nVtx = this->baseModel_->getLocalNumObjects();
248 std::string method_type = this->params_->template
249 get<std::string>(
"order_method_type",
"local");
251 if(method_type ==
"local" || method_type ==
"both") {
254 if(method_type ==
"global" || method_type ==
"both") {
264 std::string method = this->params_->template
265 get<std::string>(
"order_method",
"rcm");
274 #define ZOLTAN2_COMPUTE_ORDERING \
275 if(localOrderingSolution_ != Teuchos::null) { \
276 alg.localOrder(localOrderingSolution_); \
278 if(globalOrderingSolution_ != Teuchos::null) { \
279 alg.globalOrder(globalOrderingSolution_); \
282 if (method.compare(
"rcm") == 0) {
286 else if (method.compare(
"natural") == 0) {
291 else if (method.compare(
"random") == 0) {
296 else if (method.compare(
"sorted_degree") == 0) {
301 else if (method.compare(
"minimum_degree") == 0) {
302 std::string pkg = this->params_->template get<std::string>(
303 "order_package",
"amd");
304 if (pkg.compare(
"amd") == 0)
307 this->params_, this->comm_);
311 else if (method.compare(
"scotch") == 0) {
313 this->baseInputAdapter_);
317#ifdef INCLUDE_ZOLTAN2_EXPERIMENTAL
318 else if (method.compare(
"nd") == 0) {
319 AlgND<Adapter> alg(this->envConst_, this->comm_, this->graphModel_,
320 this->coordinateModel_,this->baseInputAdapter_);
342template <
typename Adapter>
346 using Teuchos::ParameterList;
354 std::string method = this->params_->template
355 get<std::string>(
"order_method",
"rcm");
357 if ((method == std::string(
"rcm")) ||
358 (method == std::string(
"sorted_degree")) ||
359 (method == std::string(
"minimum_degree"))) {
363#ifdef INCLUDE_ZOLTAN2_EXPERIMENTAL
364 if ((method == std::string(
"nd")))
373 std::bitset<NUM_MODEL_FLAGS> graphFlags;
374 std::bitset<NUM_MODEL_FLAGS> idFlags;
385 this->graphModel_ = rcp(
new GraphModel<base_adapter_t>(
386 this->baseInputAdapter_, this->envConst_, this->comm_, graphFlags));
388 this->baseModel_ = rcp_implicit_cast<const Model<base_adapter_t> >(
395 this->identifierModel_ = rcp(
new IdentifierModel<base_adapter_t>(
396 this->baseInputAdapter_, this->envConst_, this->comm_, idFlags));
398 this->baseModel_ = rcp_implicit_cast<const Model<base_adapter_t> >(
399 this->identifierModel_);
406 <<
" Model type " << modelType <<
" not yet supported."
Defines the Zoltan2_EvaluateOrdering.hpp class.
#define Z2_FORWARD_EXCEPTIONS
Forward an exception back through call stack.
#define __func__zoltan2__
Defines the GraphModel interface.
#define ZOLTAN2_COMPUTE_ORDERING
Defines the OrderingSolution class.
Defines the Problem base class.
static void getValidParameters(ParameterList &pl)
Set up validators specific to this algorithm
OrderingProblem sets up ordering problems for the user.
Adapter::scalar_t scalar_t
virtual ~OrderingProblem()
Destructor.
Adapter::base_adapter_t base_adapter_t
void solve(bool updateInputData=true)
Direct the problem to create a solution.
LocalOrderingSolution< lno_t > * getLocalOrderingSolution()
Get the local ordering solution to the problem.
OrderingProblem(Adapter *A, ParameterList *p, const RCP< const Teuchos::Comm< int > > &comm)
static void getValidParameters(ParameterList &pl)
Set up validators specific to this Problem.
OrderingProblem(Adapter *A, ParameterList *p)
Constructor that uses a default communicator.
GlobalOrderingSolution< gno_t > * getGlobalOrderingSolution()
Get the global ordering solution to the problem.
Problem base class from which other classes (PartitioningProblem, ColoringProblem,...
Created by mbenlioglu on Aug 31, 2020.
ModelType
An identifier for the general type of model.
@ REMOVE_SELF_EDGES
algorithm requires no self edges
@ BUILD_LOCAL_GRAPH
model represents graph within only one rank