本文整理汇总了Java中org.cpsolver.coursett.Constants.sPreferenceLevelRequired方法的典型用法代码示例。如果您正苦于以下问题:Java Constants.sPreferenceLevelRequired方法的具体用法?Java Constants.sPreferenceLevelRequired怎么用?Java Constants.sPreferenceLevelRequired使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.cpsolver.coursett.Constants
的用法示例。
在下文中一共展示了Constants.sPreferenceLevelRequired方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
}
示例2: 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();
}
}
示例3: 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;
}
示例4: 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;
}
示例5: 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);
}
示例6: isRequired
import org.cpsolver.coursett.Constants; //导入方法依赖的package包/类
/**
* Is required?
* @return true if the preference is required
*/
public boolean isRequired() { return iPreference < Constants.sPreferenceLevelRequired / 2; }