本文整理汇总了C++中Interpretation::add方法的典型用法代码示例。如果您正苦于以下问题:C++ Interpretation::add方法的具体用法?C++ Interpretation::add怎么用?C++ Interpretation::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Interpretation
的用法示例。
在下文中一共展示了Interpretation::add方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: retrieve
void ConsistencyAtom::retrieve(const Query& query, Answer& answer, NogoodContainerPtr nogoods) throw (PluginError)
{
Interpretation toCheck;
RegistryPtr registry = getRegistry();
std::vector<std::string> expressions;
std::vector<OrdinaryAtom> sumData;
int domainMaxValue;
int domainMinValue;
bool definedDomain=false;
std::string globalConstraintName = "";
std::string globalConstraintValue = "";
std::pair<Interpretation::TrueBitIterator, Interpretation::TrueBitIterator>
trueAtoms ;
InterpretationConstPtr toUse;
if(query.assigned!=NULL)
{
trueAtoms= query.assigned->trueBits();
toUse=query.assigned;
}
else
{
toUse=query.interpretation;
trueAtoms= query.interpretation->trueBits();
}
vector<ID> atomIds;
if(!idSaved)
storeID(registry);
// Iterate over all input interpretation
for (Interpretation::TrueBitIterator it = trueAtoms.first; it != trueAtoms.second; it++) {
const OrdinaryAtom &atom = toUse->getAtomToBit(it);
Term name = registry->terms.getByID(atom.tuple[0]);
if(!query.interpretation->getFact(*it)){
continue;
}
string expr="";
if (atom.tuple[0]==exprAuxID) {
expressions.push_back(getExpressionFromID(registry,atom,false));
ID atomID=registry->ogatoms.getIDByTuple(atom.tuple);
atomIds.push_back(atomID);
if(cspGraphLearning && possibleConflictCpVariable.find(atomID)!=possibleConflictCpVariable.end())
{
set< Interpretation* > s=possibleConflictCpVariable.at(atomID);
for( set<Interpretation*>::iterator it=s.begin();it!=s.end();++it)
{
toCheck.add(**it);
}
}
}
else if (atom.tuple[0]==not_exprAuxID) {
expressions.push_back(getExpressionFromID(registry,atom,true));
ID atomID=registry->ogatoms.getIDByTuple(atom.tuple);
atomIds.push_back(atomID);
// if the atom doesn't contain ASP variables insert all atom that are possible conflict
if(cspGraphLearning && possibleConflictCpVariable.find(atomID)!=possibleConflictCpVariable.end())
{
set< Interpretation* > s=possibleConflictCpVariable.at(atomID);
for( set<Interpretation*>::iterator it=s.begin();it!=s.end();++it)
{
toCheck.add(**it);
}
}
}
else if (atom.tuple[0]==domainAuxID) {
definedDomain=true;
domainMinValue=atom.tuple[1].address;
domainMaxValue=atom.tuple[2].address;;
}
else if (atom.tuple[0]==maximizeAuxID ||atom.tuple[0]==minimizeAuxID) {
globalConstraintName = name.symbol;
globalConstraintValue = removeQuotes(registry->terms.getByID(atom.tuple[1]).symbol);
}
else { // this predicate received as input to sum aggregate function
sumData.push_back(atom);
}
}
if(!definedDomain)
throw dlvhex::PluginError("No domain specified");
// Call gecode solver
GecodeSolver* solver = new GecodeSolver(registry,sumData,domainMinValue, domainMaxValue, globalConstraintName, globalConstraintValue, simpleParser);
solver->propagate(expressions);
Gecode::Search::Options opt;
Gecode::BAB<GecodeSolver> solutions(solver,opt);
// If there's at least one solution, then data is consistent
if (solutions.next()) {
Tuple out;
answer.get().push_back(out);
if(cspAnticipateLearning && query.assigned!=NULL)
anticipateLearning(registry,query.assigned,nogoods,expressions,atomIds,sumData,domainMinValue,domainMaxValue,globalConstraintName,globalConstraintValue,toCheck);
}
else if (nogoods != 0){ // otherwise we need to learn IIS from it
GecodeSolver* otherSolver = new GecodeSolver(registry,sumData, domainMinValue,domainMaxValue, globalConstraintName, globalConstraintValue, simpleParser);
//.........这里部分代码省略.........