50 #ifndef _ZOLTAN2_PROBLEM_HPP_
51 #define _ZOLTAN2_PROBLEM_HPP_
56 #include <Teuchos_StandardParameterEntryValidators.hpp>
57 #include <Teuchos_Tuple.hpp>
72 virtual RCP<const Comm<int> >
getComm() = 0;
76 virtual void solve(
bool updateInputData =
true) = 0;
83 template<
typename Adapter>
89 Problem(
const Adapter *input, ParameterList *params,
90 const RCP<
const Comm<int> > &comm):
100 comm_ = comm->duplicate();
101 setupProblemEnvironment(params);
132 #ifdef Z2_OMIT_ALL_ERROR_CHECKING
138 timer_->printAndResetToZero();
146 pl.set(
"compute_metrics",
false,
"Compute metrics after computing solution",
149 RCP<Teuchos::StringValidator> hypergraph_model_type_Validator =
150 Teuchos::rcp(
new Teuchos::StringValidator(
151 Teuchos::tuple<std::string>(
"traditional",
"ghosting" )));
152 pl.set(
"hypergraph_model_type",
"traditional",
"construction type when "
153 "creating a hypergraph model", hypergraph_model_type_Validator);
156 pl.set(
"subset_graph",
false,
"If \"true\", the graph input is to be "
157 "subsetted. If a vertex neighbor is not a valid vertex, it will be "
158 "omitted from the pList. Otherwise, an invalid neighbor identifier "
161 RCP<Teuchos::StringValidator> symmetrize_input_Validator = Teuchos::rcp(
162 new Teuchos::StringValidator(
163 Teuchos::tuple<std::string>(
"no",
"transpose",
"bipartite" )));
164 pl.set(
"symmetrize_input",
"no",
"Symmetrize input prior to pList. "
165 "If \"transpose\", symmetrize A by computing A plus ATranspose. "
166 "If \"bipartite\", A becomes [[0 A][ATranspose 0]].",
167 symmetrize_input_Validator);
170 pl.sublist(
"zoltan_parameters");
171 pl.sublist(
"parma_parameters");
172 pl.sublist(
"sarma_parameters");
218 void setupProblemEnvironment(ParameterList *pl);
222 template <
typename Adapter>
225 ParameterList &processedParameters = env_->getParametersNonConst();
226 params_ = rcp<ParameterList>(&processedParameters,
false);
228 #ifndef Z2_OMIT_ALL_PROFILING
229 ParameterList pl = *params_;
232 bool haveType=
false, haveStream=
false, haveFile=
false;
235 const Teuchos::ParameterEntry *pe = pl.getEntryPtr(
"timer_type");
238 choice = pe->getValue<
int>(&choice);
245 pe = pl.getEntryPtr(
"timer_output_file");
248 fname = pe->getValue<std::string>(&
fname);
249 std::ofstream *dbgFile =
new std::ofstream;
250 if (comm_->getRank()==0){
253 dbgFile->open(fname.c_str(), std::ios::out|std::ios::trunc);
255 catch(std::exception &e){
256 throw std::runtime_error(e.what());
259 timer_ = rcp(
new TimerManager(comm_, dbgFile, tt));
263 pe = pl.getEntryPtr(
"timer_output_stream");
265 choice = pe->getValue<
int>(&choice);
271 if (haveStream || haveType){
273 timer_ = rcp(
new TimerManager(comm_, &std::cout, tt));
275 timer_ = rcp(
new TimerManager(comm_, &std::cerr, tt));
277 std::ofstream *of = NULL;
278 timer_ = rcp(
new TimerManager(comm_, of, tt));
283 if (haveType || haveStream || haveFile)
284 env_->setTimer(timer_);
290 template <
typename Adapter>
293 env_->resetParameters(*params);
294 setupProblemEnvironment(params);
299 if (!timer_.is_null())
300 env_->setTimer(timer_);
Zoltan2::BaseAdapter< userTypes_t > base_adapter_t
Time an algorithm (or other entity) as a whole.
RCP< const base_adapter_t > baseInputAdapter_
Adapter::base_adapter_t base_adapter_t
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.
ProblemRoot allows ptr storage and safe dynamic_cast of all.
RCP< const Comm< int > > comm_
void resetParameters(ParameterList *params)
Reset the list of parameters.
virtual RCP< const Comm< int > > getComm()=0
virtual void solve(bool updateInputData=true)=0
Method that creates a solution.
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_
void printTimers() const
Return the communicator passed to the problem.
The user parameters, debug, timing and memory profiling output objects, and error checking methods...
RCP< TimerManager > timer_
Define IntegerRangeList validator.
Gathering definitions used in software development.
RCP< ParameterList > params_
const RCP< const Environment > & getEnvironment() const
Get the current Environment. Useful for testing.
RCP< const Environment > envConst_
Declarations for TimerManager.