PredicateSymbol* LiftedAlgsConvertor::createPredicateSymbol(Predicate* pred) { int predicateId = pred->getId(); vector<int> var_types(pred->getNumTerms()); string symbolName(pred->getName()); PredicateSymbol* pSymbol = new PredicateSymbol(predicateId,symbolName,var_types,LogDouble(1,false),LogDouble(1,false),predicateId); return pSymbol; }
InputParameters validParams<RichardsVarNames>() { InputParameters params = validParams<GeneralUserObject>(); params.addClassDescription("Holds information on the porepressure variable names"); params.addRequiredCoupledVar("richards_vars", "List of variables that represent the porepressures or (porepressure, saturations). In single-phase models you will just have one (eg \'pressure\'), in two-phase models you will have two (eg \'p_water p_gas\', or \'p_water s_water\', etc. These names must also be used in your kernels and material."); MooseEnum var_types("pppp", "pppp"); params.addParam<MooseEnum>("var_types", var_types, "Variable types for the problem. Eg, 'pppp' means all the variables are pressure variables"); return params; }
WClause* LiftedAlgsConvertor::convertClauseToLifted(Clause* clause, const Domain* domain, vector<PredicateSymbol*>& symbolsToAdd,bool& containsGroundedClause) { const Array<Predicate*>* preds = clause->getPredicates(); map<int,LvrTerm*> mapOfTerms; WClause* nClause = new WClause(); nClause->atoms = vector<Atom*>(preds->size()); nClause->sign = vector<bool>(preds->size()); nClause->weight = LogDouble(clause->getWt(),false); set<int> completedIds; for (int i = 0; i < preds->size(); i++) { nClause->sign[i] = !((*preds)[i]->getSense()); int predicateId = (*preds)[i]->getId(); vector<int> var_types((*preds)[i]->getNumTerms()); string symbolName((*preds)[i]->getName()); PredicateSymbol* pSymbol = new PredicateSymbol(predicateId,symbolName,var_types,LogDouble(1,false),LogDouble(1,false),predicateId); const PredicateTemplate *ptemplate = (*preds)[i]->getTemplate(); vector<LvrTerm*> atomTerms((*preds)[i]->getNumTerms()); for (int termno = 0; termno < (*preds)[i]->getNumTerms(); termno++) { const Term* term = (*preds)[i]->getTerm(termno); if(term->getType()==Term::CONSTANT) { int id = term->getId(); vector<int> domValues(1); domValues[0] = id; LvrTerm* lvrTerm = new LvrTerm(0,domValues); atomTerms[termno]=lvrTerm; //contains a "+" in the term containsGroundedClause=true; continue; } int varId = term->getId(); map<int,LvrTerm*>::iterator mapIt = mapOfTerms.find(varId); if(mapIt==mapOfTerms.end()) { //new term, add it int varTypeId = ptemplate->getTermTypeAsInt(termno); const Array<int>* constants = domain->getConstantsByType(varTypeId); vector<int> domValues; for(unsigned int j=0;j<constants->size();j++) { domValues.push_back((*constants)[j]); } LvrTerm* lvrTerm = new LvrTerm(0,domValues); mapOfTerms.insert(pair<int,LvrTerm*> (varId,lvrTerm)); atomTerms[termno]=lvrTerm; } else { //use existing term atomTerms[termno] = mapIt->second; } } //sort the domains of all terms for(unsigned int jj=0;jj<atomTerms.size();jj++) sort(atomTerms[jj]->domain.begin(),atomTerms[jj]->domain.end()); Atom* atom = new Atom(pSymbol,atomTerms); nClause->atoms[i] = atom; if(completedIds.count(pSymbol->id) == 0) { //ADD TO LvrMLN PredicateSymbol* nSymbol = new PredicateSymbol(predicateId,symbolName,var_types,LogDouble(1,false),LogDouble(1,false),predicateId); symbolsToAdd.push_back(nSymbol); } } return nClause; }