当前位置: 首页>>代码示例>>C++>>正文


C++ Constraint类代码示例

本文整理汇总了C++中Constraint的典型用法代码示例。如果您正苦于以下问题:C++ Constraint类的具体用法?C++ Constraint怎么用?C++ Constraint使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Constraint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: f

/*
 * Symmetrical to mergeLeft
 */
void Blocks::mergeRight(Block *l) {    
#ifdef LIBVPSC_LOGGING
    ofstream f(LOGFILE,ios::app);
    f<<"mergeRight called on "<<*l<<endl;
#endif    
    l->setUpOutConstraints();
    Constraint *c = l->findMinOutConstraint();
    while (c != NULL && c->slack()<0) {        
#ifdef LIBVPSC_LOGGING
        f<<"mergeRight on constraint: "<<*c<<endl;
#endif
        l->deleteMinOutConstraint();
        Block *r = c->right->block;
        r->setUpOutConstraints();
        double dist = c->left->offset + c->gap - c->right->offset;
        if (l->vars->size() > r->vars->size()) {
            dist=-dist;
            std::swap(l, r);
        }
        l->merge(r, c, dist);
        l->mergeOut(r);
        removeBlock(r);
        c=l->findMinOutConstraint();
    }    
#ifdef LIBVPSC_LOGGING
    f<<"merged "<<*l<<endl;
#endif
}
开发者ID:P-N-L,项目名称:adaptagrams,代码行数:31,代码来源:vpsc.cpp

示例2: VERBOSE_MSG

void RGFlow<Two_scale>::run_up()
{
   VERBOSE_MSG("> running tower up (iteration " << iteration << ") ...");
   const size_t number_of_models = models.size();
   for (size_t m = 0; m < number_of_models; ++m) {
      TModel* model = models[m];
      model->model->set_precision(get_precision());
      VERBOSE_MSG("> \tselecting model " << model->model->name());
      // apply all constraints
      const size_t n_upwards_constraints = model->upwards_constraints.size();
      for (size_t c = 0; c < n_upwards_constraints; ++c) {
         Constraint<Two_scale>* constraint = model->upwards_constraints[c];
         const double scale = constraint->get_scale();
         VERBOSE_MSG("> \t\tselecting constraint " << c << " at scale " << scale);
         VERBOSE_MSG("> \t\t\trunning model to scale " << scale);
         if (model->model->run_to(scale))
            throw NonPerturbativeRunningError(scale);
         VERBOSE_MSG("> \t\t\tapplying constraint");
         constraint->apply();
      }
      // apply matching condition if this is not the last model
      if (m != number_of_models - 1) {
         VERBOSE_MSG("> \tmatching to model " << models[m + 1]->model->name());
         Matching<Two_scale>* mc = model->matching_condition;
         mc->match_low_to_high_scale_model();
      }
   }
   VERBOSE_MSG("> running up finished");
}
开发者ID:McLenin,项目名称:gm2,代码行数:29,代码来源:two_scale_solver.cpp

示例3: OGDF_ASSERT

void ClusterPlanarity::outputCons(ofstream &os,
	StandardPool<Constraint, Variable> *connCon,
	StandardPool<Variable, Constraint> *stdVar)
{
	int i;
	for ( i = 0; i < connCon->number(); i++)
		{
			PoolSlot< Constraint, Variable > * sloty = connCon->slot(i);
			Constraint *mycon = sloty->conVar();
			OGDF_ASSERT(mycon != 0);
			int count;
			for (count = 0; count < stdVar->size(); count++)
			{
				PoolSlot< Variable, Constraint > * slotv = stdVar->slot(count);
				Variable *myvar = slotv->conVar();
				double d = mycon->coeff(myvar);
				if (d != 0.0) //precision!
				{
					os <<"+"<< d <<"x"<<count+1;
				}
			}//for
			switch (mycon->sense()->sense())
			{
				case CSense::Less: os << " <= "; break;
				case CSense::Greater: os << " >= "; break;
				case CSense::Equal: os << " = "; break;
				default: os << "Inequality sense doesn't make any sense \n";
						 cerr << "Inequality sense unknown \n";
						break;
			}//switch
			os << mycon->rhs();
			os << "\n";
		}
}
开发者ID:marvin2k,项目名称:ogdf,代码行数:34,代码来源:ClusterPlanarity.cpp

