Matrix<double> GeneralConstraint::getCovariance( const VariableSet& varSet ) { Matrix<double> covariance(varSet.size(),varSet.size(),0.0); int i(0); for(VariableSet::const_iterator iti=varSet.begin(); iti!=varSet.end(); ++iti) { int j(0); for(VariableSet::const_iterator itj=varSet.begin(); itj!=varSet.end(); ++itj) { covariance[i][j] = solver.getCovariance(*iti,*itj); j++; } i++; } return covariance; } // End of method 'GeneralConstraint::getCovariance(...'
bool operator()(const VariableSet & m,const VariableSet & n) const { bool result = false; int msz = m.size(); int nsz = n.size(); if(msz!=nsz) { result = msz< nsz; } else if(msz>0) { result = false; // perhaps they are equal Variable v1,v2; bool b1 = m.firstVariable(v1); bool b2 = n.firstVariable(v2); if(v1==v2) { while(b1&&b2) { b1 = m.nextVariable(v1); b2 = n.nextVariable(v2); if(b1) { if(v1!=v2) { result = operator()(v1,v2); }; } else break; }; } else { result = operator()(v1,v2); }; if(b1!=b2) errorh(__LINE__); }; return result; };
/** * Takes formula, the prefix, and converts it to the set of sets of second * order variables, according to the variable map; * * @param formula: formula corresponding to the prefix * @return: list of lists of second-order variables */ PrefixListType convertPrefixFormulaToList(ASTForm* formula) { PrefixListType list; VariableSet set; unsigned int quantifiedSize; unsigned int value; bool isFirstNeg = true; // empty prefix is just one empty list if (formula->kind == aTrue) { list.push_front(set); return list; } ASTForm* iterator = formula; // while we are not at the end of the prefix while (iterator->kind != aTrue) { //iterator->dump(); //std::cout << "\n"; // Add to set if (iterator->kind == aEx2) { ASTForm_Ex2* exf = (ASTForm_Ex2*) iterator; quantifiedSize = (exf->vl)->size(); for (unsigned i = 0; i < quantifiedSize; ++i) { value = (exf->vl)->get(i); //std::cout << value << " -> " << varMap[value] << "\n"; set.push_back(varMap[value]); } iterator = exf->f; isFirstNeg = false; // Create new set } else if (iterator->kind == aNot) { if (!isFirstNeg) { list.push_front(set); set.clear(); } else { isFirstNeg = false; } ASTForm_Not* notf = (ASTForm_Not*) iterator; iterator = notf->f; // Fail, should not happen } else { assert(false); } } if (set.size() != 0) { list.push_front(set); } return list; }
Vector<double> GeneralConstraint::getSolution( const VariableSet& varSet ) { Vector<double> solution(varSet.size(),0.0); int i(0); for(VariableSet::const_iterator it=varSet.begin(); it!=varSet.end(); ++it) { solution[i] = solver.getSolution(*it); i++; } return solution; } // End of method 'GeneralConstraint::getSolution(...'