本文整理汇总了C++中problem函数的典型用法代码示例。如果您正苦于以下问题:C++ problem函数的具体用法?C++ problem怎么用?C++ problem使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了problem函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: problem
std::vector<DataPoint> Analysis_Impl::getDataPoints(
const std::vector< boost::optional<DiscretePerturbation> >& perturbations) const
{
DataPointVector result;
std::vector<QVariant> variableValues = problem().getVariableValues(perturbations);
if (variableValues.size() == perturbations.size()) {
// problem was able to match all perturbations
result = getDataPoints(variableValues);
}
return result;
}
示例2: map
std::vector<Problem> map(int problems_count, std::vector<std::string> &lines) {
std::vector<Problem> problems;
auto it = lines.cbegin();
for (int i = 0; i < problems_count; ++i) {
Problem problem(it);
problems.push_back(problem);
}
return problems;
}
示例3: wasserted
/* "warning" assert -- safe to continue, so we don't throw exception. */
void wasserted(const char *msg, const char *file, unsigned line) {
problem() << "warning Assertion failure " << msg << ' ' << file << ' ' << dec << line << endl;
sayDbContext();
raiseError(0,msg && *msg ? msg : "wassertion failure");
assertionCount.condrollover( ++assertionCount.warning );
#if defined(_DEBUG) || defined(_DURABLEDEFAULTON)
// this is so we notice in buildbot
log() << "\n\n***aborting after wassert() failure in a debug/test build\n\n" << endl;
abort();
#endif
}
示例4: defined
/**
Deletes the specified file. An exception is not thrown if the specified file does not exist
\param[in] path The path to the file to be deleted.
\throws SCXUnauthorizedFileSystemAccessException The caller does not have the required permission
or path is a directory or path specified a read-only file
The path parameter is permitted to specify relative or absolute path information. Relative
path information is interpreted as relative to the current working directory. To obtain
the current working directory, see GetCurrentDirectory
*/
void SCXFile::Delete(const SCXFilePath& path) {
#if defined(WIN32)
int failure = _wremove(path.Get().c_str());
#elif defined(SCX_UNIX)
std::string localizedPath = SCXFileSystem::EncodePath(path);
int failure = remove(localizedPath.c_str());
#else
#error
#endif
if (failure) {
if (errno == EACCES || errno == EBUSY || errno == EPERM || errno == EROFS) {
throw SCXUnauthorizedFileSystemAccessException(path, SCXFileSystem::GetAttributes(path), SCXSRCLOCATION);
} else if (errno == ENOENT) {
const int existenceOnly = 00;
#if defined(WIN32)
failure = _waccess(path.Get().c_str(), existenceOnly);
#elif defined(SCX_UNIX)
failure = access(localizedPath.c_str(), existenceOnly);
#else
#error
#endif
bool fileStillExists = !failure;
if (fileStillExists) {
// We got ENOENT when trying to remove the file,
// but appearently the file exists. That means that
// the file is not a file but a directory
throw SCXUnauthorizedFileSystemAccessException(path, SCXFileSystem::GetAttributes(path), SCXSRCLOCATION);
} if (errno == EACCES) {
throw SCXUnauthorizedFileSystemAccessException(path, SCXFileSystem::GetAttributes(path), SCXSRCLOCATION);
} else if (errno == EINVAL) {
throw SCXInvalidArgumentException(L"path", L"Invalid format of path " + path.Get(), SCXSRCLOCATION);
} else if (errno != ENOENT) {
std::wstring problem(L"Failed to delete " + path.Get());
throw SCXInternalErrorException(UnexpectedErrno(problem, errno), SCXSRCLOCATION);
}
} else {
std::wstring problem(L"Failed to delete " + path.Get());
throw SCXInternalErrorException(UnexpectedErrno(problem, errno), SCXSRCLOCATION);
}
}
}
示例5: threadRun
void threadRun( MessagingPort * inPort) {
assert( inPort );
setThreadName( "conn" );
TicketHolderReleaser connTicketReleaser( &connTicketHolder );
auto_ptr<MessagingPort> p( inPort );
string otherSide;
Message m;
try {
otherSide = p->farEnd.toString();
while ( 1 ) {
m.reset();
p->clearCounters();
if ( ! p->recv(m) ) {
if( !cmdLine.quiet )
log() << "end connection " << otherSide << endl;
p->shutdown();
break;
}
handler->process( m , p.get() );
networkCounter.hit( p->getBytesIn() , p->getBytesOut() );
}
}
catch ( const SocketException& ) {
log() << "unclean socket shutdown from: " << otherSide << endl;
}
catch ( const std::exception& e ) {
problem() << "uncaught exception (" << e.what() << ")(" << demangleName( typeid(e) ) <<") in PortMessageServer::threadRun, closing connection" << endl;
}
catch ( ... ) {
problem() << "uncaught exception in PortMessageServer::threadRun, closing connection" << endl;
}
handler->disconnected( p.get() );
}
示例6: LOG
bool Analysis_Impl::addDataPoint(const DataPoint& dataPoint) {
if (m_dataPointsAreInvalid) {
LOG(Info,"Current data points are invalid. Call removeAllDataPoints before adding new ones.");
return false;
}
if (!(dataPoint.problem().uuid() == problem().uuid())) {
LOG(Error,"Cannot add given DataPoint to Analysis '" << name() <<
"', because it is not associated with Problem '" << problem().name() << "'.");
return false;
}
DataPointVector existingDataPoints = getDataPoints(dataPoint.variableValues());
if (existingDataPoints.size() > 0) {
BOOST_ASSERT(existingDataPoints.size() == 1); // dataPoint must be fully specified to be valid
LOG(Info,"DataPoint not added to Analysis '" << name() << "', because it already exists.");
return false;
}
m_dataPoints.push_back(dataPoint);
connectChild(m_dataPoints.back(),true);
onChange(AnalysisObject_Impl::Benign);
return true;
}
示例7: asserted
void asserted(const char *msg, const char *file, unsigned line) {
assertionCount.condrollover( ++assertionCount.regular );
problem() << "Assertion failure " << msg << ' ' << file << ' ' << dec << line << endl;
sayDbContext();
raiseError(0,msg && *msg ? msg : "assertion failure");
lastAssert[0].set(msg, getDbContext().c_str(), file, line);
stringstream temp;
temp << "assertion " << file << ":" << line;
AssertionException e(temp.str(),0);
breakpoint();
throw e;
}
示例8: TestExceptions
void TestExceptions() throw(Exception)
{
TS_ASSERT_THROWS_THIS(MatrixVentilationProblem bad_problem("mesh/test/data/y_branch_3d_mesh", 1u),
"Outlet node is not a boundary node");
MatrixVentilationProblem problem("lung/test/data/three_bifurcations");
TS_ASSERT_THROWS_THIS(problem.SolveProblemFromFile("DoesNotExist.txt", "out", "out"), "Could not open file DoesNotExist.txt");
TS_ASSERT_THROWS_THIS(problem.SetPressureAtBoundaryNode(3u, 0.0), "Boundary conditions cannot be set at internal nodes");
TS_ASSERT_THROWS_THIS(problem.SetFluxAtBoundaryNode(3u, 0.0), "Boundary conditions cannot be set at internal nodes");
}
示例9: problem
void ilp_solution_t::get_reduced_sol(std::set<literal_t> *p_literals, std::set<literal_t> *p_non_eqs, const std::list< hash_set<term_t> > &terms) const {
const ilp_problem_t *prob = problem();
const pg::proof_graph_t *graph = prob->proof_graph();
hash_map<term_t, term_t> t2r;
_getRepresentative(&t2r, terms);
auto reguralized =
[&t2r](const std::list<hash_set<term_t> > &terms, const literal_t &lit) -> literal_t
{
literal_t out(lit);
for (term_idx_t i = 0; i < out.terms.size(); ++i)
{
if (t2r.count(out.terms.at(i)) > 0)
{
out.terms[i] = t2r[out.terms.at(i)];
break;
}
}
return out;
};
// ENUMERATE ELEMENTS OF literals AND non_eqs
for (auto n : graph->nodes())
if (not n.is_equality_node())
if (n.type() == pg::NODE_HYPOTHESIS or n.type() == pg::NODE_OBSERVABLE)
{
variable_idx_t v = problem()->find_variable_with_node(n.index());
if (v >= 0)
if (variable_is_active(v))
{
if (n.is_non_equality_node())
p_non_eqs->insert(reguralized(terms, n.literal()));
else
p_literals->insert(reguralized(terms, n.literal()));
}
}
}
示例10: initSimulation
void
InitPolicyInterpolation< mesh_Type >::
initSimulation ( bcContainerPtr_Type /*bchandler*/,
vectorPtr_Type solution )
{
ASSERT ( problem()->hasExactSolution(), "Error: You cannot use the interpolation method if the problem has not an analytical solution." );
Real currentTime = initialTime() - timestep() * bdf()->order();
UInt pressureOffset = uFESpace()->fieldDim() * uFESpace()->dof().numTotalDof();
vectorPtr_Type velocity;
velocity.reset ( new vector_Type ( uFESpace()->map(), Unique ) );
vectorPtr_Type pressure;
pressure.reset ( new vector_Type ( pFESpace()->map(), Unique ) );
*solution = 0.0;
uFESpace()->interpolate ( problem()->uexact(), *velocity, currentTime );
pFESpace()->interpolate ( problem()->pexact(), *pressure, currentTime );
solution->add ( *velocity );
solution->add ( *pressure, pressureOffset );
bdf()->setInitialCondition ( *solution );
currentTime += timestep();
for ( ; currentTime <= initialTime() + timestep() / 2.0; currentTime += timestep() )
{
*solution = 0.0;
*velocity = 0.0;
*pressure = 0.0;
uFESpace()->interpolate ( problem()->uexact(), *velocity, currentTime );
pFESpace()->interpolate ( problem()->pexact(), *pressure, currentTime );
solution->add ( *velocity );
solution->add ( *pressure, pressureOffset );
// Updating bdf
bdf()->shiftRight ( *solution );
}
}
示例11: conflicting_writes
void conflicting_writes(host_port *host) {
int connection, err;
err = make_connection_with(host->ip, host->port, &connection);
if(err < 0) {
problem("Connection failure.\n");
exit(-1);
}
printf("Made connection in second thread, file descriptor is %d\n", connection);
err = DONT;
safe_send(connection, &err, sizeof(int));
err = 3000;
safe_send(connection, &err, sizeof(int));
}
示例12: SockStartupTests
SockStartupTests() {
#if defined(_WIN32)
WSADATA d;
if ( WSAStartup(MAKEWORD(2,2), &d) != 0 ) {
out() << "ERROR: wsastartup failed " << errno << endl;
problem() << "ERROR: wsastartup failed " << errno << endl;
dbexit( EXIT_NTSERVICE_ERROR );
}
#endif
//out() << "ntohl:" << ntohl(256) << endl;
//sendtest();
//listentest();
}
示例13: main
int main(int argc, char *argv[])
{
// Pour accélérer les I/O
//std::ios_base::sync_with_stdio(false);
if(argc != 2)
{
std::cerr << "Nombre d'argument invalide : un unique argument est attendu." << std::endl;
exit(1);
}
std::ifstream input;
input.open (argv[1], std::ios::in);
if (!input.is_open())
{
std::cerr << "Erreur dans l'ouverture du fichier " << argv[1] << std::endl;
exit(1);
}
// Parse le header dans l'entrée standard : récupère nombre de variables et de clauses
unsigned int nbrVar, nbrClauses;
parserHeader(input, nbrVar, nbrClauses);
// Initialise le problème en lisant l'entrée standard
SatProblem problem(input, nbrVar, nbrClauses);
input.close();
// Résout le problème puis affiche la sortie correspondante
#if VERBOSE == 0
if (problem.satisfiability())
return EXIT_SATISFIABLE;
else
return EXIT_UNSATISFIABLE;
#else
if(problem.satisfiability())
{
std::cout << "s SATISFIABLE\n";
const std::vector<std::pair<unsigned, bool> > assign = problem.getAssign();
for(unsigned int k = 0; k < assign.size(); k++)
{
std::cout << "v ";
if (! assign[k].second)
std::cout << "-";
std::cout << assign[k].first << '\n';
}
return EXIT_SATISFIABLE;
}
else
{
std::cout << "s UNSATISFIABLE\n";
return EXIT_UNSATISFIABLE;
}
#endif
}
示例14: problem
//-----------------------------------------------------------------------------
void dolfin::solve(const Equation& equation,
Function& u,
std::vector<const BoundaryCondition*> bcs,
Parameters parameters)
{
// Solve linear problem
if (equation.is_linear())
{
LinearVariationalProblem problem(*equation.lhs(), *equation.rhs(), u, bcs);
LinearVariationalSolver solver(problem);
solver.parameters.update(parameters);
solver.solve();
}
// Solve nonlinear problem
else
{
NonlinearVariationalProblem problem(*equation.lhs(), u, bcs);
NonlinearVariationalSolver solver(problem);
solver.parameters.update(parameters);
solver.solve();
}
}
示例15: _unindexRecord
/**
* Remove the provided (obj, dl) pair from the provided index.
*/
static void _unindexRecord(NamespaceDetails *d, int idxNo, const BSONObj& obj,
const DiskLoc& dl, bool logIfError = true) {
auto_ptr<IndexDescriptor> desc(CatalogHack::getDescriptor(d, idxNo));
auto_ptr<IndexAccessMethod> iam(CatalogHack::getIndex(desc.get()));
InsertDeleteOptions options;
options.logIfError = logIfError;
int64_t removed;
Status ret = iam->remove(obj, dl, options, &removed);
if (Status::OK() != ret) {
problem() << "Couldn't unindex record " << obj.toString() << " status: "
<< ret.toString() << endl;
}
}