50 #ifndef _ZOLTAN2_PROBLEM_HPP_ 51 #define _ZOLTAN2_PROBLEM_HPP_ 59 #include <Teuchos_StandardParameterEntryValidators.hpp> 60 #include <Teuchos_Tuple.hpp> 69 template<
typename Adapter>
75 Problem(
const Adapter *input, ParameterList *params):
82 RCP<const Comm<int> > tmp = DefaultComm<int>::getComm();
83 comm_ = tmp->duplicate();
84 setupProblemEnvironment(params);
90 Problem(
const Adapter *input, ParameterList *params,
91 const RCP<
const Comm<int> > &comm):
98 comm_ = comm->duplicate();
99 setupProblemEnvironment(params);
102 #ifdef HAVE_ZOLTAN2_MPI 105 Problem(
const Adapter *input, ParameterList *params, MPI_Comm comm):
112 RCP<Teuchos::OpaqueWrapper<MPI_Comm> > wrapper =
113 Teuchos::opaqueWrapper(comm);
114 RCP<const Comm<int> > tmp =
115 rcp<const Comm<int> >(
new Teuchos::MpiComm<int>(wrapper));
116 comm_ = tmp->duplicate();
117 setupProblemEnvironment(params);
135 virtual void solve(
bool updateInputData) = 0;
153 #ifdef Z2_OMIT_ALL_ERROR_CHECKING 159 timer_->printAndResetToZero();
167 pl.set(
"compute_metrics",
false,
"Compute metrics after computing solution",
170 RCP<Teuchos::StringValidator> hypergraph_model_type_Validator =
171 Teuchos::rcp(
new Teuchos::StringValidator(
172 Teuchos::tuple<std::string>(
"traditional",
"ghosting" )));
173 pl.set(
"hypergraph_model_type",
"traditional",
"construction type when " 174 "creating a hypergraph model", hypergraph_model_type_Validator);
177 pl.set(
"subset_graph",
false,
"If \"true\", the graph input is to be " 178 "subsetted. If a vertex neighbor is not a valid vertex, it will be " 179 "omitted from the pList. Otherwise, an invalid neighbor identifier " 182 RCP<Teuchos::StringValidator> symmetrize_input_Validator = Teuchos::rcp(
183 new Teuchos::StringValidator(
184 Teuchos::tuple<std::string>(
"no",
"transpose",
"bipartite" )));
185 pl.set(
"symmetrize_input",
"no",
"Symmetrize input prior to pList. " 186 "If \"transpose\", symmetrize A by computing A plus ATranspose. " 187 "If \"bipartite\", A becomes [[0 A][ATranspose 0]].",
188 symmetrize_input_Validator);
191 pl.sublist(
"zoltan_parameters");
192 pl.sublist(
"parma_parameters");
248 void setupProblemEnvironment(ParameterList *pl);
252 template <
typename Adapter>
256 env_ = rcp(
new Environment(*params, Teuchos::DefaultComm<int>::getComm()));
260 envConst_ = rcp_const_cast<
const Environment>(env_);
262 ParameterList &processedParameters = env_->getParametersNonConst();
263 params_ = rcp<ParameterList>(&processedParameters,
false);
265 #ifndef Z2_OMIT_ALL_PROFILING 266 ParameterList pl = *params_;
269 bool haveType=
false, haveStream=
false, haveFile=
false;
272 const Teuchos::ParameterEntry *pe = pl.getEntryPtr(
"timer_type");
275 choice = pe->getValue<
int>(&choice);
282 pe = pl.getEntryPtr(
"timer_output_file");
285 fname = pe->getValue<std::string>(&fname);
286 std::ofstream *dbgFile =
new std::ofstream;
287 if (comm_->getRank()==0){
290 dbgFile->open(fname.c_str(), std::ios::out|std::ios::trunc);
292 catch(std::exception &e){
293 throw std::runtime_error(e.what());
296 timer_ = rcp(
new TimerManager(comm_, dbgFile, tt));
300 pe = pl.getEntryPtr(
"timer_output_stream");
302 choice = pe->getValue<
int>(&choice);
308 if (haveStream || haveType){
310 timer_ = rcp(
new TimerManager(comm_, &std::cout, tt));
312 timer_ = rcp(
new TimerManager(comm_, &std::cerr, tt));
314 std::ofstream *of = NULL;
315 timer_ = rcp(
new TimerManager(comm_, of, tt));
320 if (haveType || haveStream || haveFile)
321 env_->setTimer(timer_);
327 template <
typename Adapter>
330 setupProblemEnvironment(params);
335 if (!timer_.is_null())
336 env_->setTimer(timer_);
RCP< GraphModel< base_adapter_t > > graphModel_
Zoltan2::BaseAdapter< userTypes_t > base_adapter_t
Time an algorithm (or other entity) as a whole.
RCP< const base_adapter_t > baseInputAdapter_
virtual void solve(bool updateInputData)=0
Method that creates a solution.
Problem(const Adapter *input, ParameterList *params)
Constructor where communicator is Teuchos default.
Adapter::base_adapter_t base_adapter_t
#define Z2_FORWARD_EXCEPTIONS
Forward an exception back through call stack.
static RCP< Teuchos::BoolParameterEntryValidator > getBoolValidator()
Exists to make setting up validators less cluttered.
virtual ~Problem()
Destructor.
TimerType
The type of timers which should be active.
RCP< Algorithm< Adapter > > algorithm_
/dev/null: do actions but don't output results
Problem(const Adapter *input, ParameterList *params, const RCP< const Comm< int > > &comm)
Constructor where Teuchos communicator is specified.
RCP< const Comm< int > > comm_
void resetParameters(ParameterList *params)
Reset the list of parameters.
const RCP< const Environment > & getEnvironment() const
Get the current Environment. Useful for testing.
RCP< IdentifierModel< base_adapter_t > > identifierModel_
Defines the IdentifierModel interface.
OSType
Output stream types.
static void getValidParameters(ParameterList &pl)
RCP< const Comm< int > > getComm()
Return the communicator used by the problem.
Problem base class from which other classes (PartitioningProblem, ColoringProblem, OrderingProblem, MatchingProblem, etc.) derive.
RCP< const Adapter > inputAdapter_
RCP< CoordinateModel< base_adapter_t > > coordinateModel_
The user parameters, debug, timing and memory profiling output objects, and error checking methods...
void printTimers() const
Return the communicator passed to the problem.
RCP< TimerManager > timer_
Define IntegerRangeList validator.
Defines the CoordinateModel classes.
Gathering definitions used in software development.
RCP< ParameterList > params_
Defines the GraphModel interface.
RCP< const Model< base_adapter_t > > baseModel_
RCP< const Environment > envConst_
Declarations for TimerManager.