void ConsistencyAtom::anticipateLearning(RegistryPtr& registry,const InterpretationConstPtr& assigned,NogoodContainerPtr& nogoods, vector<string>& expressions,vector<ID>& atomIds,vector<OrdinaryAtom> &sumData,int domainMinValue,int domainMaxValue,string& globalConstraintName,string& globalConstraintValue,Interpretation& toCheck) { pm.updateMask(); Interpretation::TrueBitIterator it, it_end; boost::tie(it, it_end) = pm.mask()->trueBits(); //iterate over all Ordinary ground atom (expr and not_expr) for(;it!=it_end;it++) { //if the atom is not assigned, add atom to lists in order to check consistency if(assigned->getFact(*it)) { continue; } const OrdinaryAtom& atom=pm.mask()->getAtomToBit(it); if (atom.tuple[0]==exprAuxID && (!cspGraphLearning || !cpVariables.getFact(*it) || toCheck.getFact(*it))) { expressions.push_back(getExpressionFromID(registry,atom,false)); atomIds.push_back(registry->ogatoms.getIDByTuple(atom.tuple)); } else if (atom.tuple[0]==not_exprAuxID && (!cspGraphLearning ||!cpVariables.getFact(*it) || toCheck.getFact(*it))) { expressions.push_back(getExpressionFromID(registry,atom,true)); atomIds.push_back(registry->ogatoms.getIDByTuple(atom.tuple)); } 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 the solution is not consistent try to learn nogoods if (solutions.next()==NULL) { GecodeSolver* otherSolver = new GecodeSolver(registry,sumData, domainMinValue,domainMaxValue, globalConstraintName, globalConstraintValue, simpleParser); //try to learn no goods backwardlearningProcessor->learnNogoods(nogoods,expressions,atomIds,otherSolver); delete otherSolver; } delete solver; expressions.pop_back(); atomIds.pop_back(); } }