當前位置: 首頁>>代碼示例>>Java>>正文


Java GlobalConstraint類代碼示例

本文整理匯總了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);
}
 
開發者ID:UniTime,項目名稱:cpsolver,代碼行數:20,代碼來源:MultiCriteriaBranchAndBoundSelection.java

示例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;
}
 
開發者ID:UniTime,項目名稱:cpsolver,代碼行數:23,代碼來源:BranchBoundSelection.java


注:本文中的org.cpsolver.ifs.model.GlobalConstraint類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。