示例4: while

void VACExtension::enforcePass1()
{
    //  VACVariable* xi;
    VACVariable *xj;
    VACBinaryConstraint *cij;
    //if (ToulBar2::verbose > 1) cout << "VAC Enforce Pass 1" << endl;

    while (!VAC.empty()) {
        xj = (VACVariable *) VAC.pop_first();
        //list<Constraint*> l;
        for (ConstraintList::iterator itc = xj->getConstrs()->begin();
                itc != xj->getConstrs()->end(); ++itc) {
            Constraint *c = (*itc).constr;
            if (c->arity() == 2 && !c->isSep()) {
                cij = (VACBinaryConstraint *) c;
                //        xi = (VACVariable *)cij->getVarDiffFrom(xj);
                //if(xj->getMaxK(nbIterations) > 2) l.push_back(cij); else
                if (enforcePass1(xj, cij))
                    return;
            }
        }

        /*for (list<Constraint*>::iterator itl = l.begin(); itl != l.end(); ++itl) {
		   cij = (VACConstraint *) *itl;
		   if(enforcePass1(xj,cij)) return;
		   } */
    }
    inconsistentVariable = -1;
}
开发者ID:eomahony,项目名称:Numberjack,代码行数:29,代码来源:tb2vac.cpp

示例5: Constraint

void PropertyConstraintList::Restore(Base::XMLReader &reader)
{
    // read my element
    reader.readElement("ConstraintList");
    // get the value of my attribute
    int count = reader.getAttributeAsInteger("count");

    std::vector<Constraint*> values;
    values.reserve(count);
    for (int i = 0; i < count; i++) {
        Constraint *newC = new Constraint();
        newC->Restore(reader);
        // To keep upward compatibility ignore unknown constraint types
        if (newC->Type < Sketcher::NumConstraintTypes) {
            values.push_back(newC);
        }
        else {
            // reading a new constraint type which this version cannot handle
            delete newC;
        }
    }

    reader.readEndElement("ConstraintList");

    // assignment
    setValues(values);
    for (Constraint* it : values)
        delete it;
}
开发者ID:lanigb,项目名称:FreeCAD,代码行数:29,代码来源:PropertyConstraintList.cpp

示例6: while

void ConstraintSet::enforce_r(const vector<vector<double> > &r0,
                              vector<vector<double> > &rp)
{
  const bool oncoutpe = ctxt_.oncoutpe();
  int iter = 0;
  bool done = false;
  while ( !done && (iter < constraints_maxiter) )
  {
    done = true;
    for ( int i = 0; i < constraint_list.size(); i++ )
    {
      Constraint *c = constraint_list[i];
      bool b = c->enforce_r(r0,rp);
      done &= b;
    }
    iter++;
  }

  if ( !done )
  {
    if ( oncoutpe )
      cout << " ConstraintSet: could not enforce position constraints in "
           << constraints_maxiter << " iterations" << endl;
  }
}
开发者ID:xorJane,项目名称:qball,代码行数:25,代码来源:ConstraintSet.C

示例7: switch

/*! \return The bounding rectangle for the graphics used to represent
 * a constraint between points \a start and \a end (typically an
 * arrow)
 */
QRectF ItemDelegate::constraintBoundingRect( const QPointF& start, const QPointF& end, const Constraint &constraint ) const
{
    QPolygonF poly;
    QPointF e = end;
    switch ( constraint.relationType() ) {
        case Constraint::FinishStart:
            if ( constraint.endIndex().data( KDGantt::ItemTypeRole ).toInt() == KDGantt::TypeEvent ) {
                e.setX( e.x() - TURN );
            }
            poly = finishStartLine( start, e ) + finishStartArrow( start, e );
            break;
        case Constraint::FinishFinish:
            if ( constraint.endIndex().data( KDGantt::ItemTypeRole ).toInt() == KDGantt::TypeEvent ) {
                e.setX( e.x() + TURN );
            }
            poly = finishFinishLine( start, e ) + finishFinishArrow( start, e );
            break;
        case Constraint::StartStart:
            if ( constraint.endIndex().data( KDGantt::ItemTypeRole ).toInt() == KDGantt::TypeEvent ) {
                e.setX( e.x() - TURN );
            }
            poly = startStartLine( start, e ) + startStartArrow( start, e );
            break;
        case Constraint::StartFinish:
            if ( constraint.endIndex().data( KDGantt::ItemTypeRole ).toInt() == KDGantt::TypeEvent ) {
                e.setX( e.x() + TURN );
            }
            poly = startFinishLine( start, e ) + startFinishArrow( start, e );
            break;
        default:
            break;
    }
    return poly.boundingRect().adjusted( -PW, -PW, PW, PW );
}
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:38,代码来源:kdganttitemdelegate.cpp

