本文整理匯總了Java中org.cpsolver.ifs.model.GlobalConstraint類的典型用法代碼示例。如果您正苦於以下問題:Java GlobalConstraint類的具體用法?Java GlobalConstraint怎麽用?Java GlobalConstraint使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
GlobalConstraint類屬於org.cpsolver.ifs.model包,在下文中一共展示了GlobalConstraint類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: inConflict
import org.cpsolver.ifs.model.GlobalConstraint; //導入依賴的package包/類
/** True if the enrollment is conflicting */
public boolean inConflict(final int idx, final Enrollment enrollment) {
for (GlobalConstraint<Request, Enrollment> constraint : enrollment.variable().getModel().globalConstraints())
if (constraint.inConflict(iAssignment, enrollment))
return true;
for (LinkedSections linkedSections : iStudent.getLinkedSections()) {
if (linkedSections.inConflict(enrollment, new LinkedSections.EnrollmentAssignment() {
@Override
public Enrollment getEnrollment(Request request, int index) {
return (index == idx ? enrollment : iCurrentAssignment[index]);
}
}) != null)
return true;
}
for (int i = 0; i < iCurrentAssignment.length; i++)
if (iCurrentAssignment[i] != null && i != idx && iCurrentAssignment[i].isOverlapping(enrollment))
return true;
return !isAllowed(idx, enrollment);
}
示例2: inConflict
import org.cpsolver.ifs.model.GlobalConstraint; //導入依賴的package包/類
/** True if the enrollment is conflicting
* @param idx index of request
* @param enrollment enrollment in question
* @return true if there is a conflict with previous enrollments
**/
public boolean inConflict(final int idx, final Enrollment enrollment) {
for (GlobalConstraint<Request, Enrollment> constraint : enrollment.variable().getModel().globalConstraints())
if (constraint.inConflict(iCurrentAssignment, enrollment))
return true;
for (LinkedSections linkedSections: iStudent.getLinkedSections()) {
if (linkedSections.inConflict(enrollment, new LinkedSections.EnrollmentAssignment() {
@Override
public Enrollment getEnrollment(Request request, int index) {
return (index == idx ? enrollment : iAssignment[index]);
}
}) != null) return true;
}
for (int i = 0; i < iAssignment.length; i++)
if (iAssignment[i] != null && i != idx && iAssignment[i].isOverlapping(enrollment))
return true;
return false;
}