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


C++ ConstraintSet::addConstraint方法代码示例

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


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

示例1: checkTypes

void checkTypes() {
  VariableIdMapping variableIdMapping;
  PState s1;
  cout << "RUNNING CHECKS:"<<endl;
  {
    // check temporary variables (create and delete)
    VariableId var_tmp=variableIdMapping.createUniqueTemporaryVariableId("tmp");
    variableIdMapping.deleteUniqueTemporaryVariableId(var_tmp);
  }

  {
    cout << "------------------------------------------"<<endl;
    cout << "RUNNING CHECKS FOR BOOLLATTICE TYPE:"<<endl;
    AType::BoolLattice a;
    a=true;
    check("a=true => isTrue",a.isTrue());
    AType::BoolLattice b;
    b=false;
    check("b=false => isFalse",b.isFalse());
    AType::BoolLattice c=a||b;
    check("c=a||b => c isTrue ",c.isTrue());
    AType::Top e;
    AType::BoolLattice d;
    d=e;
    check("Top e; d=e => d isTop",d.isTop());
    c=c||d;
    check("c=c||d: true",c.isTrue());
    AType::BoolLattice f=AType::Bot();
    d=AType::Bot();
    check("d=bot: bot",d.isBot());
    check("f=bot: bot",f.isBot());
    a=d&&f;
    check("a=d&&f => a isBot",a.isBot());
    f=false;
    check("f=false => f isFalse",f.isFalse());
    a=d&&f;
    check("a=d&&f: a isFalse (we define it this way)",a.isFalse());
  }

  {
    cout << "RUNNING CHECKS FOR CONSTINT LATTICE TYPE:"<<endl;
    AType::ConstIntLattice a;
    a=true;
    check("a=true => isTrue",a.isTrue());
    check("a=true => !isFalse",!a.isFalse());
    AType::ConstIntLattice b;
    b=false;
    check("b=false => isFalse",b.isFalse());
    check("b=false => !isTrue",!b.isTrue());
    AType::ConstIntLattice c=a.operatorOr(b);
    check("c=a.operatorOr(b): ",c.isTrue());
    AType::Top e;
    AType::ConstIntLattice d;
    d=e;
    check("Top e; d=e; d isTop ",d.isTop());
    c=c.operatorOr(d);
    check("c=c.operatorOr(d) => c isTrue ",c.isTrue());
    AType::ConstIntLattice f=AType::Bot();
    d=AType::Bot();
    
    a=d.operatorAnd(f);
    check("d=bot;f=bot;a=d.operatorAnd(f); => a isBot",a.isBot());
    f=false;
    a=d.operatorAnd(f);
    check("f=false; a=d.operatorAnd(f); => a isFalse",a.isFalse());
    a=5;
    check("a=5; a.isTrue()==true",a.isTrue()==true);
    check("a=5; a.isFalse()==false",a.isFalse()==false);

    a=0;
    check("a=0; a.isTrue()==false",a.isTrue()==false);
    check("a=0; a.isFalse())==true",a.isFalse()==true);
  }

  {
    cout << "------------------------------------------"<<endl;
    cout << "RUNNING CHECKS FOR CONSTRAINT TYPE:"<<endl;
    VariableId var_x=variableIdMapping.createUniqueTemporaryVariableId("x");
    VariableId var_y=variableIdMapping.createUniqueTemporaryVariableId("y");
    cout << "P1"<<endl;
    Constraint c1(Constraint::EQ_VAR_CONST,var_x,1);
    cout << "P2"<<endl;
    Constraint c2(Constraint::NEQ_VAR_CONST,var_y,2);
    cout << "P3"<<endl;
    Constraint c3=DISEQUALITYCONSTRAINT;
    cout << "P4"<<endl;
    Constraint c4=Constraint(Constraint::EQ_VAR_CONST,var_y,2);
    cout << "P5"<<endl;
    ConstraintSet cs;
    cout << "P6"<<endl;
    cs.addConstraint(c1);
    cout << "P7"<<endl;
    cout << "CS1:"<<cs.toString()<<endl;
    cs.addConstraint(c2);
    cout << "CS2:"<<cs.toString()<<endl;
    check("inserted 2 different constraints, size of constraint set == 3",cs.size()==2);
    check("c1:constraintExists(EQ_VAR_CONST,x,1) == true",cs.constraintExists(Constraint::EQ_VAR_CONST,var_x,1));
    check("c1:constraintExists(NEQ_VAR_CONST,x,1) == false",!cs.constraintExists(Constraint::NEQ_VAR_CONST,var_x,1));
    check("c2:constraintExists(NEQ_VAR_CONST,y,2) == true",cs.constraintExists(Constraint::NEQ_VAR_CONST,var_y,2));
    check("c3:isDisequality==false",cs.disequalityExists()==false);
//.........这里部分代码省略.........
开发者ID:8l,项目名称:rose,代码行数:101,代码来源:InternalChecks.C


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