void Conveyor::onImage(const cv::Mat &mono) { Timer timer; timer.start(); double min, max; cv::minMaxLoc(mono, &min, &max); //if(min < min_) min_ = min; min_ += (min - min_) * 0.02; //if(max > max_) max_ = max; max_ += (max - max_) * 0.02; Frame8 nf(mono, 10, min_, max_, invmed_); if(jacobi_.empty()) initJacobi(nf.levels_.size()); for(auto j = jacobi_.begin(); j != jacobi_.end(); j++) { if(j == jacobi_.begin()) (*j)->set(nf.levels_[0], 1); else (*j)->shrink((j - 1)->get()); } cv::Mat pose = cv::Mat::zeros(2, 3, CV_64F); double weight = 0; for(auto f = history_.begin(); f != history_.end(); f++) { cv::Mat t; double w = solve(*f, nf, t); /*cv::Mat tr = f->pose_(cv::Rect(0, 0, 2, 2)); cv::Mat to = t(cv::Rect(2, 0, 1, 2)); ps += tr * t(cv::Rect(2, 0, 1, 2)); tr *= t(cv::Rect(0, 0, 2, 2)); t =*/ weight += w; pose += t; } pose /= weight; nf.pose_ = pose; if(pushHistory) { if(history_.size() > 0) history_.pop_back(); history_.push_front(nf); } double time = timer.end(); std::cout << "time = " << time << std::endl; }
bool IdentifyLiaisonTunnel::doILT2( EdgeArray& edges ) { if( !isInitNetworkOk() ) return false; if( airEdges.isEmpty() ) return false; NodeFilter nf( dg, true ); BuildNodeFilter( dg, airEdges, sn, tn, nf ); // 记录节点属于哪个区域(0-用风区, 1-进风区, -1-回风区) IntMap imap( dg ); Init_IMap( dg, ef, nf, airEdges, imap ); // 查找联络巷 FindILTEdges( dg, datas, imap, edges ); return true; }
void MeasureFormat::initMeasureFormat( const Locale &locale, UMeasureFormatWidth w, NumberFormat *nfToAdopt, UErrorCode &status) { static const char *listStyles[] = {"unit", "unit-short", "unit-narrow"}; LocalPointer<NumberFormat> nf(nfToAdopt); if (U_FAILURE(status)) { return; } const char *name = locale.getName(); setLocaleIDs(name, name); UnifiedCache::getByLocale(locale, cache, status); if (U_FAILURE(status)) { return; } const SharedPluralRules *pr = PluralRules::createSharedInstance( locale, UPLURAL_TYPE_CARDINAL, status); if (U_FAILURE(status)) { return; } SharedObject::copyPtr(pr, pluralRules); pr->removeRef(); if (nf.isNull()) { const SharedNumberFormat *shared = NumberFormat::createSharedInstance( locale, UNUM_DECIMAL, status); if (U_FAILURE(status)) { return; } SharedObject::copyPtr(shared, numberFormat); shared->removeRef(); } else { adoptNumberFormat(nf.orphan(), status); if (U_FAILURE(status)) { return; } } fWidth = w; delete listFormatter; listFormatter = ListFormatter::createInstance( locale, listStyles[getRegularWidth(fWidth)], status); }
// Make patch weighting factors void Foam::cyclicGgiFvPatch::makeWeights(scalarField& w) const { // Calculation of weighting factors is performed from the master // position, using reconstructed shadow cell centres // HJ, 2/Aug/2007 if (cyclicGgiPolyPatch_.master()) { vectorField n = nf(); // Note: mag in the dot-product. // For all valid meshes, the non-orthogonality will be less that // 90 deg and the dot-product will be positive. For invalid // meshes (d & s <= 0), this will stabilise the calculation // but the result will be poor. HJ, 24/Aug/2011 scalarField nfc = mag ( n & (cyclicGgiPolyPatch_.reconFaceCellCentres() - Cf()) ); w = nfc/(mag(n & (Cf() - Cn())) + nfc); if (bridgeOverlap()) { // Set overlap weights to 0.5 and use mirrored neighbour field // for interpolation. HJ, 21/Jan/2009 bridge(scalarField(size(), 0.5), w); } } else { // Pick up weights from the master side scalarField masterWeights(shadow().size()); shadow().makeWeights(masterWeights); w = interpolate(1 - masterWeights); if (bridgeOverlap()) { // Set overlap weights to 0.5 and use mirrored neighbour field // for interpolation. HJ, 21/Jan/2009 bridge(scalarField(size(), 0.5), w); } } }
void QualifyPass1(CppBase& base) { // Qualify types LTIMING("QualifyPass1"); for(int ni = 0; ni < base.GetCount(); ni++) { Array<CppItem>& n = base[ni]; ScopeInfo nf(base, ni); for(int i = 0; i < n.GetCount(); i++) { CppItem& m = n[i]; if(m.kind == NAMESPACE) base.namespaces.FindAdd(base.GetKey(ni)); if(m.IsType() && m.qualify) { m.qualify = false; m.qtype = QualifyIds(nf, m.type, m.using_namespaces, true); // type of item, now qualified (probaly already was) m.qptype = QualifyIds(nf, m.ptype, m.using_namespaces, true); // base classes m.qitem = m.item; // name of type (struct) item is already qualified } } } }
void test_inc_rank( ) { int N = 20; for( int i=0 ; i<100 ; ++i ) { Word w = Word::randomWord( N-1 , 200 ); NF nf( N , w ); NF nf2 = nf.increaseRank( N+1 ); Word u = -w * nf2.getWord( ); NF nf_check( N+1 , -w * nf2.getWord( ) ); if( nf_check.isTrivial( ) ) { cout << "The result is correct" << endl; } else { cout << "The result is not correct" << endl; exit(1); } } }
static #endif int main_pac(int argc, char *argv[]) { // Clean exit first atexit(cleanup); InitData d; PostInitData pd; GameData gd; screen_setup(d, gd); // Show splash/loading screen SDL_Surface *splash = SurfaceLoader::getInstance()->loadSurface(SPLASH_SCREEN); nf(!splash, "Unable to load splash screen"); blit(splash, gd.screen, 0, 0); SDL_Flip(gd.screen); // Initialisation data and initial setup setup_setup_data(d); setup(d, gd); // Post-setup data and post-setup setup_post_setup_data(pd, gd); post_setup(pd, d, gd); // Manage splash screen ShowStartingScreen(splash, gd.screen, *gd.bools, gd.akmovs, d.startingTime); // Start game loop gaim_loop(gd); // conclusion if (!gd.bools->game_exit) { if (gd.bools->won) showWiener(gd); else showLoser(gd); } credits(gd); return 0; }
void QualifyPass2(CppBase& base) { // Qualify function parameters LTIMING("QualifyPass2"); for(int ni = 0; ni < base.GetCount(); ni++) { Array<CppItem>& n = base[ni]; ScopeInfo nf(base, ni); for(int i = 0; i < n.GetCount(); i++) { CppItem& m = n[i]; if(m.uname.GetCount() == 0 && m.name.GetCount()) m.uname = ToUpper(m.name); if(!m.IsType() && m.qualify) { m.qualify = false; m.qtype = QualifyIds(nf, m.type, m.using_namespaces, true); m.qptype = QualifyIds(nf, m.ptype, m.using_namespaces, true); m.qitem = m.IsCode() ? QualifyIds(nf, m.item, m.using_namespaces, false) : m.item; } } } }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); doUpdate(); if(!QFile(QApplication::applicationDirPath() + "/adjustments.ini").exists()) { QFile nf(QApplication::applicationDirPath() + "/adjustments.ini"); nf.open(QFile::WriteOnly); nf.write(QString("[adjustments]\n").toUtf8()); nf.write(QString("x=\"0\"\n").toUtf8()); nf.write(QString("y=\"0\"\n").toUtf8()); nf.close(); } adjust = new QSettings(QApplication::applicationDirPath() + "/adjustments.ini", QSettings::IniFormat); adjust->beginGroup("adjustments"); }
void unwind(Bool sh, Int addr) { App app = heap[addr]; if (app.tag >= INVALID) error("unwind(): invalid tag.\n"); if (sh && !nf(&app)) { Update u; u.saddr = sp; u.haddr = addr; ustack[usp++] = u; } #if ONEBITGC_STUDY1 if (!sh) collectApp(addr); #endif dashApp(sh, &app); if (app.tag == CASE) lstack[lsp++] = app.details.lut; sp--; pushAtoms(app.size, app.atoms); }
int main(int argc, char** argv) try { if(!setup(argc, argv)) { usage(); exit(-2); } std::cerr << "parsed channels: "; std::copy(channel_list.begin(), channel_list.end(), std::ostream_iterator<int> (std::cerr, " ")); std::cerr << std::endl; std::cerr << "nflogd starting..." << std::endl; PacketHandler ph(pcap_filename); NFmain nf(channel_list, [ph = std::ref(ph)](struct nflog_data *nfa){ ph(nfa); }); // setup signal SETSIG(SIGTERM, term_handler, SA_RESTART); SETSIG(SIGINT, term_handler, SA_RESTART); SETSIG(SIGHUP, hup_handler, SA_RESTART); std::cerr << "going into main loop" << std::endl; switch_user(); set_dumpable(); nf.loop(term_flag); std::cerr << "terminating..." << std::endl; return 0; } catch (const std::exception& e) { std::cerr << e.what() << std::endl; return -1; }
void Foam::cyclicACMIFvPatch::makeWeights(scalarField& w) const { if (coupled()) { const cyclicACMIFvPatch& nbrPatch = neighbFvPatch(); const scalarField deltas(nf() & coupledFvPatch::delta()); // These deltas are of the cyclic part alone - they are // not affected by the amount of overlap with the nonOverlapPatch scalarField nbrDeltas ( interpolate ( nbrPatch.nf() & nbrPatch.coupledFvPatch::delta() ) ); scalar tol = cyclicACMIPolyPatch::tolerance(); forAll(deltas, facei) { scalar di = deltas[facei]; scalar dni = nbrDeltas[facei]; if (dni < tol) { // Avoid zero weights on disconnected faces. This value // will be weighted with the (zero) face area so will not // influence calculations. w[facei] = 1.0; } else { w[facei] = dni/(di + dni); } } }
unsigned char * resample( const QString & nrrd ) { voxmap_size /= rasterization_scale; tile_size /= rasterization_scale; QProcess proc; proc.setProgram( "unu" ); proc.setArguments( QStringList() << "resample" << "-k" << "cubic:1,0" << "-i" << nrrd << "-s" << "=" << QString::number( voxmap_size.X() ) << QString::number( voxmap_size.Y() ) << QString::number( voxmap_size.Z() ) << "-o" << nrrd + ".resampled" ); proc.start(); if( !proc.waitForStarted( -1 ) || !proc.waitForFinished( -1 ) ) return NULL; qint64 bytes = voxmap_size.X() * voxmap_size.Y() * voxmap_size.Z() * voxel_size; char * voxels = new char[ bytes ]; QFile nf( nrrd + ".resampled" ); if( !voxels || !nf.open( QIODevice::ReadOnly ) || nf.size() <= bytes ) return NULL; nf.seek( nf.size() - bytes ); if( nf.read( voxels, bytes ) != bytes ) return NULL; return reinterpret_cast< unsigned char *>( voxels ); }
// Make patch face non-orthogonality correction vectors void Foam::regionCoupleFvPatch::makeCorrVecs(vectorField& cv) const { if (rcPolyPatch_.coupled()) { // Non-orthogonality correction in attached state identical to ggi // interface // Calculate correction vectors on coupled patches const scalarField& patchDeltaCoeffs = deltaCoeffs(); vectorField patchDeltas = delta(); vectorField n = nf(); // If non-orthogonality is over 90 deg, kill correction vector // HJ, 6/Jan/2011 cv = pos(patchDeltas & n)*(n - patchDeltas*patchDeltaCoeffs); } else { // No correction in detached state. HJ, 26/Jul/2011 cv = vector::zero; } }
bool IdentifyLiaisonTunnel::doILT3( EdgeArray& edges ) { if( !isInitNetworkOk() ) return false; if( airEdges.isEmpty() ) return false; NodeFilter nf( dg, true ); BuildNodeFilter( dg, airEdges, sn, tn, nf ); double st = Timer::rdtscSeconds(); double et = Timer::rdtscSeconds(); acutPrintf( _T( "\n过滤阻断分支耗费时间:%.5f" ), et - st ); IntMap cmap( dg ); Init_CMap( dg, cmap ); st = Timer::rdtscSeconds(); // 对用风地点按距离进行排序 EdgeArray sortedAirEdges; SortAirEdges( dg, ef, sn, tn, airEdges, sortedAirEdges ); et = Timer::rdtscSeconds(); acutPrintf( _T( "\n对用风地点按距离排序耗费时间:%.5f" ), et - st ); ILT_Helper( dg, datas, ef, nf, sortedAirEdges, cmap ); st = Timer::rdtscSeconds(); // 查找联络巷 FindILTEdges( dg, datas, cmap, edges ); et = Timer::rdtscSeconds(); acutPrintf( _T( "\n查找联络巷耗费时间:%.5f" ), et - st ); return true; }
void test(Container& c) { auto* nf = &node_factory<Container>; for (int i = 0; i != 10; ++i) { typename Container::node_type node = nf(i, i + 1); assert(!node.empty()); size_t prev = c.size(); auto it = c.insert(c.end(), std::move(node)); assert(node.empty()); assert(prev + 1 == c.size()); assert(it->first == i); assert(it->second == i + 1); } assert(c.size() == 10); for (int i = 0; i != 10; ++i) { assert(c.count(i) == 1); assert(c[i] == i + 1); } }
void QualifyPass0(CppBase& base) { // Move scopes - solve: namespace X { struct C { void Foo(); }; using namespace X; void C::Foo() {} Vector<int> remove_scope; for(int ni = 0; ni < base.GetCount(); ni++) { Array<CppItem>& n = base[ni]; ScopeInfo nf(base); String scope = base.GetKey(ni); String usings; int toscopei = -1; Vector<int> remove_item; for(int i = 0; i < n.GetCount(); i++) { CppItem& m = n[i]; if(m.qualify && m.impl) { if(usings != m.using_namespaces) { usings = m.using_namespaces; toscopei = -1; Vector<String> h = Split(m.using_namespaces, ';'); for(int i = 0; i < h.GetCount(); i++) { String ns = h[i] + "::" + scope; toscopei = base.Find(ns); if(toscopei >= 0) break; } } if(toscopei >= 0 && toscopei != ni) { base[toscopei].Add(m); remove_item.Add(i); } } } n.Remove(remove_item); if(scope.GetCount() && n.GetCount() == 0) remove_scope.Add(ni); } base.Remove(remove_scope); }
void CEMWeekSynthesisReport::OnExportSelect(){ _debug(_T("%s"), CString(typeid(this).name())); CHMSMainFrame *pMF = (CHMSMainFrame*) AfxGetMainWnd(); UpdateData(true); CExcel xls; CRecord rs(&pMF->m_db); CString szSQL, tmpStr, szTemp, szWhere; int nCol = 0, nRow = 0; int nTotal[12], nTemp = 0; szSQL = GetQueryString(); int nCount = rs.ExecSQL(szSQL); if (nCount <= 0) { ShowMessage(150, MB_ICONSTOP); return; } xls.CreateSheet(1); xls.SetWorksheet(0); xls.SetColumnWidth(0, 30); xls.SetColumnWidth(1, 10); xls.SetColumnWidth(2, 10); xls.SetColumnWidth(3, 10); xls.SetColumnWidth(4, 10); xls.SetColumnWidth(5, 10); xls.SetColumnWidth(6, 10); xls.SetColumnWidth(7, 10); xls.SetColumnWidth(8, 10); xls.SetColumnWidth(9, 10); xls.SetColumnWidth(10, 10); xls.SetColumnWidth(11, 13); CellFormat df(&xls), hf(&xls), nf(&xls); df.SetItalic(true); df.SetCellStyle(FMT_TEXT | FMT_CENTER); hf.SetBold(true); hf.SetCellStyle(FMT_TEXT | FMT_CENTER); nf.SetCellStyle(FMT_NUMBER1); //Header xls.SetCellMergedColumns(nCol, nRow, 3); xls.SetCellMergedColumns(nCol, nRow + 1, 3); xls.SetCellMergedColumns(nCol, nRow + 2, 11); xls.SetCellMergedColumns(nCol, nRow + 3, 11); xls.SetCellText(nCol, nRow, pMF->m_CompanyInfo.sc_pname, FMT_TEXT | FMT_CENTER, true, 10); xls.SetCellText(nCol, nRow + 1, pMF->m_CompanyInfo.sc_name, FMT_TEXT | FMT_CENTER, true, 10); TranslateString(_T("Weekly Synthesis Report"), szTemp); StringUpper(szTemp, tmpStr); xls.SetCellText(nCol, nRow + 2, tmpStr, FMT_TEXT | FMT_CENTER, true, 12); tmpStr.Format(_T("T\x1EEB ng\xE0y %s \x111\x1EBFn ng\xE0y %s"), CDateTime::Convert(m_szFromDate, yyyymmdd|hhmmss, ddmmyyyy|hhmmss), CDateTime::Convert(m_szToDate, yyyymmdd|hhmmss, ddmmyyyy|hhmmss)); xls.SetCellText(nCol, nRow + 3, tmpStr, &df); //Column Header CStringArray arrCol; arrCol.Add(_T("Ph\xF2ng")); arrCol.Add(_T("Qu\xE2n")); arrCol.Add(_T("\x42HYT Qu\xE2n")); arrCol.Add(_T("\x42\x1EA1n")); arrCol.Add(_T("Tr\x1EBB < \x36t")); arrCol.Add(_T("\x43h\xEDnh s\xE1\x63h")); arrCol.Add(_T("\x44\xE2n")); arrCol.Add(_T("\x42HYT kh\xE1\x63")); arrCol.Add(_T("\x42H TNSQ")); arrCol.Add(_T("\x42H Qu\xE2n \x111\x1ED9i")); arrCol.Add(_T("BHYT Qu\xE2n nh\xE2n")); arrCol.Add(_T("BHYT(N\x1EE3 th\x1EBB)")); arrCol.Add(_T("T\x1ED5ng \x63\x1ED9ng")); nRow = 4; for (int i = 0; i < arrCol.GetCount(); i++) { xls.SetCellText(nCol+i, nRow, arrCol.GetAt(i), FMT_TEXT | FMT_CENTER, true, 10); } for (int i = 0; i< 12; i++) { nTotal[i] = 0; } nRow = 5; while (!rs.IsEOF()){ rs.GetValue(_T("roomid"), tmpStr); xls.SetCellText(nCol, nRow, tmpStr, FMT_TEXT); for (int i = 0; i< 12; i++) { szTemp.Format(_T("c%d"), i+1); rs.GetValue(szTemp, nTemp); tmpStr.Format(_T("%d"), nTemp); xls.SetCellText(nCol+i+1, nRow, tmpStr, &nf); nTotal[i] += nTemp; } nRow++; rs.MoveNext(); } TranslateString(_T("Total"), tmpStr); xls.SetCellText(nCol, nRow, tmpStr, FMT_TEXT | FMT_CENTER, true); for (int i = 0; i<12; i++) { tmpStr.Format(_T("%d"), nTotal[i]); xls.SetCellText(nCol+i+1, nRow, tmpStr, FMT_NUMBER1, true); } szWhere.Format(_T(" AND hcr_admitdate BETWEEN cast_string2timestamp('%s') AND cast_string2timestamp('%s')"), m_szFromDate, m_szToDate); if (pMF->GetModuleID() == _T("EM")) szWhere.AppendFormat(_T(" AND hd_enddept = '%s'"), pMF->GetCurrentDepartmentID()); szSQL.Format(_T(" SELECT sum(c1) as c1,") \ _T(" sum(c2) as c2,") \ _T(" sum(c3) as c3,") \ _T(" sum(c4) as c4,") \ _T(" sum(c5) as c5,") \ _T(" sum(c6) as c6,") \ _T(" sum(c7) as c7,") \ _T(" sum(c8) as c8,") \ _T(" sum(c9) as c9,") \ _T(" sum(c10) as c10, ") \ _T(" sum(c11) as c11, ") \ _T(" sum(c12) as c12 ") \ _T(" FROM") \ _T(" (") \ _T(" SELECT") \ _T(" case when hd_object=1 then 1 else 0 end as c1,") \ _T(" case when hd_object=2 then 1 else 0 end as c2,") \ _T(" case when hd_object=8 then 1 else 0 end as c3,") \ _T(" case when hd_object in(6, 9) then 1 else 0 end as c4,") \ _T(" case when hd_object=3 then 1 else 0 end as c5,") \ _T(" case when hd_object=7 then 1 else 0 end as c6,") \ _T(" case when hd_object=4 then 1 else 0 end as c7,") \ _T(" case when hd_object=5 then 1 else 0 end as c8,") \ _T(" case when hd_object=10 then 1 else 0 end as c9,") \ _T(" case when hd_object=11 then 1 else 0 end as c10,") \ _T(" case when hd_object=12 then 1 else 0 end as c11,") \ _T(" 1 as c12 ") \ _T(" FROM hms_doc") \ _T(" LEFT JOIN hms_exam ON (he_docno = hd_docno AND hd_doctor = he_doctor)") \ _T(" LEFT JOIN hms_clinical_record ON(hcr_docno=hd_docno)") \ _T(" WHERE hcr_numinward > 0 %s") \ _T(" ) tbl"), szWhere); rs.ExecSQL(szSQL); _fmsg(_T("%s"), szSQL); if (!rs.IsEOF()){ nRow++; xls.SetCellText(nCol, nRow, _T("V\xE0o vi\x1EC7n"), FMT_TEXT | FMT_CENTER, true); for (int i = 0; i< 12; i++) { szTemp.Format(_T("c%d"), i+1); rs.GetValue(szTemp, tmpStr); xls.SetCellText(nCol+i+1, nRow, tmpStr, FMT_NUMBER1, true); } } else { ShowMessage(150, MB_ICONSTOP); return; } xls.Save(_T("Exports\\Bao Cao Tong Hop Tuan C1_1.xls")); }
void Foam::threePhaseInterfaceProperties::correctContactAngle ( surfaceVectorField::GeometricBoundaryField& nHatb ) const { const volScalarField::GeometricBoundaryField& alpha1 = mixture_.alpha1().boundaryField(); const volScalarField::GeometricBoundaryField& alpha2 = mixture_.alpha2().boundaryField(); const volScalarField::GeometricBoundaryField& alpha3 = mixture_.alpha3().boundaryField(); const volVectorField::GeometricBoundaryField& U = mixture_.U().boundaryField(); const fvMesh& mesh = mixture_.U().mesh(); const fvBoundaryMesh& boundary = mesh.boundary(); forAll(boundary, patchi) { if (isA<alphaContactAngleFvPatchScalarField>(alpha1[patchi])) { const alphaContactAngleFvPatchScalarField& a2cap = refCast<const alphaContactAngleFvPatchScalarField> (alpha2[patchi]); const alphaContactAngleFvPatchScalarField& a3cap = refCast<const alphaContactAngleFvPatchScalarField> (alpha3[patchi]); scalarField twoPhaseAlpha2(max(a2cap, scalar(0))); scalarField twoPhaseAlpha3(max(a3cap, scalar(0))); scalarField sumTwoPhaseAlpha ( twoPhaseAlpha2 + twoPhaseAlpha3 + SMALL ); twoPhaseAlpha2 /= sumTwoPhaseAlpha; twoPhaseAlpha3 /= sumTwoPhaseAlpha; fvsPatchVectorField& nHatp = nHatb[patchi]; scalarField theta ( convertToRad * ( twoPhaseAlpha2*(180 - a2cap.theta(U[patchi], nHatp)) + twoPhaseAlpha3*(180 - a3cap.theta(U[patchi], nHatp)) ) ); vectorField nf(boundary[patchi].nf()); // Reset nHatPatch to correspond to the contact angle scalarField a12(nHatp & nf); scalarField b1(cos(theta)); scalarField b2(nHatp.size()); forAll(b2, facei) { b2[facei] = cos(acos(a12[facei]) - theta[facei]); } scalarField det(1.0 - a12*a12); scalarField a((b1 - a12*b2)/det); scalarField b((b2 - a12*b1)/det); nHatp = a*nf + b*nHatp; nHatp /= (mag(nHatp) + deltaN_.value()); } }
double LineSearch::argmax(Function& f, double minx, double maxx) { NegateFunction nf(f); return argmin(nf, minx, maxx); }
forAllConstIter(labelHashSet, patchSet_, iter) { label patchi = iter.key(); const fvPatch& patch = mesh_.boundary()[patchi]; vectorField nf(patch.nf()); vectorField faceCellCentres(patch.patch().faceCellCentres()); forAll(patch, patchFacei) { label meshFacei = patch.start()+patchFacei; // Find starting point on face (since faceCentre might not // be on face-diagonal decomposition) pointIndexHit startInfo ( mappedPatchBase::facePoint ( mesh_, meshFacei, polyMesh::FACE_DIAG_TRIS ) ); point start; if (startInfo.hit()) { start = startInfo.hitPoint(); } else { // Fallback: start tracking from neighbouring cell centre start = faceCellCentres[patchFacei]; } const point end = start-distance_*nf[patchFacei]; // Find tet for starting location label celli = -1; label tetFacei = -1; label tetPtI = -1; mesh_.findCellFacePt(start, celli, tetFacei, tetPtI); // Add to cloud. Add originating face as passive data cloud.addParticle ( new findCellParticle ( mesh_, start, celli, tetFacei, tetPtI, end, globalWalls.toGlobal(nPatchFaces) // passive data ) ); nPatchFaces++; }
questionsSettings::questionsSettings(TlevelCreatorDlg* creator) : TabstractLevelPage(creator) { QVBoxLayout *mainLay = new QVBoxLayout; mainLay->addStretch(); int nootFontSize = fontMetrics().boundingRect("A").height() * 2; QString nooColor = QString("color: %1").arg(palette().highlight().color().name()); m_tableWdg = new QWidget(this); QHBoxLayout *tabLay = new QHBoxLayout; tabLay->addWidget(m_tableWdg); QGridLayout *qaLay = new QGridLayout(); // Questions & Answers table qaLay->setAlignment(Qt::AlignCenter); qaLay->setSpacing(10); // Labels describing answers types QFont f = font(); f.setBold(true); QLabel *newQuestLab = new QLabel(TquestionAsWdg::answerTxt().toUpper(), this); newQuestLab->setFont(f); qaLay->addWidget(newQuestLab, 0, 2, 0, 4, Qt::AlignHCenter | Qt::AlignTop); m_questLab = new QLabel(TnooFont::span("n", nootFontSize * 1.5, nooColor) + "<br><br>" + TquestionAsWdg::questionTxt().toUpper(), this); m_questLab->setAlignment(Qt::AlignCenter); m_questLab->setFont(f); qaLay->addWidget(m_questLab, 1, 0, Qt::AlignBottom | Qt::AlignHCenter); m_answLab = new QLabel(" ", this); m_answLab->setFont(f); qaLay->addWidget(m_answLab, 1, 1, Qt::AlignBottom); QLabel *asNoteLab = new QLabel(" <br>" + TquestionAsWdg::asNoteTxt().replace(" ", "<br>"), this); asNoteLab->setAlignment(Qt::AlignCenter); qaLay->addWidget(asNoteLab, 1, 2, Qt::AlignBottom); QLabel *asNameLab = new QLabel(" <br>" + TquestionAsWdg::asNameTxt().replace(" ", "<br>"), this); asNameLab->setAlignment(Qt::AlignCenter); qaLay->addWidget(asNameLab, 1, 3, Qt::AlignBottom); m_asFretLab = new QLabel(" <br>" + TquestionAsWdg::asFretPosTxt().replace(" ", "<br>"), this); m_asFretLab->setAlignment(Qt::AlignCenter); qaLay->addWidget(m_asFretLab, 1, 4, Qt::AlignBottom); m_asSoundLab = new QLabel(" <br>" + TquestionAsWdg::asSoundTxt().replace(" ", "<br>"), this); m_asSoundLab->setAlignment(Qt::AlignCenter); qaLay->addWidget(m_asSoundLab, 1, 5, Qt::AlignBottom); // CheckBoxes with types of answers for every kind of question asNoteWdg = new TquestionAsWdg(TQAtype::e_asNote, qaLay, 2, this); asNameWdg = new TquestionAsWdg(TQAtype::e_asName, qaLay, 3, this); asFretPosWdg = new TquestionAsWdg(TQAtype::e_asFretPos, qaLay, 4, this); asSoundWdg = new TquestionAsWdg(TQAtype::e_asSound, qaLay, 5, this); // Labels on the right side of the table with symbols of types - related to questions QLabel *scoreNooLab = new QLabel("s?", this); QFont nf("nootka", fontMetrics().boundingRect("A").height()); #if defined(Q_OS_MACX) nf.setPointSize(fontMetrics().boundingRect("A").height() * 2); #elif defined (Q_OS_ANDROID) // nf.setPointSize(qMax<int>(Tmtr::fingerPixels() / 3, fontMetrics().boundingRect("A").height())); nf.setPointSize(Tmtr::fingerPixels() / 3); #endif scoreNooLab->setFont(nf); qaLay->addWidget(scoreNooLab, 2, 6, Qt::AlignCenter); QLabel *nameNooLab = new QLabel("c?", this); nameNooLab->setFont(nf); qaLay->addWidget(nameNooLab, 3, 6, Qt::AlignCenter); m_guitarNooLab = new QLabel("g?", this); m_guitarNooLab->setFont(nf); qaLay->addWidget(m_guitarNooLab, 4, 6, Qt::AlignCenter); m_soundNooLab = new QLabel("n?", this); m_soundNooLab->setFont(nf); qaLay->addWidget(m_soundNooLab, 5, 6); // Labels on the bottom side of the table with symbols of types - related to answers QLabel *qScoreNooLab = new QLabel("s!", this); qScoreNooLab->setFont(nf); qaLay->addWidget(qScoreNooLab, 6, 2, Qt::AlignCenter); QLabel *qNmeNooLab = new QLabel("c!", this); qNmeNooLab->setFont(nf); qaLay->addWidget(qNmeNooLab, 6, 3, Qt::AlignCenter); m_qGuitarNooLab = new QLabel("g!", this); m_qGuitarNooLab->setFont(nf); qaLay->addWidget(m_qGuitarNooLab, 6, 4, Qt::AlignCenter); m_qSoundNooLab = new QLabel("n!", this); m_qSoundNooLab->setFont(nf); qaLay->addWidget(m_qSoundNooLab, 6, 5); QLabel *melodyLab = new QLabel(TnooFont::span("m", nootFontSize * 2, nooColor), this); melodyLab->setAlignment(Qt::AlignCenter); melodyLab->setMaximumWidth(melodyLab->sizeHint().width()); m_playMelodyChB = new QCheckBox(TexTrans::playMelodyTxt(), this); m_playMelodyChB->setStatusTip(tableTip(TexTrans::playDescTxt(), TQAtype::e_asNote, TQAtype::e_asSound, nootFontSize)); m_writeMelodyChB = new QCheckBox(TexTrans::writeMelodyTxt(), this); m_writeMelodyChB->setStatusTip(tableTip(TexTrans::writeDescTxt(), TQAtype::e_asSound, TQAtype::e_asNote, nootFontSize)); // QCheckBox *m_repeatMelodyChB = new QCheckBox(tr("repeat melody"), this); m_melodyLengthSpin = new QSpinBox(this); // m_melodyLengthSpin->setValue(5); m_melodyLengthSpin->setMinimum(1); m_melodyLengthSpin->setMaximum(50); m_melodyLengthSpin->setStatusTip(tr("Maximum number of notes in a melody. Melody length is random value between 70% and 100% of that number.")); QLabel *lenghtLab = new QLabel(tr("Melody length"), this); lenghtLab->setStatusTip(m_melodyLengthSpin->statusTip()); m_finishOnTonicChB = new QCheckBox(tr("Melody ends on tonic note"), this); m_finishOnTonicChB->setStatusTip(tr("Determines the last note of a melody.<br>When set, melody will be finished on tonic note of actual key signature.")); m_tableWdg->setLayout(qaLay); m_paintHandler = new TpaintHandler(widget()); m_paintHandler->setLayout(tabLay); m_singleGr = new QGroupBox(tr("single note"), this); m_singleGr->setCheckable(true); QVBoxLayout *outTabLay = new QVBoxLayout; outTabLay->addWidget(m_paintHandler); outTabLay->setContentsMargins(0, 0, 0, 0); m_singleGr->setLayout(outTabLay); auto melLay = new QVBoxLayout; #if !defined (Q_OS_ANDROID) melLay->addWidget(melodyLab, 0, Qt::AlignCenter); #endif melLay->addStretch(); melLay->addWidget(m_playMelodyChB); melLay->addWidget(m_writeMelodyChB); // melLay->addWidget(m_repeatMelodyChB); melLay->addStretch(); auto lenLay= new QHBoxLayout; lenLay->addWidget(lenghtLab); lenLay->addWidget(m_melodyLengthSpin); melLay->addLayout(lenLay); #if defined (Q_OS_ANDROID) melLay->addWidget(getLabelFromStatus(m_melodyLengthSpin, true, true)); #endif melLay->addWidget(m_finishOnTonicChB); #if defined (Q_OS_ANDROID) melLay->addWidget(getLabelFromStatus(m_finishOnTonicChB, true, true)); #endif melLay->addStretch(); m_melodiesGr = new QGroupBox(tr("melodies"), this); m_melodiesGr->setCheckable(true); #if defined (Q_OS_ANDROID) auto androidMelLay = new QHBoxLayout; melodyLab->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); androidMelLay->addWidget(melodyLab); androidMelLay->addLayout(melLay); m_melodiesGr->setLayout(androidMelLay); QVBoxLayout *grBoxLay = new QVBoxLayout; #else m_melodiesGr->setLayout(melLay); auto grBoxLay = new QHBoxLayout; #endif grBoxLay->addStretch(); grBoxLay->addWidget(m_singleGr); grBoxLay->addStretch(); grBoxLay->addWidget(m_melodiesGr); grBoxLay->addStretch(); mainLay->addLayout(grBoxLay); mainLay->addStretch(); // some checkBoxes #if defined (Q_OS_ANDROID) auto chLay = new QVBoxLayout; #else auto chLay = new QGridLayout; #endif octaveRequiredChB = new QCheckBox(tr("require octave"),this); octaveRequiredChB->setStatusTip(tr("if checked, selecting of valid octave is required")); #if defined (Q_OS_ANDROID) chLay->addWidget(octaveRequiredChB, 0, Qt::AlignLeft); chLay->addWidget(getLabelFromStatus(octaveRequiredChB, true, true)); #else chLay->addWidget(octaveRequiredChB, 0, 0, Qt::AlignLeft); #endif styleRequiredChB = new QCheckBox(tr("use different naming styles"),this); styleRequiredChB->setStatusTip(tr("if checked, note names are switched between letters and solfege.")); #if defined (Q_OS_ANDROID) chLay->addWidget(styleRequiredChB, 0, Qt::AlignLeft); chLay->addWidget(getLabelFromStatus(styleRequiredChB, true, true)); #else chLay->addWidget(styleRequiredChB, 1, 0, Qt::AlignLeft); #endif showStrNrChB = new QCheckBox(tr("show string number in questions"), this); showStrNrChB->setStatusTip( tr("Shows on which string an answer has to be given.<br>Be careful, sometimes it is needed and sometimes it makes no sense.")); #if defined (Q_OS_ANDROID) chLay->addWidget(showStrNrChB, 0, Qt::AlignLeft); chLay->addWidget(getLabelFromStatus(showStrNrChB, true, true)); #else chLay->addWidget(showStrNrChB, 0, 1, Qt::AlignLeft); #endif lowPosOnlyChBox = new QCheckBox(tr("notes in the lowest position only"),this); lowPosOnlyChBox->setStatusTip(tr("if checked, the lowest position in selected fret range is required,<br>otherwise all possible positions of the note are acceptable.<br>To use this, all strings have to be available!")); #if defined (Q_OS_ANDROID) chLay->addWidget(lowPosOnlyChBox, 0, Qt::AlignLeft); chLay->addWidget(getLabelFromStatus(lowPosOnlyChBox, true, true)); #else chLay->addWidget(lowPosOnlyChBox, 1, 1, Qt::AlignLeft); #endif mainLay->addLayout(chLay); TintonationCombo *intoCombo = new TintonationCombo(this); m_intonationCombo = intoCombo->accuracyCombo; // we need only combo box (label is not necessary) mainLay->addWidget(intoCombo, 0, Qt::AlignCenter); #if defined (Q_OS_ANDROID) // add space at the bottom to allow touching lower boxes and combo mainLay->addSpacing(Tmtr::fingerPixels() / 2); mainLay->setContentsMargins(0, 10, 0, 10); #endif setLayout(mainLay); connect(m_singleGr, SIGNAL(clicked()), this, SLOT(singleMultiSlot())); connect(m_melodiesGr, SIGNAL(clicked()), this, SLOT(singleMultiSlot())); connect(m_playMelodyChB, SIGNAL(clicked()), this, SLOT(melodyQuestionSlot())); connect(m_writeMelodyChB, SIGNAL(clicked()), this, SLOT(melodyQuestionSlot())); connect(asNoteWdg, SIGNAL(answerStateChanged()), this, SLOT(whenParamsChanged())); connect(asNameWdg, SIGNAL(answerStateChanged()), this, SLOT(whenParamsChanged())); connect(asFretPosWdg, SIGNAL(answerStateChanged()), this, SLOT(whenParamsChanged())); connect(asSoundWdg, SIGNAL(answerStateChanged()), this, SLOT(whenParamsChanged())); connect(octaveRequiredChB , SIGNAL(clicked()), this, SLOT(whenParamsChanged())); connect(styleRequiredChB, SIGNAL(clicked()), this, SLOT(whenParamsChanged())); connect(showStrNrChB, SIGNAL(clicked()), this, SLOT(whenParamsChanged())); connect(lowPosOnlyChBox, SIGNAL(clicked()), this, SLOT(whenParamsChanged())); connect(m_intonationCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(whenParamsChanged())); connect(m_playMelodyChB, SIGNAL(clicked()), this, SLOT(whenParamsChanged())); connect(m_writeMelodyChB, SIGNAL(clicked()), this, SLOT(whenParamsChanged())); connect(m_melodyLengthSpin, SIGNAL(valueChanged(int)), this, SLOT(whenParamsChanged())); connect(m_paintHandler, &TpaintHandler::paintMe, this, &questionsSettings::paintSlot); }
double gustafson_improved(double p, double n, double r, double mtbf) { return (1 - p) + (p * (n - nf(r, mtbf))); }
String QualifyKey(const CppBase& base, const String& scope, const String& type, const String& usings) { ScopeInfo nf(base, scope); return QualifyIds(nf, type, usings, false); }
// These transformations should never increase the size of the DAG. ASTNode STP::sizeReducing(ASTNode simplified_solved_InputToSAT, BVSolver* bvSolver) { simplified_solved_InputToSAT = simp->CreateSubstitutionMap(simplified_solved_InputToSAT, arrayTransformer); if (simp->hasUnappliedSubstitutions()) { simplified_solved_InputToSAT = simp->applySubstitutionMap(simplified_solved_InputToSAT); simp->haveAppliedSubstitutionMap(); bm->ASTNodeStats("After Propagating Equalities: ", simplified_solved_InputToSAT); } if (bm->UserFlags.isSet("enable-unconstrained", "1")) { // Remove unconstrained. RemoveUnconstrained r1(*bm); simplified_solved_InputToSAT = r1.topLevel(simplified_solved_InputToSAT, simp); bm->ASTNodeStats("After Removing Unconstrained: ", simplified_solved_InputToSAT); } if (bm->UserFlags.isSet("use-intervals", "1")) { EstablishIntervals intervals(*bm); simplified_solved_InputToSAT = intervals.topLevel_unsignedIntervals(simplified_solved_InputToSAT); bm->ASTNodeStats("After Establishing Intervals: ", simplified_solved_InputToSAT); } if (bm->UserFlags.bitConstantProp_flag) { bm->GetRunTimes()->start(RunTimes::ConstantBitPropagation); SimplifyingNodeFactory nf(*(bm->hashingNodeFactory), *bm); simplifier::constantBitP::ConstantBitPropagation cb(simp, &nf, simplified_solved_InputToSAT); simplified_solved_InputToSAT = cb.topLevelBothWays(simplified_solved_InputToSAT, true,false); bm->GetRunTimes()->stop(RunTimes::ConstantBitPropagation); if (cb.isUnsatisfiable()) simplified_solved_InputToSAT = bm->ASTFalse; if (simp->hasUnappliedSubstitutions()) { simplified_solved_InputToSAT = simp->applySubstitutionMap(simplified_solved_InputToSAT); simp->haveAppliedSubstitutionMap(); } bm->ASTNodeStats("After Constant Bit Propagation: ", simplified_solved_InputToSAT); } // Find pure literals. if (bm->UserFlags.isSet("pure-literals", "1")) { FindPureLiterals fpl; bool changed = fpl.topLevel(simplified_solved_InputToSAT, simp, bm); if (changed) { simplified_solved_InputToSAT = simp->applySubstitutionMap(simplified_solved_InputToSAT); simp->haveAppliedSubstitutionMap(); bm->ASTNodeStats("After Pure Literals: ", simplified_solved_InputToSAT); } } if (bm->UserFlags.isSet("always-true", "0")) { SimplifyingNodeFactory nf(*(bm->hashingNodeFactory), *bm); AlwaysTrue always (simp,bm,&nf); simplified_solved_InputToSAT = always.topLevel(simplified_solved_InputToSAT); bm->ASTNodeStats("After removing always true: ", simplified_solved_InputToSAT); } if (bm->UserFlags.wordlevel_solve_flag && bm->UserFlags.optimize_flag) { simplified_solved_InputToSAT = bvSolver->TopLevelBVSolve(simplified_solved_InputToSAT, false); bm->ASTNodeStats("after solving: ", simplified_solved_InputToSAT); } return simplified_solved_InputToSAT; }
//Acceps a query, calls the SAT solver and generates Valid/InValid. //if returned 0 then input is INVALID if returned 1 then input is //VALID if returned 2 then UNDECIDED SOLVER_RETURN_TYPE STP::TopLevelSTPAux(SATSolver& NewSolver, const ASTNode& original_input) { bm->ASTNodeStats("input asserts and query: ", original_input); DifficultyScore difficulty; if (bm->UserFlags.stats_flag) cerr << "Difficulty Initially:" << difficulty.score(original_input) << endl; // A heap object so I can easily control its lifetime. std::auto_ptr<BVSolver> bvSolver(new BVSolver(bm, simp)); std::auto_ptr<PropagateEqualities> pe (new PropagateEqualities(simp,bm->defaultNodeFactory,bm)); ASTNode simplified_solved_InputToSAT = original_input; // If the number of array reads is small. We rewrite them through. // The bit-vector simplifications are more thorough than the array simplifications. For example, // we don't currently do unconstrained elimination on arrays--- but we do for bit-vectors. // A better way to do this would be to estimate the number of axioms introduced. // TODO: I chose the number of reads we perform this operation at randomly. bool removed = false; if (((bm->UserFlags.ackermannisation && numberOfReadsLessThan(simplified_solved_InputToSAT,50)) || bm->UserFlags.isSet("upfront-ack", "0")) || numberOfReadsLessThan(simplified_solved_InputToSAT,10) ) { // If the number of axioms that would be added it small. Remove them. bm->UserFlags.ackermannisation = true; simplified_solved_InputToSAT = arrayTransformer->TransformFormula_TopLevel(simplified_solved_InputToSAT); if (bm->UserFlags.stats_flag) cerr << "Have removed array operations" << endl; removed = true; } const bool arrayops = containsArrayOps(simplified_solved_InputToSAT); if (removed) assert(!arrayops); // Run size reducing just once. simplified_solved_InputToSAT = sizeReducing(simplified_solved_InputToSAT, bvSolver.get(),pe.get()); unsigned initial_difficulty_score = difficulty.score(simplified_solved_InputToSAT); int bitblasted_difficulty = -1; // Fixed point it if it's not too difficult. // Currently we discards all the state each time sizeReducing is called, // so it's expensive to call. if ((!arrayops && initial_difficulty_score < 1000000) || bm->UserFlags.isSet("preserving-fixedpoint", "0")) simplified_solved_InputToSAT = callSizeReducing(simplified_solved_InputToSAT, bvSolver.get(),pe.get(), initial_difficulty_score, bitblasted_difficulty); if ((!arrayops || bm->UserFlags.isSet("array-difficulty-reversion", "1"))) { initial_difficulty_score = difficulty.score(simplified_solved_InputToSAT); } if (bitblasted_difficulty != -1 && bm->UserFlags.stats_flag) std::cout << "Initial Bitblasted size:" << bitblasted_difficulty << endl; if (bm->UserFlags.stats_flag) std::cout << "Difficulty After Size reducing:" << initial_difficulty_score << endl; // So we can delete the object and release all the hash-buckets storage. std::auto_ptr<Revert_to> revert(new Revert_to()); if ((!arrayops || bm->UserFlags.isSet("array-difficulty-reversion", "1"))) { revert->initialSolverMap.insert(simp->Return_SolverMap()->begin(), simp->Return_SolverMap()->end()); revert->backup_arrayToIndexToRead.insert(arrayTransformer->arrayToIndexToRead.begin(),arrayTransformer->arrayToIndexToRead.end()); revert->toRevertTo = simplified_solved_InputToSAT; } ASTNode inputToSAT; //round of substitution, solving, and simplification. ensures that //DAG is minimized as much as possibly, and ideally should //garuntee that all liketerms in BVPLUSes have been combined. bm->SimplifyWrites_InPlace_Flag = false; //bm->Begin_RemoveWrites = false; //bm->start_abstracting = false; bm->TermsAlreadySeenMap_Clear(); do { inputToSAT = simplified_solved_InputToSAT; if (bm->soft_timeout_expired) return SOLVER_TIMEOUT; if (bm->UserFlags.optimize_flag) { simplified_solved_InputToSAT = pe->topLevel(simplified_solved_InputToSAT, arrayTransformer); // Imagine: // The simplifier simplifies (0 + T) to T // Then bvsolve introduces (0 + T) // Then CreateSubstitutionMap decides T maps to a constant, but leaving another (0+T). // When we go to simplify (0 + T) will still be in the simplify cache, so will be mapped to T. // But it shouldn't be T, it should be a constant. // Applying the substitution map fixes this case. // if (simp->hasUnappliedSubstitutions()) { simplified_solved_InputToSAT = simp->applySubstitutionMap(simplified_solved_InputToSAT); simp->haveAppliedSubstitutionMap(); } bm->ASTNodeStats(pe_message.c_str(), simplified_solved_InputToSAT); simplified_solved_InputToSAT = simp->SimplifyFormula_TopLevel(simplified_solved_InputToSAT, false); bm->ASTNodeStats(size_inc_message.c_str(), simplified_solved_InputToSAT); } if (bm->UserFlags.wordlevel_solve_flag && bm->UserFlags.optimize_flag) { simplified_solved_InputToSAT = bvSolver->TopLevelBVSolve(simplified_solved_InputToSAT); bm->ASTNodeStats(bitvec_message.c_str(), simplified_solved_InputToSAT); } } while (inputToSAT != simplified_solved_InputToSAT); if (bm->UserFlags.bitConstantProp_flag) { bm->GetRunTimes()->start(RunTimes::ConstantBitPropagation); simplifier::constantBitP::ConstantBitPropagation cb(simp, bm->defaultNodeFactory, simplified_solved_InputToSAT); simplified_solved_InputToSAT = cb.topLevelBothWays(simplified_solved_InputToSAT); bm->GetRunTimes()->stop(RunTimes::ConstantBitPropagation); if (cb.isUnsatisfiable()) simplified_solved_InputToSAT = bm->ASTFalse; bm->ASTNodeStats(cb_message.c_str(), simplified_solved_InputToSAT); } if (bm->UserFlags.isSet("use-intervals", "1")) { EstablishIntervals intervals(*bm); simplified_solved_InputToSAT = intervals.topLevel_unsignedIntervals(simplified_solved_InputToSAT); bm->ASTNodeStats(int_message.c_str(), simplified_solved_InputToSAT); } // Find pure literals. if (bm->UserFlags.isSet("pure-literals", "1")) { FindPureLiterals fpl; bool changed = fpl.topLevel(simplified_solved_InputToSAT, simp, bm); if (changed) { simplified_solved_InputToSAT = simp->applySubstitutionMap(simplified_solved_InputToSAT); simp->haveAppliedSubstitutionMap(); bm->ASTNodeStats(pl_message.c_str(), simplified_solved_InputToSAT); } } if (bm->soft_timeout_expired) return SOLVER_TIMEOUT; // Simplify using Ite context if (bm->UserFlags.optimize_flag && bm->UserFlags.isSet("ite-context", "0")) { UseITEContext iteC(bm); simplified_solved_InputToSAT = iteC.topLevel(simplified_solved_InputToSAT); bm->ASTNodeStats("After ITE Context: ", simplified_solved_InputToSAT); } if (bm->UserFlags.isSet("aig-core-simplify", "0")) { AIGSimplifyPropositionalCore aigRR(bm); simplified_solved_InputToSAT = aigRR.topLevel(simplified_solved_InputToSAT); bm->ASTNodeStats("After AIG Core: ", simplified_solved_InputToSAT); } #if 0 bm->ASTNodeStats("Before SimplifyWrites_Inplace begins: ", simplified_solved_InputToSAT); bm->SimplifyWrites_InPlace_Flag = true; bm->Begin_RemoveWrites = false; bm->start_abstracting = false; bm->TermsAlreadySeenMap_Clear(); do { inputToSAT = simplified_solved_InputToSAT; if (bm->UserFlags.optimize_flag) { simplified_solved_InputToSAT = pe->topLevel(simplified_solved_InputToSAT, arrayTransformer); if (simp->hasUnappliedSubstitutions()) { simplified_solved_InputToSAT = simp->applySubstitutionMap(simplified_solved_InputToSAT); simp->haveAppliedSubstitutionMap(); } bm->ASTNodeStats(pe->message.c_str(), simplified_solved_InputToSAT); simplified_solved_InputToSAT = simp->SimplifyFormula_TopLevel(simplified_solved_InputToSAT, false); bm->ASTNodeStats("after simplification: ", simplified_solved_InputToSAT); if (bm->UserFlags.isSet("always-true", "0")) { SimplifyingNodeFactory nf(*(bm->hashingNodeFactory), *bm); AlwaysTrue always (simp,bm,&nf); simplified_solved_InputToSAT = always.topLevel(simplified_solved_InputToSAT); bm->ASTNodeStats("After removing always true: ", simplified_solved_InputToSAT); } } // The word level solver uses the simplifier to apply the rewrites it makes, // without optimisations enabled. It will enter infinite loops on some input. // Instead it could use the apply function of the substitution map, but it // doesn't yet... if (bm->UserFlags.wordlevel_solve_flag && bm->UserFlags.optimize_flag) { simplified_solved_InputToSAT = bvSolver->TopLevelBVSolve(simplified_solved_InputToSAT); bm->ASTNodeStats("after solving: ", simplified_solved_InputToSAT); } } while (inputToSAT != simplified_solved_InputToSAT); bm->ASTNodeStats("After SimplifyWrites_Inplace: ", simplified_solved_InputToSAT); #endif if (bm->UserFlags.isSet("enable-unconstrained", "1")) { // Remove unconstrained. RemoveUnconstrained r(*bm); simplified_solved_InputToSAT = r.topLevel(simplified_solved_InputToSAT, simp); bm->ASTNodeStats(uc_message.c_str(), simplified_solved_InputToSAT); } bm->TermsAlreadySeenMap_Clear(); //bm->start_abstracting = false; bm->SimplifyWrites_InPlace_Flag = false; //bm->Begin_RemoveWrites = false; long final_difficulty_score = difficulty.score(simplified_solved_InputToSAT); bool worse= false; if (final_difficulty_score > 1.1 * initial_difficulty_score) worse = true; // It's of course very wasteful to do this! Later I'll make it reuse the work.. // We bit-blast again, in order to throw it away, so that we can measure whether // the number of AIG nodes is smaller. The difficulty score is sometimes completely // wrong, the sage-app7 are the motivating examples. The other way to improve it would // be to fix the difficulty scorer! if (!worse && (bitblasted_difficulty != -1)) { BBNodeManagerAIG bbnm; BitBlaster<BBNodeAIG, BBNodeManagerAIG> bb(&bbnm, simp, bm->defaultNodeFactory , &(bm->UserFlags)); bb.BBForm(simplified_solved_InputToSAT); int newBB= bbnm.totalNumberOfNodes(); if (bm->UserFlags.stats_flag) cerr << "Final BB Size:" << newBB << endl; if (bitblasted_difficulty < newBB) worse = true; } if (bm->UserFlags.stats_flag) { cerr << "Initial Difficulty Score:" << initial_difficulty_score << endl; cerr << "Final Difficulty Score:" << final_difficulty_score << endl; } bool optimize_enabled = bm->UserFlags.optimize_flag; if (worse && (!arrayops || bm->UserFlags.isSet("array-difficulty-reversion", "1")) && bm->UserFlags.isSet("difficulty-reversion", "1")) { // If the simplified problem is harder, than the // initial problem we revert back to the initial // problem. if (bm->UserFlags.stats_flag) cerr << "simplification made the problem harder, reverting." << endl; simplified_solved_InputToSAT = revert->toRevertTo; // I do this to clear the substitution/solver map. // Not sure what would happen if it contained simplifications // that haven't been applied. simp->ClearAllTables(); simp->Return_SolverMap()->insert(revert->initialSolverMap.begin(), revert->initialSolverMap.end()); revert->initialSolverMap.clear(); // Copy back what we knew about arrays at the start.. arrayTransformer->arrayToIndexToRead.clear(); arrayTransformer->arrayToIndexToRead.insert(revert->backup_arrayToIndexToRead.begin(), revert->backup_arrayToIndexToRead.end()); // The arrayTransformer calls simplify. We don't want // it to put back in all the bad simplifications. bm->UserFlags.optimize_flag = false; } revert.reset(NULL); simplified_solved_InputToSAT = arrayTransformer->TransformFormula_TopLevel(simplified_solved_InputToSAT); bm->ASTNodeStats("after transformation: ", simplified_solved_InputToSAT); bm->TermsAlreadySeenMap_Clear(); bm->UserFlags.optimize_flag = optimize_enabled; SOLVER_RETURN_TYPE res; if (!bm->UserFlags.ackermannisation) { bm->counterexample_checking_during_refinement = true; } // We are about to solve. Clear out all the memory associated with caches // that we won't need again. simp->ClearCaches(); simp->haveAppliedSubstitutionMap(); bm->ClearAllTables(); // Deleting it clears out all the buckets associated with hashmaps etc. too. bvSolver.reset(NULL); pe.reset(NULL); if (bm->UserFlags.stats_flag) simp->printCacheStatus(); const bool maybeRefinement = arrayops && !bm->UserFlags.ackermannisation; simplifier::constantBitP::ConstantBitPropagation* cb = NULL; std::auto_ptr<simplifier::constantBitP::ConstantBitPropagation> cleaner; if (bm->UserFlags.bitConstantProp_flag) { bm->GetRunTimes()->start(RunTimes::ConstantBitPropagation); cb = new simplifier::constantBitP::ConstantBitPropagation(simp, bm->defaultNodeFactory, simplified_solved_InputToSAT); cleaner.reset(cb); bm->GetRunTimes()->stop(RunTimes::ConstantBitPropagation); bm->ASTNodeStats(cb_message.c_str(), simplified_solved_InputToSAT); if (cb->isUnsatisfiable()) simplified_solved_InputToSAT = bm->ASTFalse; } ToSATAIG toSATAIG(bm, cb, arrayTransformer); ToSATBase* satBase = bm->UserFlags.isSet("traditional-cnf", "0") ? tosat : &toSATAIG; if (bm->soft_timeout_expired) return SOLVER_TIMEOUT; // If it doesn't contain array operations, use ABC's CNF generation. res = Ctr_Example->CallSAT_ResultCheck(NewSolver, simplified_solved_InputToSAT, original_input, satBase, maybeRefinement); if (bm->soft_timeout_expired) { if (toSATAIG.cbIsDestructed()) cleaner.release(); return SOLVER_TIMEOUT; } if (SOLVER_UNDECIDED != res) { // If the aig converter knows that it is never going to be called again, // it deletes the constant bit stuff before calling the SAT solver. if (toSATAIG.cbIsDestructed()) cleaner.release(); CountersAndStats("print_func_stats", bm); return res; } assert(arrayops); // should only go to abstraction refinement if there are array ops. assert(!bm->UserFlags.ackermannisation); // Refinement must be enabled too. assert (bm->UserFlags.solver_to_use != UserDefinedFlags::MINISAT_PROPAGATORS); // The array solver shouldn't have returned undecided.. res = Ctr_Example->SATBased_ArrayReadRefinement(NewSolver, simplified_solved_InputToSAT, original_input, satBase); if (SOLVER_UNDECIDED != res) { if (toSATAIG.cbIsDestructed()) cleaner.release(); CountersAndStats("print_func_stats", bm); return res; } #if 0 res = Ctr_Example->SATBased_ArrayWriteRefinement(NewSolver, original_input, satBase); if (SOLVER_UNDECIDED != res) { if (toSATAIG.cbIsDestructed()) cleaner.release(); CountersAndStats("print_func_stats", bm); return res; } res = Ctr_Example->SATBased_ArrayReadRefinement(NewSolver, simplified_solved_InputToSAT, original_input, satBase); if (SOLVER_UNDECIDED != res) { if (toSATAIG.cbIsDestructed()) cleaner.release(); CountersAndStats("print_func_stats", bm); return res; } #endif FatalError("TopLevelSTPAux: reached the end without proper conclusion:" "either a divide by zero in the input or a bug in STP"); //bogus return to make the compiler shut up return SOLVER_ERROR; } //End of TopLevelSTPAux
void Module_DMAP::execute(const Options & options) { clock_t started = clock(); processed = 0; initialize_parameters(options); my_rank = MPI::COMM_WORLD.Get_rank(); nprocs = MPI::COMM_WORLD.Get_size(); proc_name = new char[MPI_MAX_PROCESSOR_NAME]; int resultlen; MPI::Get_processor_name(proc_name, resultlen); // Check for the correct number of files if (my_rank == 0) { stringstream filename_numberfile; filename_numberfile << options.reference_file << "_n.dht"; ifstream nf(filename_numberfile.str().c_str()); if (nf.fail()) { ERROR_CHANNEL << "File " << filename_numberfile.str() << " not found! Check the reference name!" << endl; exit(5); } string s; getline(nf,s); int n_files = -1; n_files = atoi(s.c_str()); DEFAULT_CHANNEL << "Number of rNA files in the set: " << s << endl; if (n_files != nprocs) { ERROR_CHANNEL << "Wrong number of files: expected " << nprocs << " files but the data structure was built for " << n_files << " processes!" << endl; exit(5); } else { DEFAULT_CHANNEL << '[' << my_rank << "] Found " << n_files << '/' << nprocs << " files" << endl; } } if (my_rank == 0) DEFAULT_CHANNEL << '[' << my_rank << "] Reading process started on machine " << proc_name << endl; else if (my_rank == nprocs-1) DEFAULT_CHANNEL << '[' << my_rank << "] Writing process started on machine " << proc_name << endl; else DEFAULT_CHANNEL << '[' << my_rank << "] Slave process " << my_rank << "/" << (nprocs-1) << " started on machine " << proc_name << endl; execute_generic_worker(options); if (my_rank == 0) DEFAULT_CHANNEL << '[' << my_rank << "] Reading process waiting for finalize on " << proc_name << endl; else if (my_rank == nprocs-1) DEFAULT_CHANNEL << '[' << my_rank << "] Writing process waiting for finalize on " << proc_name << endl; else DEFAULT_CHANNEL << '[' << my_rank << "] Slave process " << my_rank << "/" << (nprocs-1) << " waiting for finalize on " << proc_name << endl; MPI::Finalize(); if (my_rank == 0) { clock_t finished = clock(); double dif = (finished - started) / (double)CLOCKS_PER_SEC; DEFAULT_CHANNEL << "Time spent: " << dif << "s ("; print_formatted_time(DEFAULT_CHANNEL, dif); DEFAULT_CHANNEL << ')' << endl; //DEFAULT_CHANNEL << "Queries per second: " << (processed/dif) <<endl; } }
Foam::tmp<Foam::GeometricField<Type, Foam::fvsPatchField, Foam::surfaceMesh>> Foam::fv::faceCorrectedSnGrad<Type>::fullGradCorrection ( const GeometricField<Type, fvPatchField, volMesh>& vf ) const { const fvMesh& mesh = this->mesh(); GeometricField<Type, pointPatchField, pointMesh> pvf ( volPointInterpolation::New(mesh).interpolate(vf) ); // construct GeometricField<Type, fvsPatchField, surfaceMesh> tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> tsfCorr ( new GeometricField<Type, fvsPatchField, surfaceMesh> ( IOobject ( "snGradCorr("+vf.name()+')', vf.instance(), mesh, IOobject::NO_READ, IOobject::NO_WRITE ), mesh, vf.dimensions()*mesh.nonOrthDeltaCoeffs().dimensions() ) ); Field<Type>& sfCorr = tsfCorr.ref().internalField(); const pointField& points = mesh.points(); const faceList& faces = mesh.faces(); const vectorField& Sf = mesh.Sf().internalField(); const vectorField& C = mesh.C().internalField(); const scalarField& magSf = mesh.magSf().internalField(); const labelList& owner = mesh.owner(); const labelList& neighbour = mesh.neighbour(); forAll(sfCorr, facei) { typename outerProduct<vector, Type>::type fgrad ( outerProduct<vector, Type>::type::zero ); const face& fi = faces[facei]; vector nf(Sf[facei]/magSf[facei]); for (label pi=0; pi<fi.size(); pi++) { // Next point index label pj = (pi+1)%fi.size(); // Edge normal in plane of face vector edgen(nf^(points[fi[pj]] - points[fi[pi]])); // Edge centre field value Type pvfe(0.5*(pvf[fi[pj]] + pvf[fi[pi]])); // Integrate face gradient fgrad += edgen*pvfe; } // Finalize face-gradient by dividing by face area fgrad /= magSf[facei]; // Calculate correction vector vector dCorr(C[neighbour[facei]] - C[owner[facei]]); dCorr /= (nf & dCorr); // if (mag(dCorr) > 2) dCorr *= 2/mag(dCorr); sfCorr[facei] = dCorr&fgrad; }
void QualifyTypes(CppBase& base, const String& scope, CppItem& m) { ScopeInfo nf(base, scope); m.qtype = QualifyIds(nf, m.type, m.using_namespaces, true); m.qptype = QualifyIds(nf, m.ptype, m.using_namespaces, true); }
//Acceps a query, calls the SAT solver and generates Valid/InValid. //if returned 0 then input is INVALID if returned 1 then input is //VALID if returned 2 then UNDECIDED SOLVER_RETURN_TYPE STP::TopLevelSTPAux(SATSolver& NewSolver, const ASTNode& modified_input, const ASTNode& original_input) { ASTNode inputToSAT = modified_input; ASTNode orig_input = original_input; bm->ASTNodeStats("input asserts and query: ", inputToSAT); ASTNode simplified_solved_InputToSAT = inputToSAT; const bool arrayops = containsArrayOps(original_input); DifficultyScore difficulty; if (bm->UserFlags.stats_flag) cerr << "Difficulty Initially:" << difficulty.score(original_input) << endl; // A heap object so I can easily control its lifetime. BVSolver* bvSolver = new BVSolver(bm, simp); simplified_solved_InputToSAT = sizeReducing(inputToSAT, bvSolver); unsigned initial_difficulty_score = difficulty.score(simplified_solved_InputToSAT); // Fixed point it if it's not too difficult. // Currently we discards all the state each time sizeReducing is called, // so it's expensive to call. if (!arrayops && initial_difficulty_score < 1000000) { simplified_solved_InputToSAT = callSizeReducing(simplified_solved_InputToSAT, bvSolver, initial_difficulty_score); initial_difficulty_score = difficulty.score(simplified_solved_InputToSAT); } if (bm->UserFlags.stats_flag) cout << "Difficulty After Size reducing:" << initial_difficulty_score << endl; // Copy the solver map incase we need to revert. ASTNodeMap initialSolverMap; ASTNode toRevertTo; if (!arrayops) // we don't revert for Array problems yet, so don't copy it. { initialSolverMap.insert(simp->Return_SolverMap()->begin(), simp->Return_SolverMap()->end()); toRevertTo = simplified_solved_InputToSAT; } //round of substitution, solving, and simplification. ensures that //DAG is minimized as much as possibly, and ideally should //garuntee that all liketerms in BVPLUSes have been combined. bm->SimplifyWrites_InPlace_Flag = false; bm->Begin_RemoveWrites = false; bm->start_abstracting = false; bm->TermsAlreadySeenMap_Clear(); do { inputToSAT = simplified_solved_InputToSAT; if (bm->UserFlags.optimize_flag) { simplified_solved_InputToSAT = simp->CreateSubstitutionMap(simplified_solved_InputToSAT, arrayTransformer); // Imagine: // The simplifier simplifies (0 + T) to T // Then bvsolve introduces (0 + T) // Then CreateSubstitutionMap decides T maps to a constant, but leaving another (0+T). // When we go to simplify (0 + T) will still be in the simplify cache, so will be mapped to T. // But it shouldn't be T, it should be a constant. // Applying the substitution map fixes this case. // if (simp->hasUnappliedSubstitutions()) { simplified_solved_InputToSAT = simp->applySubstitutionMap(simplified_solved_InputToSAT); simp->haveAppliedSubstitutionMap(); } bm->ASTNodeStats("after pure substitution: ", simplified_solved_InputToSAT); simplified_solved_InputToSAT = simp->SimplifyFormula_TopLevel(simplified_solved_InputToSAT, false); bm->ASTNodeStats("after simplification: ", simplified_solved_InputToSAT); } if (bm->UserFlags.wordlevel_solve_flag && bm->UserFlags.optimize_flag) { simplified_solved_InputToSAT = bvSolver->TopLevelBVSolve(simplified_solved_InputToSAT); bm->ASTNodeStats("after solving: ", simplified_solved_InputToSAT); } } while (inputToSAT != simplified_solved_InputToSAT); if (bm->UserFlags.bitConstantProp_flag) { bm->GetRunTimes()->start(RunTimes::ConstantBitPropagation); SimplifyingNodeFactory nf(*(bm->hashingNodeFactory), *bm); simplifier::constantBitP::ConstantBitPropagation cb(simp, &nf, simplified_solved_InputToSAT); simplified_solved_InputToSAT = cb.topLevelBothWays(simplified_solved_InputToSAT); bm->GetRunTimes()->stop(RunTimes::ConstantBitPropagation); if (cb.isUnsatisfiable()) simplified_solved_InputToSAT = bm->ASTFalse; bm->ASTNodeStats("After Constant Bit Propagation begins: ", simplified_solved_InputToSAT); } if (bm->UserFlags.isSet("use-intervals", "1")) { EstablishIntervals intervals(*bm); simplified_solved_InputToSAT = intervals.topLevel_unsignedIntervals(simplified_solved_InputToSAT); bm->ASTNodeStats("After Establishing Intervals: ", simplified_solved_InputToSAT); } // Find pure literals. if (bm->UserFlags.isSet("pure-literals", "1")) { FindPureLiterals fpl; bool changed = fpl.topLevel(simplified_solved_InputToSAT, simp, bm); if (changed) { simplified_solved_InputToSAT = simp->applySubstitutionMap(simplified_solved_InputToSAT); simp->haveAppliedSubstitutionMap(); bm->ASTNodeStats("After Pure Literals: ", simplified_solved_InputToSAT); } } // Simplify using Ite context if (bm->UserFlags.optimize_flag && bm->UserFlags.isSet("ite-context", "0")) { UseITEContext iteC(bm); simplified_solved_InputToSAT = iteC.topLevel(simplified_solved_InputToSAT); bm->ASTNodeStats("After ITE Context: ", simplified_solved_InputToSAT); } if (bm->UserFlags.isSet("aig-core-simplify", "0")) { AIGSimplifyPropositionalCore aigRR(bm); simplified_solved_InputToSAT = aigRR.topLevel(simplified_solved_InputToSAT); bm->ASTNodeStats("After AIG Core: ", simplified_solved_InputToSAT); } bm->ASTNodeStats("Before SimplifyWrites_Inplace begins: ", simplified_solved_InputToSAT); bm->SimplifyWrites_InPlace_Flag = true; bm->Begin_RemoveWrites = false; bm->start_abstracting = false; bm->TermsAlreadySeenMap_Clear(); do { inputToSAT = simplified_solved_InputToSAT; if (bm->UserFlags.optimize_flag) { simplified_solved_InputToSAT = simp->CreateSubstitutionMap(simplified_solved_InputToSAT, arrayTransformer); if (simp->hasUnappliedSubstitutions()) { simplified_solved_InputToSAT = simp->applySubstitutionMap(simplified_solved_InputToSAT); simp->haveAppliedSubstitutionMap(); } bm->ASTNodeStats("after pure substitution: ", simplified_solved_InputToSAT); simplified_solved_InputToSAT = simp->SimplifyFormula_TopLevel(simplified_solved_InputToSAT, false); bm->ASTNodeStats("after simplification: ", simplified_solved_InputToSAT); if (bm->UserFlags.isSet("always-true", "0")) { SimplifyingNodeFactory nf(*(bm->hashingNodeFactory), *bm); AlwaysTrue always (simp,bm,&nf); simplified_solved_InputToSAT = always.topLevel(simplified_solved_InputToSAT); bm->ASTNodeStats("After removing always true: ", simplified_solved_InputToSAT); } } // The word level solver uses the simplifier to apply the rewrites it makes, // without optimisations enabled. It will enter infinite loops on some input. // Instead it could use the apply function of the substitution map, but it // doesn't yet... if (bm->UserFlags.wordlevel_solve_flag && bm->UserFlags.optimize_flag) { simplified_solved_InputToSAT = bvSolver->TopLevelBVSolve(simplified_solved_InputToSAT); bm->ASTNodeStats("after solving: ", simplified_solved_InputToSAT); } } while (inputToSAT != simplified_solved_InputToSAT); bm->ASTNodeStats("After SimplifyWrites_Inplace: ", simplified_solved_InputToSAT); if (bm->UserFlags.isSet("enable-unconstrained", "1")) { // Remove unconstrained. RemoveUnconstrained r(*bm); simplified_solved_InputToSAT = r.topLevel(simplified_solved_InputToSAT, simp); bm->ASTNodeStats("After Unconstrained Remove begins: ", simplified_solved_InputToSAT); } bm->TermsAlreadySeenMap_Clear(); bm->start_abstracting = false; bm->SimplifyWrites_InPlace_Flag = false; bm->Begin_RemoveWrites = false; long final_difficulty_score = difficulty.score(simplified_solved_InputToSAT); if (bm->UserFlags.stats_flag) { cerr << "Initial Difficulty Score:" << initial_difficulty_score << endl; cerr << "Final Difficulty Score:" << final_difficulty_score << endl; } bool optimize_enabled = bm->UserFlags.optimize_flag; if (final_difficulty_score > 1.1 * initial_difficulty_score && !arrayops && bm->UserFlags.isSet( "difficulty-reversion", "1")) { // If the simplified problem is harder, than the // initial problem we revert back to the initial // problem. if (bm->UserFlags.stats_flag) cerr << "simplification made the problem harder, reverting." << endl; simplified_solved_InputToSAT = toRevertTo; // I do this to clear the substitution/solver map. // Not sure what would happen if it contained simplifications // that haven't been applied. simp->ClearAllTables(); simp->Return_SolverMap()->insert(initialSolverMap.begin(), initialSolverMap.end()); initialSolverMap.clear(); // The arrayTransformer calls simplify. We don't want // it to put back in all the bad simplifications. bm->UserFlags.optimize_flag = false; } simplified_solved_InputToSAT = arrayTransformer->TransformFormula_TopLevel(simplified_solved_InputToSAT); bm->ASTNodeStats("after transformation: ", simplified_solved_InputToSAT); bm->TermsAlreadySeenMap_Clear(); bm->UserFlags.optimize_flag = optimize_enabled; SOLVER_RETURN_TYPE res; if (bm->UserFlags.arrayread_refinement_flag) { bm->counterexample_checking_during_refinement = true; } // We are about to solve. Clear out all the memory associated with caches // that we won't need again. simp->ClearCaches(); simp->haveAppliedSubstitutionMap(); bm->ClearAllTables(); // Deleting it clears out all the buckets associated with hashmaps etc. too. delete bvSolver; bvSolver = NULL; if (bm->UserFlags.stats_flag) simp->printCacheStatus(); const bool maybeRefinement = arrayops && bm->UserFlags.arrayread_refinement_flag; simplifier::constantBitP::ConstantBitPropagation* cb = NULL; std::auto_ptr<simplifier::constantBitP::ConstantBitPropagation> cleaner; if (bm->UserFlags.bitConstantProp_flag) { bm->ASTNodeStats("Before Constant Bit Propagation begins: ", simplified_solved_InputToSAT); bm->GetRunTimes()->start(RunTimes::ConstantBitPropagation); cb = new simplifier::constantBitP::ConstantBitPropagation(simp, bm->defaultNodeFactory, simplified_solved_InputToSAT); cleaner.reset(cb); bm->GetRunTimes()->stop(RunTimes::ConstantBitPropagation); if (cb->isUnsatisfiable()) simplified_solved_InputToSAT = bm->ASTFalse; } ToSATAIG toSATAIG(bm, cb); toSATAIG.setArrayTransformer(arrayTransformer); ToSATBase* satBase = bm->UserFlags.isSet("traditional-cnf", "0") ? tosat : ((ToSAT*) &toSATAIG) ; // If it doesn't contain array operations, use ABC's CNF generation. res = Ctr_Example->CallSAT_ResultCheck(NewSolver, simplified_solved_InputToSAT, orig_input, satBase, maybeRefinement); if (SOLVER_UNDECIDED != res) { // If the aig converter knows that it is never going to be called again, // it deletes the constant bit stuff before calling the SAT solver. if (toSATAIG.cbIsDestructed()) cleaner.release(); CountersAndStats("print_func_stats", bm); return res; } assert(arrayops); // should only go to abstraction refinement if there are array ops. assert(bm->UserFlags.arrayread_refinement_flag); // Refinement must be enabled too. // Unfortunately how I implemented the incremental CNF generator in ABC means that // cryptominisat and simplifying minisat may simplify away variables that we later need. res = Ctr_Example->SATBased_ArrayReadRefinement(NewSolver, simplified_solved_InputToSAT, orig_input, satBase); if (SOLVER_UNDECIDED != res) { if (toSATAIG.cbIsDestructed()) cleaner.release(); CountersAndStats("print_func_stats", bm); return res; } res = Ctr_Example->SATBased_ArrayWriteRefinement(NewSolver, orig_input, satBase); if (SOLVER_UNDECIDED != res) { if (toSATAIG.cbIsDestructed()) cleaner.release(); CountersAndStats("print_func_stats", bm); return res; } res = Ctr_Example->SATBased_ArrayReadRefinement(NewSolver, simplified_solved_InputToSAT, orig_input, satBase); if (SOLVER_UNDECIDED != res) { if (toSATAIG.cbIsDestructed()) cleaner.release(); CountersAndStats("print_func_stats", bm); return res; } // if (!bm->UserFlags.num_absrefine_flag) { FatalError("TopLevelSTPAux: reached the end without proper conclusion:" "either a divide by zero in the input or a bug in STP"); //bogus return to make the compiler shut up return SOLVER_ERROR; } // else { // return res; } } //End of TopLevelSTPAux