示例8: ofs

void VACExtension::printTightMatrix()
{
    ofstream ofs("problem.dat");

    Cost Top = wcsp->getUb();
    for (unsigned int i = 0; i < wcsp->numberOfVariables(); i++) {
        for (unsigned int j = 0; j < wcsp->numberOfVariables(); j++) {
            if (i != j) {
                EnumeratedVariable *x =
                        (EnumeratedVariable *) wcsp->getVar(i);
                EnumeratedVariable *y =
                        (EnumeratedVariable *) wcsp->getVar(j);
                Constraint *bctr = x->getConstr(y);
                double t = 0;
                if (bctr)
                    t = bctr->getTightness();
                if (t > to_double(Top))
                    t = to_double(Top);
                t = t * 256.0 / to_double(Top);
                ofs << t << " ";
            } else
                ofs << 0 << " ";
        }
        ofs << endl;
    }
}
开发者ID:eomahony,项目名称:Numberjack,代码行数:26,代码来源:tb2vac.cpp

示例9: getSimulationThread

    void MainWindow::onConstraintItemSelectionChanged( ) {
        getSimulationThread().getSimulator().getLock().lockForRead();
        Creature* creature = getSimulationThread().getSimulator().currentCreature();
        if (creature) {
            for (int i = 0; i < getUiInspector().lst_constraints->count(); ++i) {
                if (!getUiInspector().lst_constraints->item(i)->isSelected()) {
                    continue;
                }
                Constraint* constraint = &creature->getConstraint(i);
                btVector3 angular_limits = constraint->getAngularLowerLimits();
                getUiInspector().sbx_lower_angular_dof_x->setValue(angular_limits.x());
                getUiInspector().sbx_lower_angular_dof_y->setValue(angular_limits.y());
                getUiInspector().sbx_lower_angular_dof_z->setValue(angular_limits.z());
                angular_limits = constraint->getAngularUpperLimits();
                getUiInspector().sbx_upper_angular_dof_x->setValue(angular_limits.x());
                getUiInspector().sbx_upper_angular_dof_y->setValue(angular_limits.y());
                getUiInspector().sbx_upper_angular_dof_z->setValue(angular_limits.z());

                if (getUiInspector().rbt_motor_x->isChecked()) {
                    loadConstraintValues(constraint, 0);
                }
                if (getUiInspector().rbt_motor_y->isChecked()) {
                    loadConstraintValues(constraint, 1);
                }
                if (getUiInspector().rbt_motor_z->isChecked()) {
                    loadConstraintValues(constraint, 2);
                }
            }
        }
        getSimulationThread().getSimulator().getLock().unlock();
    }
开发者ID:jcrada,项目名称:jcrada-creatures,代码行数:31,代码来源:OldMainWindowCreature.cpp

示例10: ShowStepDimension

void TextWindow::ShowStepDimension(void) {
    Constraint *c = SK.constraint.FindByIdNoOops(shown.constraint);
    if(!c) {
        shown.screen = SCREEN_LIST_OF_GROUPS;
        Show();
        return;
    }

    Printf(true, "%FtSTEP DIMENSION%E %s", c->DescriptionString());

    if(shown.dimIsDistance) {
        Printf(true,  "%Ba   %Ftstart%E    %s", SS.MmToString(c->valA));
        Printf(false, "%Bd   %Ftfinish%E   %s %Fl%Ll%f[change]%E",
            SS.MmToString(shown.dimFinish), &ScreenStepDimFinish);
    } else {
        Printf(true,  "%Ba   %Ftstart%E    %@", c->valA);
        Printf(false, "%Bd   %Ftfinish%E   %@ %Fl%Ll%f[change]%E",
            shown.dimFinish, &ScreenStepDimFinish);
    }
    Printf(false, "%Ba   %Ftsteps%E    %d %Fl%Ll%f%D[change]%E",
        shown.dimSteps, &ScreenStepDimSteps);

    Printf(true, " %Fl%Ll%fstep dimension now%E", &ScreenStepDimGo);

    Printf(true, "(or %Fl%Ll%fcancel operation%E)", &ScreenHome);
}
开发者ID:tc17,项目名称:solvespace-gtk,代码行数:26,代码来源:textscreens.cpp

