50 #ifndef _ZOLTAN2_PROBLEM_HPP_
51 #define _ZOLTAN2_PROBLEM_HPP_
68 template<
typename Adapter>
72 #ifdef HAVE_ZOLTAN2_MPI
75 Problem(Adapter *, ParameterList *params, MPI_Comm comm);
80 Problem(Adapter *, ParameterList *params);
92 virtual void solve(
bool updateInputData) = 0;
107 #ifdef Z2_OMIT_ALL_ERROR_CHECKING
113 timer_->printAndResetToZero();
160 void setupProblemEnvironment(ParameterList *pl);
164 #ifdef HAVE_ZOLTAN2_MPI
166 template <
typename Adapter>
168 MPI_Comm comm) : inputAdapter_(input), baseInputAdapter_(),
169 graphModel_(), identifierModel_(), baseModel_(),
170 params_(), comm_(), env_(), envConst_(), timer_()
173 RCP<Teuchos::OpaqueWrapper<MPI_Comm> > wrapper =
174 Teuchos::opaqueWrapper(comm);
175 comm_ = rcp<const Comm<int> >(
new Teuchos::MpiComm<int>(wrapper));
176 setupProblemEnvironment(params);
180 template <
typename Adapter>
182 inputAdapter_(input),
184 graphModel_(), identifierModel_(), baseModel_(),
185 params_(), comm_(), env_(), envConst_(), timer_()
188 comm_ = DefaultComm<int>::getComm();
189 setupProblemEnvironment(params);
192 template <
typename Adapter>
195 baseInputAdapter_ =
dynamic_cast<base_adapter_t *
>(inputAdapter_);
198 env_ = rcp(
new Environment(*params, Teuchos::DefaultComm<int>::getComm()));
202 envConst_ = rcp_const_cast<
const Environment>(env_);
204 ParameterList &processedParameters = env_->getParametersNonConst();
205 params_ = rcp<ParameterList>(&processedParameters,
false);
207 #ifndef Z2_OMIT_ALL_PROFILING
208 ParameterList pl = *params_;
211 bool haveType=
false, haveStream=
false, haveFile=
false;
214 const Teuchos::ParameterEntry *pe = pl.getEntryPtr(
"timer_type");
217 choice = pe->getValue<
int>(&choice);
224 pe = pl.getEntryPtr(
"timer_output_file");
227 fname = pe->getValue<
string>(&fname);
228 std::ofstream *dbgFile =
new std::ofstream;
229 if (comm_->getRank()==0){
232 dbgFile->open(fname.c_str(), std::ios::out|std::ios::trunc);
234 catch(std::exception &e){
235 throw std::runtime_error(e.what());
238 timer_ = rcp(
new TimerManager(comm_, dbgFile, tt));
242 pe = pl.getEntryPtr(
"timer_output_stream");
244 choice = pe->getValue<
int>(&choice);
250 if (haveStream || haveType){
252 timer_ = rcp(
new TimerManager(comm_, &cout, tt));
254 timer_ = rcp(
new TimerManager(comm_, &cerr, tt));
256 std::ofstream *of = NULL;
257 timer_ = rcp(
new TimerManager(comm_, of, tt));
262 if (haveType || haveStream || haveFile)
263 env_->setTimer(timer_);
269 template <
typename Adapter>
272 env_ = rcp(
new Environment(*params, Teuchos::DefaultComm<int>::getComm()));
273 envConst_ = rcp_const_cast<
const Environment>(env_);
276 params_ = rcp<ParameterList>(&processedParameters,
false);
281 if (!timer_.is_null())
282 env_->setTimer(timer_);
RCP< GraphModel< base_adapter_t > > graphModel_
Time an algorithm (or other entity) as a whole.
virtual void solve(bool updateInputData)=0
Method that creates a solution.
Adapter::base_adapter_t base_adapter_t
#define Z2_FORWARD_EXCEPTIONS
Forward an exception back through call stack.
base_adapter_t * baseInputAdapter_
virtual ~Problem()
Destructor.
TimerType
The type of timers which should be active.
/dev/null: do actions but don't output results
RCP< const Comm< int > > comm_
void resetParameters(ParameterList *params)
Reset the list of parameters.
RCP< IdentifierModel< base_adapter_t > > identifierModel_
Problem(Adapter *, ParameterList *params)
Constructor where communicator is Teuchos default.
Teuchos::ParameterList & getParametersNonConst()
Returns a reference to a non-const copy of the parameters.
Defines the IdentifierModel interface.
OSType
Output stream types.
Problem base class from which other classes (PartitioningProblem, ColoringProblem, OrderingProblem, MatchingProblem, etc.) derive.
void printTimers() const
If timer data was collected, print out global data.
RCP< CoordinateModel< base_adapter_t > > coordinateModel_
The user parameters, debug, timing and memory profiling output objects, and error checking methods...
RCP< TimerManager > timer_
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.