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


Java Constants.sPreferenceLevelProhibited方法代码示例

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


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

示例1: getAttributePreference

import org.cpsolver.coursett.Constants; //导入方法依赖的package包/类
/**
 * Compute attribute preference for the given instructor and attribute type
 * @param instructor an instructor
 * @param type an attribute type
 * @return combined preference using {@link Attribute.Type#isConjunctive()} and {@link Attribute.Type#isRequired()} properties
 */
public int getAttributePreference(Instructor instructor, Attribute.Type type) {
    Set<Attribute> attributes = instructor.getAttributes(type);
    boolean hasReq = false, hasPref = false, needReq = false, hasType = false;
    PreferenceCombination ret = new SumPreferenceCombination();
    for (Preference<Attribute> pref: iAttributePreferences) {
        if (!type.equals(pref.getTarget().getType())) continue;
        hasType = true;
        if (pref.isRequired()) needReq = true;
        if (attributes.contains(pref.getTarget())) {
            if (pref.isProhibited()) return Constants.sPreferenceLevelProhibited;
            else if (pref.isRequired()) hasReq = true;
            else ret.addPreferenceInt(pref.getPreference());
            hasPref = true;
        } else {
            if (pref.isRequired() && type.isConjunctive()) return Constants.sPreferenceLevelProhibited;
        }
    }
    if (needReq && !hasReq) return Constants.sPreferenceLevelProhibited;
    if (type.isRequired() && hasType && !hasPref) return Constants.sPreferenceLevelProhibited;
    if (!type.isRequired() && hasType && !hasPref) return 16;
    return ret.getPreferenceInt();
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:29,代码来源:TeachingRequest.java

示例2: isConsistent

import org.cpsolver.coursett.Constants; //导入方法依赖的package包/类
@Override
public boolean isConsistent(Placement p1, Placement p2) {
    if (p1.canShareRooms(p2) && p1.sameRooms(p2))
        return true;
    if (p1.getTimeLocation().hasIntersection(p2.getTimeLocation()))
        return false;
    return getDistancePreference(p1, p2) != Constants.sPreferenceLevelProhibited;
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:9,代码来源:InstructorConstraint.java

示例3: getMinMaxRoomPreference

import org.cpsolver.coursett.Constants; //导入方法依赖的package包/类
public int[] getMinMaxRoomPreference() {
    iLock.readLock().lock();
    try {
        if (iMinMaxRoomPreference != null) return iMinMaxRoomPreference;
    } finally {
        iLock.readLock().unlock();
    }
    iLock.writeLock().lock();
    try {
        if (iMinMaxRoomPreference != null) return iMinMaxRoomPreference;

        if (getNrRooms() <= 0 || roomLocations().isEmpty()) {
            iMinMaxRoomPreference = new int[] { 0, 0 };
        } else {
            Integer minRoomPref = null, maxRoomPref = null;
            for (RoomLocation r : roomLocations()) {
                int pref = r.getPreference();
                if (pref >= Constants.sPreferenceLevelRequired / 2 && pref <= Constants.sPreferenceLevelProhibited / 2) {
                    minRoomPref = (minRoomPref == null ? pref : Math.min(minRoomPref, pref));
                    maxRoomPref = (maxRoomPref == null ? pref : Math.max(maxRoomPref, pref));
                }
            }
            iMinMaxRoomPreference = new int[] { minRoomPref == null ? 0 : minRoomPref, maxRoomPref == null ? 0 : maxRoomPref };
        }

        return iMinMaxRoomPreference;
    } finally {
        iLock.writeLock().unlock();
    }
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:31,代码来源:Lecture.java

示例4: getMinMaxTimePreference

import org.cpsolver.coursett.Constants; //导入方法依赖的package包/类
public double[] getMinMaxTimePreference() {
    iLock.readLock().lock();
    try {
        if (iMinMaxTimePreference != null) return iMinMaxTimePreference;
    } finally {
        iLock.readLock().unlock();
    }
    iLock.writeLock().lock();
    try {
        if (iMinMaxTimePreference != null) return iMinMaxTimePreference;

        Double minTimePref = null, maxTimePref = null;
        for (TimeLocation t : timeLocations()) {
            double npref = t.getNormalizedPreference();
            int pref = t.getPreference();
            if (pref >= Constants.sPreferenceLevelRequired / 2 && pref <= Constants.sPreferenceLevelProhibited / 2) {
                minTimePref = (minTimePref == null ? npref : Math.min(minTimePref, npref));
                maxTimePref = (maxTimePref == null ? npref : Math.max(maxTimePref, npref));
            }
        }
        iMinMaxTimePreference = new double[] { minTimePref == null ? 0.0 : minTimePref, maxTimePref == null ? 0.0 : maxTimePref };
        
        return iMinMaxTimePreference;
    } finally {
        iLock.writeLock().unlock();
    }
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:28,代码来源:Lecture.java

示例5: getTimePenalty

import org.cpsolver.coursett.Constants; //导入方法依赖的package包/类
public double getTimePenalty() {
    if (iTimeLocation == null) return 0.0;
    if (iTimePenalty == null) {
        double[] bounds = variable().getMinMaxTimePreference();
        double npref = iTimeLocation.getNormalizedPreference();
        if (iTimeLocation.getPreference() < Constants.sPreferenceLevelRequired / 2) npref = bounds[0];
        else if (iTimeLocation.getPreference() > Constants.sPreferenceLevelProhibited / 2) npref = bounds[1];
        iTimePenalty = npref - bounds[0];
    }
    return iTimePenalty;
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:12,代码来源:Placement.java

示例6: getRoomPenalty

import org.cpsolver.coursett.Constants; //导入方法依赖的package包/类
public int getRoomPenalty() {
    if (getNrRooms() == 0) return 0;
    if (iRoomPenalty == null) {
        int pref = getRoomPreference();
        int[] bounds = variable().getMinMaxRoomPreference();
        if (pref < Constants.sPreferenceLevelRequired / 2) pref = bounds[0];
        if (pref > Constants.sPreferenceLevelProhibited / 2) pref = bounds[1];
        iRoomPenalty = pref - bounds[0];
    }
    return iRoomPenalty;
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:12,代码来源:Placement.java

示例7: string2preference

import org.cpsolver.coursett.Constants; //导入方法依赖的package包/类
/** Convert preference string to a preference value */
protected static int string2preference(String pref) {
    if (pref == null || pref.isEmpty()) return 0;
    if (Constants.sPreferenceRequired.equals(pref))
        return Constants.sPreferenceLevelRequired;
    if (Constants.sPreferenceProhibited.equals(pref))
        return Constants.sPreferenceLevelProhibited;
    return Integer.valueOf(pref);
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:10,代码来源:InstructorSchedulingModel.java

示例8: violation

import org.cpsolver.coursett.Constants; //导入方法依赖的package包/类
@Override
protected boolean violation(Placement value) {
    int pref = value.getTimeLocation().getPreference();
    return pref > Constants.sPreferenceLevelProhibited / 2;
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:6,代码来源:TimeViolations.java

示例9: violation

import org.cpsolver.coursett.Constants; //导入方法依赖的package包/类
protected boolean violation(Placement value) {
    int pref = value.getRoomPreference();
    return pref > Constants.sPreferenceLevelProhibited / 2;
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:5,代码来源:RoomViolations.java

示例10: isProhibited

import org.cpsolver.coursett.Constants; //导入方法依赖的package包/类
/**
 * Is prohibited?
 * @return true if the preference is prohibited
 */
public boolean isProhibited() { return iPreference > Constants.sPreferenceLevelProhibited / 2; }
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:6,代码来源:Preference.java


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