bool debugUpdatedBasic(const UpdateInfo& selected, ArithVar updated){ if(selected.describesPivot() && updated == selected.leaving()){ return selected.foundConflict(); }else{ return true; } }
WitnessImprovement FCSimplexDecisionProcedure::primalImproveError(ArithVar errorVar){ bool useBlands = degeneratePivotsInARow() >= s_maxDegeneratePivotsBeforeBlandsOnLeaving; UpdateInfo selected = selectUpdateForPrimal (errorVar, useBlands); Assert(!selected.uninitialized()); WitnessImprovement w = selected.getWitness(useBlands); Assert(debugCheckWitness(selected, w, useBlands)); updateAndSignal(selected, w); logPivot(w); return w; }
void PassiveUpdateNotifier::versionInfoArrived(const UpdateInfo &info) { if( info.version().isEmpty() || Helper::stringVersionToInt(info.version()) >= Helper::currentVersionToInt() ) { qDebug() << "Client is on latest version!"; setDownloadState(UpToDate); } else { setDownloadState(UpdateOnlyAvailableThroughSystem); } }
void PassiveUpdateNotifier::versionInfoArrived(const UpdateInfo &info) { qint64 currentVer = Helper::currentVersionToInt(); qint64 remoteVer = Helper::stringVersionToInt(info.version()); if (info.version().isEmpty() || currentVer >= remoteVer) { qCInfo(lcUpdater) << "Client is on latest version!"; setDownloadState(UpToDate); } else { setDownloadState(UpdateOnlyAvailableThroughSystem); } }
bool FCSimplexDecisionProcedure::debugCheckWitness(const UpdateInfo& inf, WitnessImprovement w, bool useBlands){ if(inf.getWitness(useBlands) == w){ switch(w){ case ConflictFound: return inf.foundConflict(); case ErrorDropped: return inf.errorsChange() < 0; case FocusImproved: return inf.focusDirection() > 0; case FocusShrank: return false; // This is not a valid output case Degenerate: return false; // This is not a valid output case BlandsDegenerate: return useBlands; case HeuristicDegenerate: return !useBlands; case AntiProductive: return false; } } return false; }
void UpdateChecker::checkUpdate() { QString applicationName = ApplicationManager::getInstance()->getApplicationName().remove(" "); /** * dokumentacja dla http://agila.bluebraces.com/service/checkUpdate/$appName/$versionCode * * @param $appName dozwolone wartości "AgilaFaktury", "AgilaS3" (bez spacji!) * @param $versionCode - aktualny numer wersji kodu * @return 'NONE' - niewłaściwa liczba argumentów * @return 'INCORRECT_APP_NAME' - niewłasciwa nazwa aplikacji * @return '{"newVersionCode":2,"newVersionName":"1.2","downloadLink":...}' - odpowiedz JSON */ QStringList args; // kolejność ma znaczenie! args << applicationName << QVariant(ApplicationInfo::getVersionCode()).toString(); HttpRequester *requester = new HttpRequester(); try { QString response = requester->sendAgilaServiceRequest("checkUpdate", args); delete requester; if(response == "NONE") { emit noUpdateAvailable(); } else if(response == "INCORRECT_APP_NAME") { // "Błąd wywołania requestu! Błąd: 102"; } else if(response.startsWith("{")) { // jest dostępna aktualizacja JsonObject *jObject = new JsonObject(response); UpdateInfo updateInfo; updateInfo.setNewVersionCode(jObject->getInt("newVersionCode")); updateInfo.setNewVersionName(jObject->getString("newVersionName")); updateInfo.setDownloadLink(jObject->getString("downloadLink")); delete jObject; emit updateAvailable(updateInfo); } } catch(NoHttpResponseException *e) { delete requester; } }
void NSISUpdater::showDialog(const UpdateInfo &info) { // if the version tag is set, there is a newer version. QDialog *msgBox = new QDialog; msgBox->setAttribute(Qt::WA_DeleteOnClose); QIcon infoIcon = msgBox->style()->standardIcon(QStyle::SP_MessageBoxInformation, 0, 0); int iconSize = msgBox->style()->pixelMetric(QStyle::PM_MessageBoxIconSize, 0, 0); msgBox->setWindowIcon(infoIcon); QVBoxLayout *layout = new QVBoxLayout(msgBox); QHBoxLayout *hlayout = new QHBoxLayout; layout->addLayout(hlayout); msgBox->setWindowTitle(tr("New Version Available")); QLabel *ico = new QLabel; ico->setFixedSize(iconSize, iconSize); ico->setPixmap(infoIcon.pixmap(iconSize)); QLabel *lbl = new QLabel; QString txt = tr("<p>A new version of the %1 Client is available.</p>" "<p><b>%2</b> is available for download. The installed version is %3.</p>") .arg(Utility::escape(Theme::instance()->appNameGUI()), Utility::escape(info.versionString()), Utility::escape(clientVersion())); lbl->setText(txt); lbl->setTextFormat(Qt::RichText); lbl->setWordWrap(true); hlayout->addWidget(ico); hlayout->addWidget(lbl); QDialogButtonBox *bb = new QDialogButtonBox; bb->setWindowFlags(bb->windowFlags() & ~Qt::WindowContextHelpButtonHint); QPushButton *skip = bb->addButton(tr("Skip this version"), QDialogButtonBox::ResetRole); QPushButton *reject = bb->addButton(tr("Skip this time"), QDialogButtonBox::AcceptRole); QPushButton *getupdate = bb->addButton(tr("Get update"), QDialogButtonBox::AcceptRole); connect(skip, &QAbstractButton::clicked, msgBox, &QDialog::reject); connect(reject, &QAbstractButton::clicked, msgBox, &QDialog::reject); connect(getupdate, &QAbstractButton::clicked, msgBox, &QDialog::accept); connect(skip, &QAbstractButton::clicked, this, &NSISUpdater::slotSetSeenVersion); connect(getupdate, SIGNAL(clicked()), SLOT(slotOpenUpdateUrl())); layout->addWidget(bb); msgBox->open(); }
WitnessImprovement FCSimplexDecisionProcedure::selectFocusImproving() { Assert(d_focusErrorVar != ARITHVAR_SENTINEL); Assert(d_focusSize >= 2); LinearEqualityModule::UpdatePreferenceFunction upf = &LinearEqualityModule::preferWitness<true>; LinearEqualityModule::VarPreferenceFunction bpf = &LinearEqualityModule::minRowLength; UpdateInfo selected = selectPrimalUpdate(d_focusErrorVar, upf, bpf); if(selected.uninitialized()){ Debug("selectFocusImproving") << "focus is optimum, but we don't have sat/conflict yet" << endl; return focusDownToLastHalf(); } Assert(!selected.uninitialized()); WitnessImprovement w = selected.getWitness(false); Assert(debugCheckWitness(selected, w, false)); if(degenerate(w)){ Debug("selectFocusImproving") << "only degenerate" << endl; if(d_prevWitnessImprovement == HeuristicDegenerate && d_witnessImprovementInARow >= s_focusThreshold){ Debug("selectFocusImproving") << "focus down been degenerate too long" << endl; return focusDownToLastHalf(); }else{ Debug("selectFocusImproving") << "taking degenerate" << endl; } } Debug("selectFocusImproving") << "selectFocusImproving did this " << selected << endl; updateAndSignal(selected, w); logPivot(w); return w; }
void NSISUpdater::versionInfoArrived(const UpdateInfo &info) { ConfigFile cfg; QSettings settings(cfg.configFile(), QSettings::IniFormat); qint64 infoVersion = Helper::stringVersionToInt(info.version()); qint64 seenVersion = Helper::stringVersionToInt(settings.value(seenVersionC).toString()); qint64 currVersion = Helper::currentVersionToInt(); if(info.version().isEmpty() || infoVersion <= currVersion || infoVersion <= seenVersion) { qDebug() << "Client is on latest version!"; setDownloadState(UpToDate); } else { QString url = info.downloadUrl(); qint64 autoUpdateFailedVersion = Helper::stringVersionToInt(settings.value(autoUpdateFailedVersionC).toString()); if (url.isEmpty() || _showFallbackMessage || infoVersion == autoUpdateFailedVersion) { showDialog(info); } if (!url.isEmpty()) { _targetFile = cfg.configPath() + url.mid(url.lastIndexOf('/')); if (QFile(_targetFile).exists()) { setDownloadState(DownloadComplete); } else { QNetworkReply *reply = qnam()->get(QNetworkRequest(QUrl(url))); connect(reply, SIGNAL(readyRead()), SLOT(slotWriteFile())); connect(reply, SIGNAL(finished()), SLOT(slotDownloadFinished())); setDownloadState(Downloading); _file.reset(new QTemporaryFile); _file->setAutoRemove(true); _file->open(); } } } }
WitnessImprovement FCSimplexDecisionProcedure::dualLikeImproveError(ArithVar errorVar){ Assert(d_sgnDisagreements.empty()); Assert(d_focusSize > 1); UpdateInfo selected = selectUpdateForDualLike(errorVar); if(selected.uninitialized()){ // we found no proposals // If this is empty, there must be an error on this variable! // this should not be possible. It Should have been caught as a signal earlier WitnessImprovement dropped = focusUsingSignDisagreements(errorVar); Assert(d_sgnDisagreements.empty()); return dropped; }else{ d_sgnDisagreements.clear(); } Assert(d_sgnDisagreements.empty()); Assert(!selected.uninitialized()); if(selected.focusDirection() == 0 && d_prevWitnessImprovement == HeuristicDegenerate && d_witnessImprovementInARow >= s_focusThreshold){ Debug("focusDownToJust") << "focusDownToJust " << errorVar << endl; return focusDownToJust(errorVar); }else{ WitnessImprovement w = selected.getWitness(false); Assert(debugCheckWitness(selected, w, false)); updateAndSignal(selected, w); logPivot(w); return w; } }
void FCSimplexDecisionProcedure::updateAndSignal(const UpdateInfo& selected, WitnessImprovement w){ ArithVar nonbasic = selected.nonbasic(); static bool verbose = false; Debug("updateAndSignal") << "updateAndSignal " << selected << endl; stringstream ss; if(verbose){ d_errorSet.debugPrint(ss); if(selected.describesPivot()){ ArithVar leaving = selected.leaving(); ss << "leaving " << leaving << " " << d_tableau.basicRowLength(leaving) << " " << d_linEq.debugBasicAtBoundCount(leaving) << endl; } if(degenerate(w) && selected.describesPivot()){ ArithVar leaving = selected.leaving(); Message() << "degenerate " << leaving << ", atBounds " << d_linEq.basicsAtBounds(selected) << ", len " << d_tableau.basicRowLength(leaving) << ", bc " << d_linEq.debugBasicAtBoundCount(leaving) << endl; } } if(selected.describesPivot()){ ConstraintP limiting = selected.limiting(); ArithVar basic = limiting->getVariable(); Assert(d_linEq.basicIsTracked(basic)); d_linEq.pivotAndUpdate(basic, nonbasic, limiting->getValue()); }else{ Assert(!selected.unbounded() || selected.errorsChange() < 0); DeltaRational newAssignment = d_variables.getAssignment(nonbasic) + selected.nonbasicDelta(); d_linEq.updateTracked(nonbasic, newAssignment); } d_pivots++; increaseLeavingCount(nonbasic); vector< pair<ArithVar, int> > focusChanges; while(d_errorSet.moreSignals()){ ArithVar updated = d_errorSet.topSignal(); int prevFocusSgn = d_errorSet.popSignal(); if(d_tableau.isBasic(updated)){ Assert(!d_variables.assignmentIsConsistent(updated) == d_errorSet.inError(updated)); if(Debug.isOn("updateAndSignal")){debugPrintSignal(updated);} if(!d_variables.assignmentIsConsistent(updated)){ if(checkBasicForConflict(updated)){ reportConflict(updated); Assert(debugUpdatedBasic(selected, updated)); } } }else{ Debug("updateAndSignal") << "updated nonbasic " << updated << endl; } int currFocusSgn = d_errorSet.focusSgn(updated); if(currFocusSgn != prevFocusSgn){ int change = currFocusSgn - prevFocusSgn; focusChanges.push_back(make_pair(updated, change)); } } if(verbose){ Message() << "conflict variable " << selected << endl; Message() << ss.str(); } if(Debug.isOn("error")){ d_errorSet.debugPrint(Debug("error")); } Assert(debugSelectedErrorDropped(selected, d_errorSize, d_errorSet.errorSize())); adjustFocusAndError(selected, focusChanges); }
bool debugSelectedErrorDropped(const UpdateInfo& selected, int32_t prevErrorSize, int32_t currErrorSize){ int diff = currErrorSize - prevErrorSize; return selected.foundConflict() || diff == selected.errorsChange(); }
UpdateInfo FCSimplexDecisionProcedure::selectPrimalUpdate(ArithVar basic, LinearEqualityModule::UpdatePreferenceFunction upf, LinearEqualityModule::VarPreferenceFunction bpf) { UpdateInfo selected; static int instance = 0 ; ++instance; Debug("arith::selectPrimalUpdate") << "selectPrimalUpdate " << instance << endl << basic << " " << d_tableau.basicRowLength(basic) << " " << d_linEq.debugBasicAtBoundCount(basic) << endl; static const int s_maxCandidatesAfterImprove = 3; bool isFocus = basic == d_focusErrorVar; Assert(isFocus || d_errorSet.inError(basic)); int basicDir = isFocus? 1 : d_errorSet.getSgn(basic); bool dualLike = !isFocus && d_focusSize > 1; if(!isFocus){ loadFocusSigns(); } decreasePenalties(); typedef std::vector<Cand> CandVector; CandVector candidates; for(Tableau::RowIterator ri = d_tableau.basicRowIterator(basic); !ri.atEnd(); ++ri){ const Tableau::Entry& e = *ri; ArithVar curr = e.getColVar(); if(curr == basic){ continue; } int sgn = e.getCoefficient().sgn(); int curr_movement = basicDir * sgn; bool candidate = (curr_movement > 0 && d_variables.cmpAssignmentUpperBound(curr) < 0) || (curr_movement < 0 && d_variables.cmpAssignmentLowerBound(curr) > 0); Debug("arith::selectPrimalUpdate") << "storing " << basic << " " << curr << " " << candidate << " " << e.getCoefficient() << " " << curr_movement << " " << focusCoefficient(curr) << endl; if(!candidate) { continue; } if(!isFocus){ const Rational& focusC = focusCoefficient(curr); Assert(dualLike || !focusC.isZero()); if(dualLike && curr_movement != focusC.sgn()){ Debug("arith::selectPrimalUpdate") << "sgn disagreement " << curr << endl; d_sgnDisagreements.push_back(curr); continue; }else{ candidates.push_back(Cand(curr, penalty(curr), curr_movement, &focusC)); } }else{ candidates.push_back(Cand(curr, penalty(curr), curr_movement, &e.getCoefficient())); } } CompPenaltyColLength colCmp(&d_linEq); CandVector::iterator i = candidates.begin(); CandVector::iterator end = candidates.end(); std::make_heap(i, end, colCmp); bool checkEverything = d_pivots == 0; int candidatesAfterFocusImprove = 0; while(i != end && (checkEverything || candidatesAfterFocusImprove <= s_maxCandidatesAfterImprove)){ std::pop_heap(i, end, colCmp); --end; Cand& cand = (*end); ArithVar curr = cand.d_nb; const Rational& coeff = *cand.d_coeff; LinearEqualityModule::UpdatePreferenceFunction leavingPrefFunc = selectLeavingFunction(curr); UpdateInfo currProposal = d_linEq.speculativeUpdate(curr, coeff, leavingPrefFunc); Debug("arith::selectPrimalUpdate") << "selected " << selected << endl << "currProp " << currProposal << endl << "coeff " << coeff << endl; Assert(!currProposal.uninitialized()); if(candidatesAfterFocusImprove > 0){ candidatesAfterFocusImprove++; } if(selected.uninitialized() || (d_linEq.*upf)(selected, currProposal)){ selected = currProposal; WitnessImprovement w = selected.getWitness(false); Debug("arith::selectPrimalUpdate") << "selected " << w << endl; setPenalty(curr, w); if(improvement(w)){ bool exitEarly; switch(w){ case ConflictFound: exitEarly = true; break; case ErrorDropped: if(checkEverything){ exitEarly = d_errorSize + selected.errorsChange() == 0; Debug("arith::selectPrimalUpdate") << "ee " << d_errorSize << " " << selected.errorsChange() << " " << d_errorSize + selected.errorsChange() << endl; }else{ exitEarly = true; } break; case FocusImproved: candidatesAfterFocusImprove = 1; exitEarly = false; break; default: exitEarly = false; break; } if(exitEarly){ break; } } }else{ Debug("arith::selectPrimalUpdate") << "dropped "<< endl; } } if(!isFocus){ unloadFocusSigns(); } return selected; }
/** \todo document this function */ QDomElement GCF::UpdateInfo::toDomElement(QDomDocument doc, bool forThisSystem) const { QDomElement updateE = doc.createElement("Update"); QDomElement nameE = doc.createElement("Name"); nameE.appendChild( doc.createTextNode(d->name) ); updateE.appendChild(nameE); QDomElement titleE = doc.createElement("Title"); titleE.appendChild( doc.createTextNode(d->title) ); updateE.appendChild(titleE); QDomElement sourceE = doc.createElement("Source"); sourceE.appendChild( doc.createTextNode(d->source) ); updateE.appendChild(sourceE); QDomElement iconE = doc.createElement("Icon"); iconE.appendChild( doc.createTextNode(d->iconUrl.toString()) ); updateE.appendChild(iconE); QDomElement typeE = doc.createElement("Type"); typeE.appendChild( doc.createTextNode(d->type) ); updateE.appendChild(typeE); QDomElement forceInstallE = doc.createElement("ForceInstall"); forceInstallE.appendChild( doc.createTextNode( QVariant(d->forceInstall).toString() ) ); updateE.appendChild(forceInstallE); QDomElement descE = doc.createElement("Description"); descE.appendChild( doc.createCDATASection(d->description) ); updateE.appendChild(descE); QDomElement releaseE = doc.createElement("Release"); releaseE.appendChild( doc.createTextNode(d->release.toString()) ); updateE.appendChild(releaseE); QDomElement versionE = doc.createElement("Version"); versionE.appendChild( doc.createTextNode(d->version) ); updateE.appendChild(versionE); QList<UpdateFileInfo> ufiList; if( forThisSystem ) { UpdateFileInfo fileInfo = updateFileForThisSystem(); ufiList.append(fileInfo); } else ufiList = d->updateFiles; for(int j=0; j<ufiList.count(); j++) { UpdateFileInfo ufi = ufiList[j]; QDomElement updateFileE = doc.createElement("UpdateFile"); updateE.appendChild(updateFileE); updateFileE.setAttribute("OS", ufi.OS); updateFileE.setAttribute("Arch", ufi.Arch); updateFileE.appendChild( doc.createTextNode(ufi.UpdateFileURL.toString()) ); } const QList<UpdateInfo>& deps = d->dependencies; for(int j=0; j<deps.count(); j++) { UpdateInfo dep = deps[j]; QString depStr = QString("%1 [%2]").arg( dep.name() ).arg( dep.version() ); QDomElement dependsOnE = doc.createElement("DependsOn"); dependsOnE.appendChild( doc.createTextNode(depStr) ); updateE.appendChild(dependsOnE); } return updateE; }