14#ifndef _ZOLTAN2_MATRIXPARTITIONINGPROBLEM_HPP_
15#define _ZOLTAN2_MATRIXPARTITIONINGPROBLEM_HPP_
68template<
typename Adapter>
74 typedef typename Adapter::gno_t
gno_t;
75 typedef typename Adapter::lno_t
lno_t;
76 typedef typename Adapter::part_t
part_t;
77 typedef typename Adapter::user_t
user_t;
85 const RCP<
const Teuchos::Comm<int> > &comm):
86 Problem<Adapter>(A,p,comm), solution_(),
96#ifdef HAVE_ZOLTAN2_MPI
97 typedef Teuchos::OpaqueWrapper<MPI_Comm> mpiWrapper_t;
102 rcp<const Comm<int> >(new
Teuchos::MpiComm<int>(
103 Teuchos::opaqueWrapper(mpicomm))))
146 void solve(
bool updateInputData=
true );
154 return *(solution_.getRawPtr());
172 Array<std::string> algorithm_names(1);
173 algorithm_names[0] =
"2D Cartesian";
174 RCP<Teuchos::StringValidator> algorithm_Validator = Teuchos::rcp(
175 new Teuchos::StringValidator( algorithm_names ));
176 pl.set(
"algorithm",
"2D Cartesian",
"partitioning algorithm",
177 algorithm_Validator);
193 pl.set(
"imbalance_tolerance", 1.1,
"imbalance tolerance, ratio of "
197 RCP<Teuchos::EnhancedNumberValidator<int>> num_global_parts_Validator =
198 Teuchos::rcp(
new Teuchos::EnhancedNumberValidator<int>(
199 1, Teuchos::EnhancedNumberTraits<int>::max()) );
200 pl.set(
"num_global_parts", 1,
"global number of parts to compute "
201 "(0 means use the number of processes)", num_global_parts_Validator);
204 RCP<Teuchos::EnhancedNumberValidator<int>> num_local_parts_Validator =
205 Teuchos::rcp(
new Teuchos::EnhancedNumberValidator<int>(
206 0, Teuchos::EnhancedNumberTraits<int>::max()) );
207 pl.set(
"num_local_parts", 0,
"number of parts to compute for this "
208 "process (num_global_parts == sum of all num_local_parts)",
209 num_local_parts_Validator);
233 void initializeProblem();
235 void createPartitioningProblem(
bool newData);
237 RCP<MatrixPartitioningSolution<Adapter> > solution_;
243 std::string algName_;
251template <
typename Adapter>
252 void MatrixPartitioningProblem<Adapter>::initializeProblem()
256 this->env_->debug(
DETAILED_STATUS,
"MatrixPartitioningProblem::initializeProblem");
258 inputType_ = this->inputAdapter_->adapterType();
263 std::cerr <<
"Error: only matrix adapter type supported" << std::endl;
267 this->env_->memory(
"After initializeProblem");
273template <
typename Adapter>
276 std::cout <<
"MatrixPartitioningProblem solve " << std::endl;
285 createPartitioningProblem(updateInputData);
309 this->baseInputAdapter_));
318 this->env_->timerStart(
MACRO_TIMERS,
"create solution");
323 this->envConst_, this->comm_,
328 solution_ = rcp(soln);
331 this->env_->memory(
"After creating Solution");
337 this->algorithm_->partitionMatrix(solution_);
347template <
typename Adapter>
351 "MatrixPartitioningProblem::createPartitioningProblem");
353 using Teuchos::ParameterList;
376 const Teuchos::ParameterEntry *pe;
377 std::string defString(
"default");
390 std::string algorithm(defString);
391 pe = pl.getEntryPtr(
"algorithm");
393 algorithm = pe->getValue<std::string>(&algorithm);
401 if (algorithm != defString)
405 if (algorithm == std::string(
"2D Cartesian"))
407 algName_ = algorithm;
412 throw std::logic_error(
"parameter list algorithm is invalid");
#define Z2_FORWARD_EXCEPTIONS
Forward an exception back through call stack.
Defines the Problem base class.
The user parameters, debug, timing and memory profiling output objects, and error checking methods.
static RCP< Teuchos::AnyNumberParameterEntryValidator > getAnyDoubleValidator()
Exists to make setting up validators less cluttered.
Teuchos::ParameterList & getParametersNonConst()
Returns a reference to a non-const copy of the parameters.
MatrixPartitioningProblem sets up partitioning problems for the user.
static void getValidParameters(ParameterList &pl)
Set up validators specific to this Problem.
MatrixPartitioningProblem(Adapter *A, ParameterList *p)
Constructor where communicator is the Teuchos default.
const PartitioningSolution< Adapter > & getSolution()
Get the solution to the problem.
Adapter::scalar_t scalar_t
void solve(bool updateInputData=true)
Direct the problem to create a solution.
MatrixPartitioningProblem(Adapter *A, ParameterList *p, const RCP< const Teuchos::Comm< int > > &comm)
Constructor where Teuchos communicator is specified.
~MatrixPartitioningProblem()
Destructor.
Adapter::base_adapter_t base_adapter_t
A PartitioningSolution is a solution to a partitioning problem.
A PartitioningSolution is a solution to a partitioning problem.
Problem base class from which other classes (PartitioningProblem, ColoringProblem,...
Created by mbenlioglu on Aug 31, 2020.
@ MACRO_TIMERS
Time an algorithm (or other entity) as a whole.
@ DETAILED_STATUS
sub-steps, each method's entry and exit
BaseAdapterType
An enum to identify general types of adapters.
@ InvalidAdapterType
unused value
@ MatrixAdapterType
matrix data