catalog::Schema *SchemaTransformer::GetSchemaFromTupleDesc( TupleDesc tupleDesc) { catalog::Schema *schema = nullptr; std::vector<catalog::Column> columns; int natts = tupleDesc->natts; // construct column for (int column_itr = 0; column_itr < natts; column_itr++) { std::vector<catalog::Constraint> constraint_infos; PostgresValueFormat postgresValueFormat( tupleDesc->attrs[column_itr]->atttypid, tupleDesc->attrs[column_itr]->attlen, tupleDesc->attrs[column_itr]->atttypmod); PelotonValueFormat pelotonValueFormat = FormatTransformer::TransformValueFormat(postgresValueFormat); ValueType value_type = pelotonValueFormat.GetType(); int column_length = pelotonValueFormat.GetLength(); bool is_inlined = pelotonValueFormat.IsInlined(); // Skip invalid attributes (e.g., ctid) if (VALUE_TYPE_INVALID == value_type) { continue; } // NOT NULL constraint if (tupleDesc->attrs[column_itr]->attnotnull) { std::string constraint_name = "not_null"; catalog::Constraint constraint(CONSTRAINT_TYPE_NOTNULL, constraint_name); constraint_infos.push_back(constraint); } // DEFAULT value constraint if (tupleDesc->attrs[column_itr]->atthasdef) { std::string constraint_name = "default"; catalog::Constraint constraint(CONSTRAINT_TYPE_DEFAULT, constraint_name); constraint_infos.push_back(constraint); } LOG_TRACE("Column length: %d/%d, is inlined: %d", tupleDesc->attrs[column_itr]->attlen, column_length, is_inlined); catalog::Column column( value_type, column_length, std::string(NameStr(tupleDesc->attrs[column_itr]->attname), NAMEDATALEN), is_inlined); for (auto constraint : constraint_infos) column.AddConstraint(constraint); columns.push_back(column); } schema = new catalog::Schema(columns); return schema; }
void StatsTestsUtil::CreateTable(bool has_primary_key) { LOG_INFO("Creating a table..."); auto id_column = catalog::Column( common::Type::INTEGER, common::Type::GetTypeSize(common::Type::INTEGER), "dept_id", true); if (has_primary_key) { catalog::Constraint constraint(CONSTRAINT_TYPE_PRIMARY, "con_primary"); id_column.AddConstraint(constraint); } auto name_column = catalog::Column(common::Type::VARCHAR, 32, "dept_name", false); std::unique_ptr<catalog::Schema> table_schema( new catalog::Schema({id_column, name_column})); auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); std::unique_ptr<executor::ExecutorContext> context( new executor::ExecutorContext(txn)); planner::CreatePlan node("department_table", "emp_db", std::move(table_schema), CreateType::CREATE_TYPE_TABLE); executor::CreateExecutor create_executor(&node, context.get()); create_executor.Init(); create_executor.Execute(); txn_manager.CommitTransaction(txn); }
inline void QtMultiArg::checkConstraint() const { if( isDefined() ) { QList< QVariant > values = value().toList(); foreach( QVariant v, values ) if( constraint() && !constraint()->check( v ) ) throw QtArgContraintNotObservedEx( QString::fromLatin1( "Constraint for the argument: %1" " hasn't observed. Wrong value is: %2" ) .arg( names().size() ? names().front() : flags().front() ) .arg( v.toString() ) ); } }
void IxValidator::validateEMail(const QVariant & v, QxInvalidValueX & lstInvalidValues) const { QString s = v.toString(); QString pattern = "\\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}\\b"; QRegExp constraint(pattern, Qt::CaseInsensitive); if (! constraint.exactMatch(s)) { lstInvalidValues.insert(this); } }
bool Enumerator::continueFromModel(Solver& s, bool heu) { if (!optimize()) { return true; } s.strengthenConditional(); MinimizeConstraint* min = constraint(s)->minimize(); return !s.isTrue(s.sharedContext()->tagLiteral()) || (!s.hasConflict() && min->integrateNext(s) && (!heu || min->modelHeuristic(s))); }
/** * Prints the condition to an output stream. * * @param _out The output stream, where it should print. */ void Condition::print( std::ostream& _out ) const { _out << constraint().toString( 0, true, true ); _out << " [" << mId << "]"; _out << " "; if( flag() ) _out << "(true, "; else _out << "(false, "; _out << "valuation=" << valuation(); if( recentlyAdded() ) _out << ", recently added) {"; else _out << ") {"; if( originalConditions().empty() ) _out << "no original condition}"; else { for( auto oCond = originalConditions().begin(); oCond != originalConditions().end(); ++oCond ) { if( oCond != originalConditions().begin() ) _out << ", "; _out << "[" << (*oCond)->getId() << "]"; } _out << " }"; } }
void PenaltyMP_FE::determineTangent(void) { // first determine [C] = [-I [Ccr]] C->Zero(); const Matrix &constraint = theMP->getConstraint(); int noRows = constraint.noRows(); int noCols = constraint.noCols(); for (int j=0; j<noRows; j++) (*C)(j,j) = -1.0; for (int i=0; i<noRows; i++) for (int j=0; j<noCols; j++) (*C)(i,j+noRows) = constraint(i,j); // now form the tangent: [K] = alpha * [C]^t[C] // *(tang) = (*C)^(*C); // *(tang) *= alpha; // THIS IS A WORKAROUND UNTIL WE GET addMatrixTransposeProduct() IN // THE Matrix CLASS OR UNROLL THIS COMPUTATION int rows = C->noRows(); int cols = C->noCols(); Matrix CT(cols,rows); const Matrix &Cref = *C; // Fill in the transpose of C for (int k = 0; k < cols; k++) for (int l = 0; l < rows; l++) CT(k,l) = Cref(l,k); // Compute alpha*(C^*C) tang->addMatrixProduct(0.0, CT, Cref, alpha); }
bool SetConstraintToolPositionCommand(std::ostream& sout, std::istream& sinput) { std::string manipname; ManipPositionConstraintsPtr constraint(new ManipPositionConstraints()); sinput >> manipname; if( manipname.size() == 0 ) { // reset the tool position if( !!_pConstraintToolPosition ) { if( !!_cache ) { _cache->Reset(); // need this here in order to invalidate cache. } } _pConstraintToolPosition.reset(); return true; } sinput >> constraint->obb.right.x >> constraint->obb.right.y >> constraint->obb.right.z >> constraint->obb.up.x >> constraint->obb.up.y >> constraint->obb.up.z >> constraint->obb.dir.x >> constraint->obb.dir.y >> constraint->obb.dir.z >> constraint->obb.pos.x >> constraint->obb.pos.y >> constraint->obb.pos.z >> constraint->obb.extents.x >> constraint->obb.extents.y >> constraint->obb.extents.z; if( !sinput ) { return false; } RobotBase::ManipulatorConstPtr pmanip = _probot->GetManipulator(manipname); if( !pmanip ) { return false; } _pmanip = pmanip; _pConstraintToolPosition = constraint; if( !!_cache ) { _cache->Reset(); // need this here in order to invalidate cache. } return true; }
void DoubleExponentialCalibration::compute() { if (vegaWeighted_) { Real weightsSum = 0.0; for (Size i=0; i<times_.size() ; i++) { Real stdDev = std::sqrt(blackVols_[i]* blackVols_[i]* times_[i]); // when strike==forward, the blackFormulaStdDevDerivative becomes weights_[i] = CumulativeNormalDistribution().derivative(.5*stdDev); weightsSum += weights_[i]; } // weight normalization for (Size i=0; i<times_.size() ; i++) { weights_[i] /= weightsSum; } } // there is nothing to optimize if (sigmaIsFixed_ && b1IsFixed_ && b2IsFixed_ && lambdaIsFixed_) { dblexpEndCriteria_ = EndCriteria::None; //error_ = interpolationError(); //maxError_ = interpolationMaxError(); return; } else { DoubleExponentialError costFunction(this); Array guess(4); guess[0] = sigma_; guess[1] = b1_; guess[2] = b2_; guess[3] = lambda_; std::vector<bool> parameterAreFixed(4); parameterAreFixed[0] = sigmaIsFixed_; parameterAreFixed[1] = b1IsFixed_; parameterAreFixed[2] = b2IsFixed_; parameterAreFixed[3] = lambdaIsFixed_; ProjectedCostFunction projectedDoubleExponentialCostFunction(costFunction, guess, parameterAreFixed); Array projectedGuess (projectedDoubleExponentialCostFunction.project(guess)); // NoConstraint constraint; //PositiveConstraint constraint; BoundaryConstraint constraint(0.0, 1.0); Problem problem(projectedDoubleExponentialCostFunction, constraint, projectedGuess); dblexpEndCriteria_ = optMethod_->minimize(problem, *endCriteria_); Array projectedResult(problem.currentValue()); Array result(projectedDoubleExponentialCostFunction.include(projectedResult)); sigma_ = result[0]; b1_ = result[1]; b2_ = result[2]; lambda_ = result[3]; validateDoubleExponentialParameters(sigma_, b1_, b2_, lambda_); } }
void iil4mitkImage::display (iil4mitkWidget* widget) { GLdouble planeX [] = {-1, 0, 0, regionWidth ()}; GLdouble planeY [] = {0, -1, 0, regionHeight ()}; if (!visible () || (constraint () && (widget != constraint ()))) { return; } if (_pixels) { assert (_rx + _rw <= _width); assert (_ry + _rh <= _height); GLboolean texturing = glIsEnabled (GL_TEXTURE_2D); GLboolean blending = glIsEnabled (GL_BLEND); glClipPlane (GL_CLIP_PLANE4, planeX); glEnable (GL_CLIP_PLANE4); glClipPlane (GL_CLIP_PLANE5, planeY); glEnable (GL_CLIP_PLANE5); if ((_model == INTENSITY_ALPHA) || (_model == COLOR_ALPHA) || (_model == RGB) || (_model == RGBA)) { glEnable (GL_BLEND); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } glEnable (GL_TEXTURE_2D); glMatrixMode (GL_MODELVIEW); glPushMatrix (); glColor4f (red (), green (), blue (), alpha ()); glTranslatef (x (), y (), 0.0); drawTextures (widget); glPopMatrix (); glDisable (GL_CLIP_PLANE4); glDisable (GL_CLIP_PLANE5); if (texturing == GL_FALSE) glDisable (GL_TEXTURE_2D); if (blending == GL_FALSE) glDisable (GL_BLEND); } }
int main(int, char **) { FILE *o = fopen("paper/figs/constrained-water.dat", "w"); Functional f = OfEffectivePotential(SaftFluidSlow(water_prop.lengthscale, water_prop.epsilonAB, water_prop.kappaAB, water_prop.epsilon_dispersion, water_prop.lambda_dispersion, water_prop.length_scaling, 0)); double mu_satp = find_chemical_potential(f, water_prop.kT, water_prop.liquid_density); Lattice lat(Cartesian(width,0,0), Cartesian(0,width,0), Cartesian(0,0,zmax)); GridDescription gd(lat, 0.1); Grid potential(gd); Grid constraint(gd); constraint.Set(notinwall); f = constrain(constraint, OfEffectivePotential(SaftFluidSlow(water_prop.lengthscale, water_prop.epsilonAB, water_prop.kappaAB, water_prop.epsilon_dispersion, water_prop.lambda_dispersion, water_prop.length_scaling, mu_satp))); Minimizer min = Precision(0, PreconditionedConjugateGradient(f, gd, water_prop.kT, &potential, QuadraticLineMinimizer)); potential = water_prop.liquid_density*constraint + water_prop.vapor_density*VectorXd::Ones(gd.NxNyNz); //potential = water_prop.liquid_density*VectorXd::Ones(gd.NxNyNz); potential = -water_prop.kT*potential.cwise().log(); const int numiters = 50; for (int i=0;i<numiters && min.improve_energy(true);i++) { fflush(stdout); Grid density(gd, EffectivePotentialToDensity()(water_prop.kT, gd, potential)); density.epsNative1d("paper/figs/1d-constrained-plot.eps", Cartesian(0,0,0), Cartesian(0,0,zmax), water_prop.liquid_density, 1, "Y axis: , x axis: "); } min.print_info(); double energy = min.energy()/width/width; printf("Energy is %.15g\n", energy); double N = 0; { Grid density(gd, EffectivePotentialToDensity()(water_prop.kT, gd, potential)); for (int i=0;i<gd.NxNyNz;i++) N += density[i]*gd.dvolume; } N = N/width/width; printf("N is %.15g\n", N); Grid density(gd, EffectivePotentialToDensity()(water_prop.kT, gd, potential)); density.epsNative1d("paper/figs/1d-constrained-plot.eps", Cartesian(0,0,0), Cartesian(0,0,zmax), water_prop.liquid_density, 1, "Y axis: , x axis: "); //potential.epsNative1d("hard-wall-potential.eps", Cartesian(0,0,0), Cartesian(0,0,zmax), 1, 1); fclose(o); }
Array CmsMarketCalibration::compute( const boost::shared_ptr<EndCriteria>& endCriteria, const boost::shared_ptr<OptimizationMethod>& method, const Array& guess, bool isMeanReversionFixed) { Size nSwapTenors = cmsMarket_->swapTenors().size(); QL_REQUIRE(nSwapTenors == guess.size() || nSwapTenors == guess.size()-1, "guess size (" << guess.size() << ") must be equal to swap tenors size (" << nSwapTenors << ") or greater by one if mean reversion is given as last element"); bool isMeanReversionGiven = (nSwapTenors == guess.size()-1); Array result; if (isMeanReversionFixed || !isMeanReversionGiven) { Size nBeta = guess.size() - (isMeanReversionGiven ? 1 : 0); ParametersConstraint2 constraint(nBeta); Real fixedMeanReversion = isMeanReversionGiven ? guess[nBeta] : Null<Real>(); Array betasGuess(nBeta); for (Size i=0; i<nBeta; ++i) betasGuess[i] = guess[i]; ObjectiveFunction2 costFunction(this, fixedMeanReversion); Problem problem(costFunction, constraint, betasGuess); endCriteria_ = method->minimize(problem, *endCriteria); Array tmp = problem.currentValue(); result = Array(nBeta+(isMeanReversionGiven ? 1 : 0)); for (Size i=0; i<nBeta; ++i) result[i] = tmp[i]; if(isMeanReversionGiven) result[nBeta] = fixedMeanReversion; error_ = costFunction.value(tmp); } else { ParametersConstraint constraint(guess.size()-1); ObjectiveFunction costFunction(this); Problem problem(costFunction, constraint, guess); endCriteria_ = method->minimize(problem, *endCriteria); result = problem.currentValue(); error_ = costFunction.value(result); } const boost::shared_ptr<SwaptionVolCube1> volCubeBySabr = boost::dynamic_pointer_cast<SwaptionVolCube1>(*volCube_); volCubeBySabr->updateAfterRecalibration(); sparseSabrParameters_ = volCubeBySabr->sparseSabrParameters(); denseSabrParameters_ = volCubeBySabr->denseSabrParameters(); browseCmsMarket_ = cmsMarket_->browse(); return result; }
void print_alias(Output& out, const TypeAlias& alias) { auto flags = TypeConstraint::NoFlags; if (alias.nullable) flags = flags | TypeConstraint::Nullable; TypeConstraint constraint(alias.value, flags); out.fmtln(".alias{} {} = <{}>;", opt_attrs(AttrContext::Alias, alias.attrs), (const StringData*)alias.name, type_constraint(constraint)); }
void ConstraintList::unserialize(const boost::property_tree::ptree& tree) { // Iterate through the list of operand/expressions, then set the constraint // type affinity. for (const auto& list : tree.get_child("list")) { Constraint constraint(list.second.get<unsigned char>("op")); constraint.expr = list.second.get<std::string>("expr"); constraints_.push_back(constraint); } affinity = columnTypeName(tree.get<std::string>("affinity", "UNKNOWN")); }
static OBJECT InterposeScale(OBJECT y, int scale_factor, int dim) { OBJECT res; New(res, SCALE); FposCopy(fpos(res), fpos(y)); if( dim == COLM ) { bc(constraint(res)) = scale_factor; fc(constraint(res)) = 1 * SF; } else { bc(constraint(res)) = 1 * SF; fc(constraint(res)) = scale_factor; } back(res, dim) = (back(y, dim) * scale_factor) / SF; fwd(res, dim) = (fwd(y, dim) * scale_factor) / SF; back(res, 1-dim) = back(y, 1-dim); fwd(res, 1-dim) = fwd(y, 1-dim); ReplaceNode(res, y); Link(res, y); return res; } /* end InterposeScale */
void UmlActivityAction::write_end(FileOut & out, bool dontclose) { out << ">\n"; out.indent(+1); Q3CString s = constraint(); if (! s.isEmpty()) { out.indent(); out << "<ownedRule xmi:type=\"uml:Constraint\""; out.id_prefix(this, "CONSTRAINT_"); out.ref(this, "constrainedElement"); out << ">\n"; out.indent(); out << "\t<specification xmi:type=\"uml:OpaqueExpression\""; out.id_prefix(this, "CSPEC_"); out << ">\n"; out.indent(); out << "\t\t<body>"; out.quote(s); out << "</body>\n"; out.indent(); out << "\t</specification>\n"; out.indent(); out << "</ownedRule>\n"; } write_description_properties(out); switch (_lang) { case Uml: write_condition(out, preCondition(), TRUE); write_condition(out, postCondition(), FALSE); break; case Cpp: write_condition(out, cppPreCondition(), TRUE); write_condition(out, cppPostCondition(), FALSE); break; default: // java write_condition(out, javaPreCondition(), TRUE); write_condition(out, javaPostCondition(), FALSE); } const Q3PtrVector<UmlItem> ch = children(); unsigned n = ch.size(); for (unsigned i = 0; i != n; i += 1) ch[i]->write(out); write_incoming_flows(out); if (!dontclose) write_close(out); }
bool NodeConstraintManager::checkAllConstraints() { for (std::function<bool(DataNode*)>& constraint : m_constraints) { if (!constraint(m_attribute.get<DataNode*>())) return false; } if (m_attribute.get<DataNode*>()->getAnnotation() != "Set") return false; m_attribute.get<DataNode*>()->setAnnotation("UnSet"); return true; }
void ConstraintFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node, LocalMatOps>::Build(Level &fineLevel, Level& coarseLevel) const { FactoryMonitor m(*this, "Constraint", coarseLevel); RCP<MultiVector> fineNullspace = Get< RCP<MultiVector> >(fineLevel, "Nullspace", "FineNullspace"); RCP<MultiVector> coarseNullspace = Get< RCP<MultiVector> >(coarseLevel, "Nullspace", "CoarseNullspace"); RCP<Constraint> constraint(new Constraint); constraint->Setup(*fineNullspace, *coarseNullspace, Get< RCP<const CrsGraph> >(coarseLevel, "Ppattern")); Set(coarseLevel, "Constraint", constraint); }
double run_walls(double reduced_density, const char *name, Functional fhs, double teff) { double kT = teff; if (kT == 0) kT = 1; Functional f = OfEffectivePotential(fhs); const double zmax = width + 2*spacing; Lattice lat(Cartesian(dw,0,0), Cartesian(0,dw,0), Cartesian(0,0,zmax)); GridDescription gd(lat, dx); Grid constraint(gd); constraint.Set(notinwall); f = constrain(constraint, f); Grid potential(gd); potential = pow(2,-5.0/2.0)*(reduced_density*constraint + 1e-4*reduced_density*VectorXd::Ones(gd.NxNyNz)); potential = -kT*potential.cwise().log(); const double approx_energy = fhs(kT, reduced_density*pow(2,-5.0/2.0))*dw*dw*width; const double precision = fabs(approx_energy*1e-11); printf("\tMinimizing to %g absolute precision from %g from %g...\n", precision, approx_energy, kT); fflush(stdout); Minimizer min = Precision(precision, PreconditionedConjugateGradient(f, gd, kT, &potential, QuadraticLineMinimizer)); took("Setting up the variables"); if (strcmp(name, "hard") != 0 && false) { printf("For now, SoftFluid doesn't work properly, so we're skipping the\n"); printf("minimization at temperature %g.\n", teff); } else { for (int i=0;min.improve_energy(false) && i<100;i++) { } } took("Doing the minimization"); min.print_info(); Grid density(gd, EffectivePotentialToDensity()(kT, gd, potential)); //printf("# per area is %g at filling fraction %g\n", density.sum()*gd.dvolume/dw/dw, eta); char *plotname = (char *)malloc(1024); sprintf(plotname, "papers/fuzzy-fmt/figs/walls%s-%06.4f-%04.2f.dat", name, teff, reduced_density); z_plot(plotname, Grid(gd, density*pow(2,5.0/2.0))); free(plotname); took("Plotting stuff"); printf("density %g gives ff %g for reduced density = %g and T = %g\n", density(0,0,gd.Nz/2), density(0,0,gd.Nz/2)*4*M_PI/3, reduced_density, teff); return density(0, 0, gd.Nz/2)*4*M_PI/3; // return bulk filling fraction }
void fillMatrices(CPropagation *cp) { const char *ctype = problem_vars_type(cp->problem); for(int idxRow = 0; idxRow < problem_num_rows(cp->problem); idxRow++) { char sense = problem_row_sense(cp->problem, idxRow); if(sense == 'R') /* ignoring ranged constarints */ continue; const int nElements = problem_row_size(cp->problem, idxRow); const int *idxs = problem_row_idxs(cp->problem, idxRow); const double *coefs = problem_row_coefs(cp->problem, idxRow); const double rhs = problem_row_rhs(cp->problem, idxRow); double mult = (sense == 'G') ? -1.0 : 1.0; vector<pair<int, double> > constraint(nElements); bool allBinaries = true; for(int i = 0; i < nElements; i++) { constraint[i] = pair<int, double> (idxs[i], mult * coefs[i]); if(ctype[idxs[i]] != BINARY) { allBinaries = false; break; } } if(allBinaries) { cp->matrixByRow.push_back(constraint); cp->rhs.push_back(rhs * mult); if(sense == 'E') { for(int j = 0; j < nElements; j++) constraint[j].second = -1.0 * constraint[j].second; cp->matrixByRow.push_back(constraint); cp->rhs.push_back(-1.0 * rhs); } } } cp->matrixByCol.resize(problem_num_cols(cp->problem)); for(int i = 0; i < (int)cp->matrixByRow.size(); i++) for(int j = 0; j < (int)cp->matrixByRow[i].size(); j++) { const int var = cp->matrixByRow[i][j].first; const double coef = cp->matrixByRow[i][j].second; cp->matrixByCol[var].push_back(pair<int, double>(i, coef)); } }
static OBJECT InterposeWideOrHigh(OBJECT y, int dim) { OBJECT res; New(res, dim == COLM ? WIDE : HIGH); FposCopy(fpos(res), fpos(y)); back(res, dim) = back(y, dim); fwd(res, dim) = fwd(y, dim); back(res, 1-dim) = back(y, 1-dim); fwd(res, 1-dim) = fwd(y, 1-dim); SetConstraint(constraint(res), MAX_FULL_LENGTH, size(res, dim), MAX_FULL_LENGTH); ReplaceNode(res, y); Link(res, y); return res; } /* end InterposeWideOrHigh */
Container::Container( QWidget* parent ) : QWidget(parent) { setAttribute( Qt::WA_X11NetWmWindowTypeDock ); KWindowSystem::setType( winId(), NET::Dock ); KWindowSystem::setState( winId(), NET::Sticky ); KWindowSystem::setState( winId(), NET::StaysOnTop ); KWindowSystem::setOnAllDesktops( winId(), true ); setMinimumSize( 20, 20 ); m_side = 0; m_occ = 48; // setSide( 2 ); // slotScreenResized(); NLayout* layout = new NLayout; layout->setMargin( 0 ); // layout->setSpacing( 0 ); setLayout( layout ); m_isLocked = true; /// at least set a sensible order by default QStringList m_appletsOrder; m_appletsOrder << "knpanel_applet_kbutton"; m_appletsOrder << "knpanel_applet_mnpager"; m_appletsOrder << "knpanel_applet_sctasks"; m_appletsOrder << "knpanel_applet_sstray"; m_appletsOrder << "knpanel_applet_dclock"; m_appletsOrder << "knpanel_applet_trash"; m_appletsOrder << "knpanel_applet_sdhbutton"; QHash<QString,Plate*> plates; QString constraint( "([X-KDE-Priority] > 0) and (exist Library)" ); KService::List offers = KServiceTypeTrader::self()->query( "KNPanelApplet", constraint ); foreach ( const KService::Ptr& service, offers ) { KPluginFactory* factory = KPluginLoader( service->library() ).factory(); if ( factory ) { const KAboutData* aboutData = factory->componentData().aboutData(); qWarning() << "loading" << aboutData->appName(); /// FIXME: port to KPluginInfo if ( !m_appletsOrder.contains( aboutData->appName() ) ) continue; KNPanelApplet* applet = factory->create<KNPanelApplet>(); plates.insert( aboutData->appName(), new Plate( applet, factory->componentData() ) ); } }
Enumerator::Result Enumerator::backtrackFromModel(Solver& s, bool callContinue) { assert(s.numFreeVars() == 0 && !s.hasConflict()); bool update = updateModel(s) || optimize(); bool expandSym = !ignoreSymmetric(); activeLevel_ = mini_ ? constraint(s)->minimize()->commitCurrent(s)+1 : s.decisionLevel(); Enumerator::Result r = Enumerator::enumerate_continue; EnumeratorConstraint* c = constraint(s); do { ++enumerated; s.stats.addModel(s.decisionLevel()); if (report_) { report_->reportModel(s, *this); } if ((numModels_ != 0 && --numModels_ == 0) || terminated()) { // enough models enumerated return enumerate_stop_enough; } // Process symmetric models, i.e. models that differ only in the // assignment of atoms outside of the solver's assignment. // Typical example: vars eliminated by the SAT-preprocessor } while (expandSym && s.nextSymModel()); if (activeLevel_ <= s.rootLevel() || !backtrack(s)) { r = enumerate_stop_complete; s.undoUntil(0, true); } else if (restartOnModel_) { s.undoUntil(0); } if (update && s.sharedContext()->isShared()) { // enumerator is not trivial w.r.t current search scheme // force update of other solvers // - this one is up to date c->setUpdates(nextUpdate()); } if (callContinue && !continueFromModel(s)) { r = enumerate_stop_complete; } return r; }
void DataTable::AddForeignKey(catalog::ForeignKey *key) { { std::lock_guard<std::mutex> lock(tile_group_mutex_); catalog::Schema *schema = this->GetSchema(); catalog::Constraint constraint(CONSTRAINT_TYPE_FOREIGN, key->GetConstraintName()); constraint.SetForeignKeyListOffset(GetForeignKeyCount()); for (auto fk_column : key->GetFKColumnNames()) { schema->AddConstraint(fk_column, constraint); } // TODO :: We need this one.. catalog::ForeignKey *fk = new catalog::ForeignKey(*key); foreign_keys_.push_back(fk); } }
void UmlRelation::write_generalization(FileOut & out) { out.indent(); out << "<generalization xmi:type=\"uml:Generalization\""; out.id(this); out.ref(roleType(), "general"); if (!constraint().isEmpty()) { out << ">\n"; out.indent(+1); write_constraint(out); out.indent(-1); out.indent(); out << "</generalization>\n"; } else out << "/>\n"; }
bool Enumerator::update(Solver& s, bool disjoint) { EnumeratorConstraint* c = constraint(s); uint32 gUpdates; if (!c || c->updates() == (gUpdates = updates_)) { return true; } bool ret = true; if (optimize()) { ret = c->minimize()->integrateNext(s); disjoint = true; // enforced by minimize constraint } if (ret && (ret = updateConstraint(s, disjoint)) == true) { c->setUpdates(gUpdates); } return ret; }
void tst_QGraphicsLinearLayout::heightForWidth() { QFETCH(bool, hfw); QFETCH(bool, nested); QGraphicsScene scene; QGraphicsWidget *form = new QGraphicsWidget; scene.addItem(form); QGraphicsLinearLayout *outerlayout = 0; if (nested) { outerlayout = new QGraphicsLinearLayout(form); for (int i = 0; i < 8; i++) { QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical); outerlayout->addItem(layout); outerlayout = layout; } } QGraphicsLinearLayout *qlayout = 0; qlayout = new QGraphicsLinearLayout(Qt::Vertical); if (nested) outerlayout->addItem(qlayout); else form->setLayout(qlayout); MySquareWidget *widget = new MySquareWidget; for (int i = 0; i < 1; i++) { widget = new MySquareWidget; QSizePolicy sizepolicy = widget->sizePolicy(); sizepolicy.setHeightForWidth(hfw); widget->setSizePolicy(sizepolicy); qlayout->addItem(widget); } // make sure only one iteration is done. // run with tst_QGraphicsLinearLayout.exe "heightForWidth" -tickcounter -iterations 6 // this will iterate 6 times the whole test, (not only the benchmark) // which should reduce warmup time and give a realistic picture of the performance of // effectiveSizeHint() QSizeF constraint(hfw ? 100 : -1, -1); QBENCHMARK { (void)form->effectiveSizeHint(Qt::PreferredSize, constraint); } }
void cover_goals_extt::operator()() { _iterations=_number_covered=0; decision_proceduret::resultt dec_result; // We use incremental solving, so need to freeze some variables // to prevent them from being eliminated. freeze_goal_variables(); do { // We want (at least) one of the remaining goals, please! _iterations++; constraint(); dec_result=solver(); switch(dec_result) { case decision_proceduret::D_UNSATISFIABLE: // DONE break; case decision_proceduret::D_SATISFIABLE: // mark the goals we got mark(); // notify assignment(); if(!all_properties) return; // exit on first failure if requested break; default: error() << "decision procedure has failed" << eom; return; } } while(dec_result==decision_proceduret::D_SATISFIABLE && number_covered()<size()); }
void bound_propagator::init_eq(linear_equation * eq) { if (eq == 0) return; unsigned c_idx = m_constraints.size(); m_constraints.push_back(constraint()); constraint & new_c = m_constraints.back(); new_c.m_kind = LINEAR; new_c.m_dead = false; new_c.m_timestamp = 0; new_c.m_act = 0; new_c.m_counter = 0; new_c.m_eq = eq; unsigned sz = eq->size(); for (unsigned i = 0; i < sz; i++) { m_watches[eq->x(i)].push_back(c_idx); } if (propagate(c_idx) && scope_lvl() > 0) m_reinit_stack.push_back(c_idx); }
void PBDcollision::simulate() { double cur_c = constraint(); if(cur_c >= 0) return; del_constraint(); int i, j; double s=0; for(i=0;i<n;i++) { double t = del[i].dist(); s += p[i]->w * t*t; } if(s < E)return; for(i=0;i<n;i++) { del[i] = (-cur_c/s)*del[i] * p[i]->w; p[i]->pos += del[i] * stiff; } }