示例11: main

int main(int argc, char** argv)
{
  const std::vector<FNVParam> fnvParams = FNVParam::getAll();
  const std::vector<FNVAlgo> fnvAlgos = FNVAlgo::getAll();
  const std::vector<Constraint> constraints = Constraint::getAll();

  BOOST_FOREACH(const FNVParam& fnvParam, fnvParams)
  {
    std::cout << "Problem size: " << fnvParam.getWidth() << std::endl;

    BOOST_FOREACH(const FNVAlgo& fnvAlgo, fnvAlgos)
    {
      std::cout << "Algorithm: FNV-" << fnvAlgo.getName() << std::endl;

      const Constraint nullConstraint = Constraint::getNull();
      std::cout << "Constraint: " << nullConstraint.getName() << std::endl;
      FNVSolver solver(fnvParam, fnvAlgo, nullConstraint);
      solver.solve();
      const int solutionLength = solver.getSolutionLength();

      BOOST_FOREACH(const Constraint& constraint, constraints)
      {
        std::cout << "Constraint: " << constraint.getName() << std::endl;
        FNVSolver solver(fnvParam, fnvAlgo, constraint, solutionLength);
        solver.solve();
      }
开发者ID:FrancisRussell,项目名称:fnv_solver,代码行数:26,代码来源:solver.cpp

示例12: generateNaryCtr

void naryRandom::generateNaryCtr( vector<int>& indexs, long nogoods, Cost costMin, Cost costMax)
{
    int i;
    int arity = indexs.size();
    EnumeratedVariable** scopeVars = new EnumeratedVariable * [arity];
    int* scopeIndexs = new int [arity];
    Char* tuple = new Char [arity+1];
    Cost Top = wcsp.getUb();
    if(costMax < Top) Top = costMax;

    for(i = 0; i<arity; i++) {
        scopeIndexs[i] = indexs[i];
        scopeVars[i] = (EnumeratedVariable*) wcsp.getVar(indexs[i]);
        tuple[i] = 0 + CHAR_FIRST;
    }
    tuple[arity] = '\0';

    Constraint* nctr =  wcsp.getCtr( wcsp.postNaryConstraintBegin(scopeIndexs, arity, Top) );

    String s(tuple);
    while(nogoods>0) {
        for(i = 0; i<arity; i++) s[i] = myrand() % scopeVars[i]->getDomainInitSize() + CHAR_FIRST;
        Cost c = ToulBar2::costMultiplier * randomCost(MIN_COST, costMax);
        nctr->setTuple(s, c, scopeVars);
        nogoods--;
    }
    nctr->propagate();

    delete [] scopeIndexs;
    delete [] scopeVars;
    delete [] tuple;
}
开发者ID:Alexander-Schiendorfer,项目名称:Numberjack,代码行数:32,代码来源:tb2randomgen.cpp

示例13: MakeJointMask

//this function does 2 things
//1. Fills this bipartition with the bitwise intersection of a backbone mask and a mask
//representing a subset of taxa in a growing tree.  Note that it is safe to call this when the
//constraint is not a backbone and/or when the partialMask is NULL.  In that case it will fill
//the bipartition with one or the other, or with all bits on if their if neither 
//2. Checks if there is a meaningful intersection between the created joint mask and 
//the constraint.  That means at least 2 bits are "on" on each site of the constrained bipartition
bool Bipartition::MakeJointMask(const Constraint &constr, const Bipartition *partialMask){
	if(constr.IsBackbone()){
		//this just uses Bipartition::Operator=()
		*this = *(constr.GetBackboneMask());
		if(partialMask != NULL)//in this case we'll need to test for meaningful intersection below
			this->AndEquals(*partialMask);
		else//here we don't need to check, since a backbone constraint and its own mask must be meaningful
			return true;
		}
	else if(partialMask != NULL){
		//in this case we'll need to test for meaningful intersection below
		*this = *(partialMask);
		}
	else{
		FillAllBits();
		return true;
		}

	Bipartition temp;
	temp = constr.GetBipartition();
	temp.AndEquals(*this);
	if(temp.MoreThanOneBitSet() == false)
		return false;

	temp = constr.GetBipartition();
	temp.Complement();
	temp.AndEquals(*this);
	if(temp.MoreThanOneBitSet() == false)
		return false;

	return true;
	}
开发者ID:rekepalli,项目名称:garli,代码行数:39,代码来源:bipartition.cpp

示例14: Q_UNUSED

void ItemDelegate::paintStartFinishConstraint( QPainter* painter, const QStyleOptionGraphicsItem& opt, const QPointF& start, const QPointF& end, const Constraint &constraint )
{
    Q_UNUSED( opt );

    QPen pen;
    QVariant dataPen;

    // default pens
    if ( start.x() <= end.x() ) {
        pen = QPen( Qt::black );
        dataPen = constraint.data( Constraint::ValidConstraintPen );
    } else {
        pen = QPen( Qt::red );
        dataPen = constraint.data( Constraint::InvalidConstraintPen );
    }

    // data() pen
    if( qVariantCanConvert< QPen >( dataPen ) )
        pen = qVariantValue< QPen >( dataPen );

    painter->setPen( pen );
    painter->setBrush( pen.color() );

    QPointF e = end;
    if ( constraint.endIndex().data( KDGantt::ItemTypeRole ).toInt() == KDGantt::TypeEvent ) {
        e.setX( e.x() + TURN );
    }
    painter->drawPolyline( startFinishLine( start, e ) );
    painter->drawPolygon( startFinishArrow( start, e ) );
}
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:30,代码来源:kdganttitemdelegate.cpp

示例15: rcpFromRef

  void SteepestDescentSolver<Scalar, LocalOrdinal, GlobalOrdinal, Node, LocalMatOps>::Iterate(const Matrix& Aref, const Constraint& C, const Matrix& P0, RCP<Matrix>& P) const {
    RCP<const Matrix> A = rcpFromRef(Aref);
    RCP<Matrix> AP, G;

    Teuchos::FancyOStream& mmfancy = this->GetOStream(Statistics2, 0);

    Teuchos::ArrayRCP<const SC> D = Utils::GetMatrixDiagonal(*A);

    RCP<CrsMatrix> Ptmp_ = CrsMatrixFactory::Build(C.GetPattern());
    Ptmp_->fillComplete(P0.getDomainMap(), P0.getRangeMap());
    RCP<Matrix>    Ptmp  = rcp(new CrsMatrixWrap(Ptmp_));

    // Initial P0 would only be used for multiplication
    P = rcp_const_cast<Matrix>(rcpFromRef(P0));

    for (size_t k = 0; k < nIts_; k++) {
      AP = Utils::Multiply(*A, false, *P, false, mmfancy, true, false);
#if 0
      // gradient = -2 A^T * A * P
      SC stepLength = 2*stepLength_;
      G = Utils::Multiply(*A, true, *AP, false, true, true);
      C.Apply(*G, *Ptmp);
#else
      // gradient = - A * P
      SC stepLength = stepLength_;
      Utils::MyOldScaleMatrix(*AP, D, true, false, false);
      C.Apply(*AP, *Ptmp);
#endif

      RCP<Matrix> newP;
      Utils2::TwoMatrixAdd(*Ptmp, false, -stepLength, *P, false, Teuchos::ScalarTraits<Scalar>::one(), newP, mmfancy);
      newP->fillComplete(P->getDomainMap(), P->getRangeMap() );
      P = newP;
    }
  }
开发者ID:gitter-badger,项目名称:quinoa,代码行数:35,代码来源:MueLu_SteepestDescentSolver_def.hpp


注:本文中的Constraint类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。