用于从ILOG集合中的对象设置变量的等效Drools语法

用于从ILOG集合中的对象设置变量的等效Drools语法,drools,ilog,jrules,Drools,Ilog,Jrules,在我们的ILOG规则irl文件中,我们多次从集合中设置变量,并从集合中设置不等于第一个对象的另一个变量 student1: com.company.bom.Student() in all_students; student2: com.company.bom.Student(!(?this.equals(student2))) in all_students; 在ILOG中,这些行是否只返回集合中的第一个和第二个对象 以下是在drl规则文件中的Drools中执行相同操作的最佳方法吗 stud

在我们的ILOG规则irl文件中,我们多次从集合中设置变量,并从集合中设置不等于第一个对象的另一个变量

student1: com.company.bom.Student() in all_students;
student2: com.company.bom.Student(!(?this.equals(student2))) in all_students;
在ILOG中,这些行是否只返回集合中的第一个和第二个对象

以下是在drl规则文件中的Drools中执行相同操作的最佳方法吗

student1: com.company.bom.Student() from all_students.get(0);
student2: com.company.bom.Student() from all_students.get(1);

你应该能够检查你的ILOG做了什么,所以我只是回答流口水的部分

在Drools中,可以使用
from
从reach中的某个集合中获取对象。因此,你确实可以写作

University( $roster: roster )
$student1: Student() from $roster.get(0)
$student2: Student() from $roster.get(1)
此规则对花名册集合中的前两名学生触发一次,但如果少于两名学生,则必然引发例外

University( $roster: roster )
$student1: Student() from $roster
$student2: Student( this != $student1 ) from $roster
这条规则针对不同学生的每一个有序配对触发,其中一个特定配对导致两条规则触发