50#ifndef _ZOLTAN2_PROBLEM_HPP_
51#define _ZOLTAN2_PROBLEM_HPP_
59#include <Teuchos_StandardParameterEntryValidators.hpp>
60#include <Teuchos_Tuple.hpp>
75 virtual RCP<const Comm<int> >
getComm() = 0;
79 virtual void solve(
bool updateInputData =
true) = 0;
86template<
typename Adapter>
92 Problem(
const Adapter *input, ParameterList *params,
93 const RCP<
const Comm<int> > &comm):
106 comm_ = comm->duplicate();
107 setupProblemEnvironment(params);
138#ifdef Z2_OMIT_ALL_ERROR_CHECKING
144 timer_->printAndResetToZero();
152 pl.set(
"compute_metrics",
false,
"Compute metrics after computing solution",
155 RCP<Teuchos::StringValidator> hypergraph_model_type_Validator =
156 Teuchos::rcp(
new Teuchos::StringValidator(
157 Teuchos::tuple<std::string>(
"traditional",
"ghosting" )));
158 pl.set(
"hypergraph_model_type",
"traditional",
"construction type when "
159 "creating a hypergraph model", hypergraph_model_type_Validator);
162 pl.set(
"subset_graph",
false,
"If \"true\", the graph input is to be "
163 "subsetted. If a vertex neighbor is not a valid vertex, it will be "
164 "omitted from the pList. Otherwise, an invalid neighbor identifier "
167 RCP<Teuchos::StringValidator> symmetrize_input_Validator = Teuchos::rcp(
168 new Teuchos::StringValidator(
169 Teuchos::tuple<std::string>(
"no",
"transpose",
"bipartite" )));
170 pl.set(
"symmetrize_input",
"no",
"Symmetrize input prior to pList. "
171 "If \"transpose\", symmetrize A by computing A plus ATranspose. "
172 "If \"bipartite\", A becomes [[0 A][ATranspose 0]].",
173 symmetrize_input_Validator);
176 pl.sublist(
"zoltan_parameters");
177 pl.sublist(
"parma_parameters");
178 pl.sublist(
"sarma_parameters");
234 void setupProblemEnvironment(ParameterList *pl);
238template <
typename Adapter>
241 ParameterList &processedParameters = env_->getParametersNonConst();
242 params_ = rcp<ParameterList>(&processedParameters,
false);
244#ifndef Z2_OMIT_ALL_PROFILING
245 ParameterList pl = *params_;
248 bool haveType=
false, haveStream=
false, haveFile=
false;
251 const Teuchos::ParameterEntry *pe = pl.getEntryPtr(
"timer_type");
254 choice = pe->getValue<
int>(&choice);
261 pe = pl.getEntryPtr(
"timer_output_file");
265 std::ofstream *dbgFile =
new std::ofstream;
266 if (comm_->getRank()==0){
269 dbgFile->open(
fname.c_str(), std::ios::out|std::ios::trunc);
271 catch(std::exception &e){
272 throw std::runtime_error(e.what());
275 timer_ = rcp(
new TimerManager(comm_, dbgFile, tt));
279 pe = pl.getEntryPtr(
"timer_output_stream");
281 choice = pe->getValue<
int>(&choice);
287 if (haveStream || haveType){
289 timer_ = rcp(
new TimerManager(comm_, &std::cout, tt));
291 timer_ = rcp(
new TimerManager(comm_, &std::cerr, tt));
293 std::ofstream *of = NULL;
294 timer_ = rcp(
new TimerManager(comm_, of, tt));
299 if (haveType || haveStream || haveFile)
300 env_->setTimer(timer_);
306template <
typename Adapter>
309 env_->resetParameters(*params);
310 setupProblemEnvironment(params);
315 if (!timer_.is_null())
316 env_->setTimer(timer_);
Defines the CoordinateModel classes.
Defines the GraphModel interface.
Defines the IdentifierModel interface.
Define IntegerRangeList validator.
Gathering definitions used in software development.
Declarations for TimerManager.
The user parameters, debug, timing and memory profiling output objects, and error checking methods.
static RCP< Teuchos::BoolParameterEntryValidator > getBoolValidator()
Exists to make setting up validators less cluttered.
ProblemRoot allows ptr storage and safe dynamic_cast of all.
virtual RCP< const Comm< int > > getComm()=0
virtual void solve(bool updateInputData=true)=0
Method that creates a solution.
Problem base class from which other classes (PartitioningProblem, ColoringProblem,...
RCP< const Comm< int > > getComm()
Return the communicator used by the problem.
RCP< const Environment > envConst_
RCP< IdentifierModel< base_adapter_t > > identifierModel_
void resetParameters(ParameterList *params)
Reset the list of parameters.
const RCP< const Environment > & getEnvironment() const
Get the current Environment. Useful for testing.
RCP< const Adapter > inputAdapter_
Adapter::base_adapter_t base_adapter_t
virtual ~Problem()
Destructor.
RCP< TimerManager > timer_
RCP< const base_adapter_t > baseInputAdapter_
Problem(const Adapter *input, ParameterList *params, const RCP< const Comm< int > > &comm)
Constructor where Teuchos communicator is specified.
RCP< const Model< base_adapter_t > > baseModel_
void printTimers() const
Return the communicator passed to the problem.
RCP< ParameterList > params_
static void getValidParameters(ParameterList &pl)
RCP< GraphModel< base_adapter_t > > graphModel_
RCP< const Comm< int > > comm_
RCP< CoordinateModel< base_adapter_t > > coordinateModel_
RCP< Algorithm< Adapter > > algorithm_
Zoltan2::BaseAdapter< userTypes_t > base_adapter_t
Created by mbenlioglu on Aug 31, 2020.
TimerType
The type of timers which should be active.
@ MACRO_TIMERS
Time an algorithm (or other entity) as a whole.
OSType
Output stream types.
@ NULL_STREAM
/dev/null: do actions but don't output results