跳至主内容
框架 无框架

类IloIntBinaryPredicate

定义文件: ilconcert/ilotupleset.h
IloIntBinaryPredicate的地图IloIntBinaryPredicateIloIntBinaryPredicate
用于约束编程:对模型中任意对象操作的二元谓词。

通过该类,您可以对模型中的任意对象定义二元谓词。 谓词是一个对象,带有一个成员函数(如 "IloIntBinaryPredicate::isTrue),用于检查有序的对象(指针)集合是否满足某个属性。

定义新的谓词类别

谓词与 Concert Technology 的其他对象一样,依赖于两个类:一个句柄类("IloIntBinaryPredicate)和一个实现类(如 "IloIntBinaryPredicateI),其中句柄类对象包含一个数据成员(句柄指针),该数据成员指向 Concert Technology 环境中分配的 "IloIntBinaryPredicateI实例的一个对象(其实现对象)。 作为 Concert Technology 的用户,您将主要使用手柄。

如果自行定义新的谓词类,则必须定义其实现类和相应的虚拟成员函数 "isTrue,以及返回句柄类实例的成员函数 "IloIntBinaryPredicate

元数

作为开发人员,您可以在 Concert Technology 应用程序中使用谓词来定义 Concert Technology 中尚未预定义的约束条件。 在这种情况下,谓词的迭代数(即谓词中涉及的受限变量的个数,也就是成员函数 "IloIntBinaryPredicate::isTrue必须检查的数组的大小)必须是 2。

另请参阅CP 优化器参考手册》中的这些类: IloAllowedAssignments' , 'IloForbiddenAssignments

另请参阅IBMILOG 求解器参考手册》中的这些类: IloTableConstraint.

方法概要
public IloIntBinaryPredicateI *getImpl() const
public IloIntBinaryPredicate()
public IloIntBinaryPredicate(IloIntBinaryPredicateI * impl)
public IloBoolisTrue(const IloInt val1, const IloInt val2)
public voidoperator=(const IloIntBinaryPredicate & h)
方法详细信息

IloIntBinaryPredicate

publicIloIntBinaryPredicate()

该构造函数创建一个空的二元谓词。 换句话说,谓词是一个空句柄,句柄指针为空。 在尝试访问谓词之前,必须先分配谓词的元素,就像访问其他指针一样。 如果在赋值之前试图访问它,则会出现异常("IloSolver::SolverErrorException实例)。


IloIntBinaryPredicate

publicIloIntBinaryPredicate(IloIntBinaryPredicateI *impl)

该构造函数通过指向实现对象(实现类 "IlcIntPredicateI的实例,记录在 "CP 优化器参考手册和 "IBMILOG 求解器参考手册中)的指针创建一个句柄对象(类 "IloIntBinaryPredicate的实例)。


getImpl

publicIloIntBinaryPredicateI*getImpl() const

该成员函数返回一个指向调用句柄的实现对象的指针。


isTrue

publicIloBool isTrue(constIloInt val1, constIloInt val2)

如果值 "val1和 "val2使调用的二进制谓词有效,则该成员函数返回 "IloTrue。 否则返回 "IloFalse


Operator=

public voidoperator=(constIloIntBinaryPredicate&h)

该赋值操作符通过为调用对象的句柄指针赋值,将 "h复制到调用谓词中。 该地址是参数 "h的执行对象的位置。 执行此操作符后,调用谓词和 "h都指向同一个执行对象。