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


Java Criterion.inc方法代码示例

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


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

示例1: updateCriterion

import org.cpsolver.ifs.criteria.Criterion; //导入方法依赖的package包/类
/**
 * Update value of FlexibleConstraintCriterion and number of violated FlexibleConstraints
 */
protected void updateCriterion(Assignment<Lecture, Placement> assignment) {
    if (!isHard()) {
        Criterion<Lecture, Placement> criterion = getModel().getCriterion(FlexibleConstraintCriterion.class);
        if (criterion != null) {
            criterion.inc(assignment, -iLastPreference);                
            iLastPreference = getCurrentPreference(assignment, null, null);
            criterion.inc(assignment, iLastPreference);  
        }
    }
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:14,代码来源:FlexibleConstraint.java

示例2: MaxHalfDaysFlexibleConstraintContext

import org.cpsolver.ifs.criteria.Criterion; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public MaxHalfDaysFlexibleConstraintContext(Assignment<Lecture, Placement> assignment) {
    super();
    iHalfDayAssignments = new Set[getNrHalfDays() * Constants.NR_DAYS];
    for (int i = 0; i < iHalfDayAssignments.length; i++)
        iHalfDayAssignments[i] = new HashSet<Lecture>();
    
    for (Lecture variable: variables()) {
        Placement value = assignment.getValue(variable);
        if (value != null) {
            for (int i = 0; i < Constants.DAY_CODES.length; i++)
                if ((value.getTimeLocation().getDayCode() & Constants.DAY_CODES[i]) != 0)
                    iHalfDayAssignments[i * getNrHalfDays() + getHalfDay(value.getTimeLocation())].add(value.variable());
        }
    }
    
    if (!isHard()) {
        Criterion<Lecture, Placement> criterion = getModel().getCriterion(FlexibleConstraintCriterion.class);
        if (criterion != null) {
            double pref = nrViolations(null, null);
            if (pref == 0)
                iLastPreference = -Math.abs(iPreference);
            else 
                iLastPreference = Math.abs(iPreference) * pref;
            criterion.inc(assignment, iLastPreference);  
        }
    }
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:29,代码来源:MaxHalfDaysFlexibleConstraint.java

示例3: MaxDaysFlexibleConstraintContext

import org.cpsolver.ifs.criteria.Criterion; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public MaxDaysFlexibleConstraintContext(Assignment<Lecture, Placement> assignment) {
    super();
    iDayAssignments = new Set[Constants.NR_DAYS];
    for (int i = 0; i < iDayAssignments.length; i++)
        iDayAssignments[i] = new HashSet<Lecture>();
    
    for (Lecture variable: variables()) {
        Placement value = assignment.getValue(variable);
        if (value != null) {
            for (int i = 0; i < iDayAssignments.length; i++)
                if ((value.getTimeLocation().getDayCode() & Constants.DAY_CODES[i]) != 0)
                    iDayAssignments[i].add(value.variable());
        }
    }
    
    if (!isHard()) {
        Criterion<Lecture, Placement> criterion = getModel().getCriterion(FlexibleConstraintCriterion.class);
        if (criterion != null) {
            double pref = nrViolations(null, null);
            if (pref == 0)
                iLastPreference = -Math.abs(iPreference);
            else 
                iLastPreference = Math.abs(iPreference) * pref;
            criterion.inc(assignment, iLastPreference);  
        }
    }
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:29,代码来源:MaxDaysFlexibleConstraint.java

示例4: MaxWeeksFlexibleConstraintContext

import org.cpsolver.ifs.criteria.Criterion; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public MaxWeeksFlexibleConstraintContext(Assignment<Lecture, Placement> assignment) {
    super();
    iWeeks = ((TimetableModel)getModel()).getWeeks();
    iWeekAssignments = new Set[iWeeks.size()];
    for (int i = 0; i < iWeekAssignments.length; i++)
        iWeekAssignments[i] = new HashSet<Lecture>();
    
    for (Lecture variable: variables()) {
        Placement value = assignment.getValue(variable);
        if (value != null && isCorectDayOfWeek(value)) {
            for (int i = 0; i < iWeeks.size(); i++)
                if (value.getTimeLocation().shareWeeks(iWeeks.get(i)))
                    iWeekAssignments[i].add(value.variable());
        }
    }
    
    if (!isHard()) {
        Criterion<Lecture, Placement> criterion = getModel().getCriterion(FlexibleConstraintCriterion.class);
        if (criterion != null) {
            double pref = nrViolations(null, null);
            if (pref == 0)
                iLastPreference = -Math.abs(iPreference);
            else 
                iLastPreference = Math.abs(iPreference) * pref;
            criterion.inc(assignment, iLastPreference);  
        }
    }
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:30,代码来源:MaxWeeksFlexibleConstraint.java

示例5: updateCriteria

import org.cpsolver.ifs.criteria.Criterion; //导入方法依赖的package包/类
/**
 * Update optimization criteria
 * @param assignment current assignment
 */
private void updateCriteria(Assignment<TeachingRequest.Variable, TeachingAssignment> assignment) {
    // update back-to-backs
    BackToBack b2b = (BackToBack)getModel().getCriterion(BackToBack.class);
    if (b2b != null) {
        b2b.inc(assignment, -iBackToBacks);
        iBackToBacks = countBackToBackPreference(b2b.getDifferentRoomWeight(), b2b.getDifferentTypeWeight());
        b2b.inc(assignment, iBackToBacks);
    }
    
    // update same-days
    SameDays sd = (SameDays)getModel().getCriterion(SameDays.class);
    if (sd != null) {
        sd.inc(assignment, -iSameDays);
        iSameDays = countSameDaysPreference(sd.getDifferentRoomWeight(), sd.getDifferentTypeWeight());
        sd.inc(assignment, iSameDays);
    }

    // update same-days
    SameRoom sr = (SameRoom)getModel().getCriterion(SameRoom.class);
    if (sr != null) {
        sr.inc(assignment, -iSameRooms);
        iSameRooms = countSameRoomPreference(sd.getDifferentTypeWeight());
        sr.inc(assignment, iSameRooms);
    }
    
    // update time overlaps
    Criterion<TeachingRequest.Variable, TeachingAssignment> overlaps = getModel().getCriterion(TimeOverlaps.class);
    if (overlaps != null) {
        overlaps.inc(assignment, -iTimeOverlaps);
        iTimeOverlaps = countTimeOverlaps();
        overlaps.inc(assignment, iTimeOverlaps);
    }
    
    // update same lectures
    Criterion<TeachingRequest.Variable, TeachingAssignment> diff = getModel().getCriterion(DifferentLecture.class);
    if (diff != null) {
        diff.inc(assignment, -iDifferentLectures);
        iDifferentLectures = countDifferentLectures();
        diff.inc(assignment, iDifferentLectures);
    }

    // update unused instructor load
    Criterion<TeachingRequest.Variable, TeachingAssignment> unused = getModel().getCriterion(UnusedInstructorLoad.class);
    if (unused != null) {
        unused.inc(assignment, -iUnusedLoad);
        iUnusedLoad = getUnusedLoad();
        unused.inc(assignment, iUnusedLoad);
    }
    
    // same course penalty
    Criterion<TeachingRequest.Variable, TeachingAssignment> sameCourse = getModel().getCriterion(SameCourse.class);
    if (sameCourse != null) {
        sameCourse.inc(assignment, -iSameCoursePenalty);
        iSameCoursePenalty = countSameCoursePenalty();
        sameCourse.inc(assignment, iSameCoursePenalty);
    }
    
    // same common penalty
    Criterion<TeachingRequest.Variable, TeachingAssignment> sameCommon = getModel().getCriterion(SameCommon.class);
    if (sameCommon != null) {
        sameCommon.inc(assignment, -iSameCommonPenalty);
        iSameCommonPenalty = countSameCommonPenalty();
        sameCommon.inc(assignment, iSameCommonPenalty);
    }
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:70,代码来源:Instructor.java


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