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


Java Constants类代码示例

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


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

示例1: distance

import org.cpsolver.coursett.Constants; //导入依赖的package包/类
public int distance(DistanceMetric m, Section s1, Section s2) {
    if (s1.getPlacement()==null || s2.getPlacement()==null) return 0;
    TimeLocation t1 = s1.getTime();
    TimeLocation t2 = s2.getTime();
    if (!t1.shareDays(t2) || !t1.shareWeeks(t2)) return 0;
    int a1 = t1.getStartSlot(), a2 = t2.getStartSlot();
    if (m.doComputeDistanceConflictsBetweenNonBTBClasses()) {
    	if (a1 + t1.getNrSlotsPerMeeting() <= a2) {
    		int dist = Placement.getDistanceInMinutes(m, s1.getPlacement(), s2.getPlacement());
    		if (dist > t1.getBreakTime() + Constants.SLOT_LENGTH_MIN * (a2 - a1 - t1.getLength()))
    			return dist;
    	}
    } else {
    	if (a1+t1.getNrSlotsPerMeeting()==a2)
    		return Placement.getDistanceInMinutes(m, s1.getPlacement(), s2.getPlacement());
    }
    return 0;
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:19,代码来源:XOffering.java

示例2: getDistanceInMinutes

import org.cpsolver.coursett.Constants; //导入依赖的package包/类
public int getDistanceInMinutes(XSection other, DistanceMetric m) {
if (getNrRooms() == 0 || other.getNrRooms() == 0) return 0;
XTime t1 = getTime();
XTime t2 = other.getTime();
if (t1 == null || t2 == null || !t1.shareDays(t2) || !t1.shareWeeks(t2)) return 0;
      int a1 = t1.getSlot(), a2 = t2.getSlot();
      if (m.doComputeDistanceConflictsBetweenNonBTBClasses()) {
      	if (a1 + t1.getLength() <= a2) {
      		int dist = getDistanceInMinutes(m, other.getRooms());
      		if (dist > t1.getBreakTime() + Constants.SLOT_LENGTH_MIN * (a2 - a1 - t1.getLength()))
      			return dist;
      	}
      } else {
      	if (a1 + t1.getLength() == a2)
      		return getDistanceInMinutes(m, other.getRooms());
      }
      return 0;
  }
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:19,代码来源:XSection.java

示例3: getInstructor

import org.cpsolver.coursett.Constants; //导入依赖的package包/类
protected InstructorInfo getInstructor(TeachingRequest tr, TeachingRequestInfo request, DepartmentalInstructor instructor, List<InstructorAssignment> assignments, Context context) {
	InstructorInfo info = getInstructor(request, instructor, context.getNameFormat());
	if (context.getSolver() != null) {
		InstructorInfo i = context.getSolver().getInstructorInfo(instructor.getUniqueId());
		info.setAssignedLoad(i == null ? 0f : i.getAssignedLoad());
	} else {
   		Number load = ((Number)TeachingRequestDAO.getInstance().getSession().createQuery(
   				"select sum(r.teachingLoad) from TeachingRequest r inner join r.assignedInstructors i where i.uniqueId = :instructorId")
   				.setLong("instructorId", instructor.getUniqueId()).setCacheable(true).uniqueResult());
       	info.setAssignedLoad(load == null ? 0f : load.floatValue());
	}
	if (info.getTeachingPreference() != null && !PreferenceLevel.sNeutral.equals(info.getTeachingPreference()))
		info.setValue("Teaching Preferences", Constants.preference2preferenceLevel(info.getTeachingPreference()));
	info.setValue("Time Preferences", getTimePreference(instructor, tr).getPreferenceInt());
	info.setValue("Course Preferences", Constants.preference2preferenceLevel(getCoursePreference(instructor, tr)));
	info.setValue("Instructor Preferences", Constants.preference2preferenceLevel(getInstructorPreference(instructor, tr)));
	info.setValue("Attribute Preferences", getAttributePreference(instructor, tr, context.getAttributeTypes()).getPreferenceInt());
	info.setValue("Same Course", Constants.preference2preferenceLevel(getSameCoursePreference(instructor, tr, assignments)));
	info.setValue("Same Common", Constants.preference2preferenceLevel(getSameCommonPreference(instructor, tr, assignments)));
	return info;
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:22,代码来源:InstructorSchedulingBackendHelper.java

示例4: BreakFlexibleConstraint

import org.cpsolver.coursett.Constants; //导入依赖的package包/类
/**
 * 
 * @param id constraint unique id
 * @param owner identifier of distribution preference the constraint was created for
 * @param preference time preference ("R" for required, "P" for prohibited, "-2",
 *            "-1", "1", "2" for soft preference)   
 * @param reference parameters of the constraint in String form            
 */
public BreakFlexibleConstraint(Long id, String owner, String preference, String reference) {
    super(id, owner, preference, reference);     
    
    Pattern pattern = null;
    Matcher matcher = null;   
    
    // recognize Break constraint        
    String patternString = "_(Break):([0-9]+):([0-9]+):([0-9]+)_";
    pattern = Pattern.compile(patternString);
    matcher = pattern.matcher(reference);
    if (matcher.find()) {                
        iBreakStart = Integer.parseInt(matcher.group(2));
        iBreakEnd = Integer.parseInt(matcher.group(3)); 
        iBreakLength = Integer.parseInt(matcher.group(4))/Constants.SLOT_LENGTH_MIN; 
        iConstraintType = FlexibleConstraintType.BREAK;           
    }   
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:26,代码来源:BreakFlexibleConstraint.java

示例5: getNrViolations

import org.cpsolver.coursett.Constants; //导入依赖的package包/类
@Override
public double getNrViolations(Assignment<Lecture, Placement> assignment, Set<Placement> conflicts, HashMap<Lecture, Placement> assignments){
    List<BitSet> weeks = getWeeks();

    int violatedDays = 0;
    for (int dayCode : Constants.DAY_CODES) {
        weekIteration: for (BitSet week : weeks) {
            Set<Placement> adepts = new HashSet<Placement>();
            List<Block> blocks = getBreakBlocks(assignment, dayCode, null, null, assignments, week);
            getAdeptsLunchBreak(blocks, adepts);
            if (!adepts.isEmpty())
                violatedDays++;
            break weekIteration;
        }
    }
    return violatedDays;
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:18,代码来源:BreakFlexibleConstraint.java

示例6: getNrViolations

import org.cpsolver.coursett.Constants; //导入依赖的package包/类
@Override
public double getNrViolations(Assignment<Lecture, Placement> assignment, Set<Placement> conflicts, HashMap<Lecture, Placement> assignments) {
    List<BitSet> weeks = getWeeks();

    int violatedBlocks = 0;
    for (int dayCode : Constants.DAY_CODES) {
        for (BitSet week : weeks) {
            List<Block> blocks = getBlocks(assignment, dayCode, null, null, assignments, week);
            for (Block block : blocks) {
                if (block.getNbrPlacements() == 1 || block.haveSameStartTime())
                    continue;
                // violated if there is a block containing more than one
                // class longer than iMaxBlockSlotsBTB
                if (block.getLengthInSlots() > iMaxBlockSlotsBTB) {
                    int blockLengthPenalty = block.getLengthInSlots() / iMaxBlockSlotsBTB;
                    violatedBlocks += blockLengthPenalty;
                }
            }
        }
    }
    return violatedBlocks;
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:23,代码来源:MaxBlockFlexibleConstraint.java

示例7: isNrDaysBetweenGreaterThanOne

import org.cpsolver.coursett.Constants; //导入依赖的package包/类
private boolean isNrDaysBetweenGreaterThanOne(TimeLocation t1, TimeLocation t2) {
    int f1 = -1, f2 = -1, e1 = -1, e2 = -1;
    for (int i = 0; i < Constants.DAY_CODES.length; i++) {
        int idx = (i + iFirstWorkDay) % 7;
        if ((t1.getDayCode() & Constants.DAY_CODES[idx]) != 0) {
            if (f1 < 0)
                f1 = i;
            e1 = i;
        }
        if ((t2.getDayCode() & Constants.DAY_CODES[idx]) != 0) {
            if (f2 < 0)
                f2 = i;
            e2 = i;
        }
    }
    return (e1 - f2 > 2) || (e2 - f1 > 2);
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:18,代码来源:GroupConstraint.java

示例8: setNotAvailable

import org.cpsolver.coursett.Constants; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void setNotAvailable(Placement placement) {
    if (iAvailable == null) {
        iAvailable = new List[Constants.SLOTS_PER_DAY * Constants.NR_DAYS];
        for (int i = 0; i < iAvailable.length; i++)
            iAvailable[i] = null;
    }
    for (Enumeration<Integer> e = placement.getTimeLocation().getSlots(); e.hasMoreElements();) {
        int slot = e.nextElement();
        if (iAvailable[slot] == null)
            iAvailable[slot] = new ArrayList<Placement>(1);
        iAvailable[slot].add(placement);
    }
    for (Lecture lecture: variables())
        lecture.clearValueCache();
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:17,代码来源:RoomConstraint.java

示例9: RoomConstraintContext

import org.cpsolver.coursett.Constants; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public RoomConstraintContext(Assignment<Lecture, Placement> assignment) {
    iResource = new List[Constants.SLOTS_PER_DAY * Constants.NR_DAYS];
    for (int i = 0; i < iResource.length; i++)
        iResource[i] = new ArrayList<Placement>(3);
    for (Lecture lecture: variables()) {
        Placement placement = assignment.getValue(lecture);
        if (placement != null && placement.hasRoomLocation(getResourceId())) {
            for (Enumeration<Integer> e = placement.getTimeLocation().getSlots(); e.hasMoreElements();) {
                int slot = e.nextElement();
                iResource[slot].add(placement);
            }
        }
    }
    iLastUselessHalfHours = UselessHalfHours.countUselessSlotsHalfHours(this);
    getModel().getCriterion(UselessHalfHours.class).inc(assignment, iLastUselessHalfHours);
    iLastBrokenTimePatterns = BrokenTimePatterns.countUselessSlotsBrokenTimePatterns(this) / 6.0;
    getModel().getCriterion(BrokenTimePatterns.class).inc(assignment, iLastBrokenTimePatterns);
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:20,代码来源:RoomConstraint.java

示例10: getPenaltyIfUnassigned

import org.cpsolver.coursett.Constants; //导入依赖的package包/类
private int getPenaltyIfUnassigned(Assignment<Lecture, Placement> assignment, Placement placement, int[][] nrCourses) {
    SpreadConstraintContext context = getContext(assignment);
    int firstSlot = placement.getTimeLocation().getStartSlot();
    if (firstSlot > iLastDaySlot)
        return 0;
    int endSlot = firstSlot + placement.getTimeLocation().getNrSlotsPerMeeting() - 1;
    if (endSlot < iFirstDaySlot)
        return 0;
    int penalty = 0;
    for (int i = Math.max(firstSlot, iFirstDaySlot); i <= Math.min(endSlot, iLastDaySlot); i++) {
        for (int j = iFirstWorkDay; j <= iLastWorkDay; j++) {
            int dayCode = Constants.DAY_CODES[j % 7];
            if ((dayCode & placement.getTimeLocation().getDayCode()) != 0 && nrCourses[i - iFirstDaySlot][j - iFirstWorkDay] > context.getMaxCourses(i, j))
                penalty++;
        }
    }
    return penalty;
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:19,代码来源:SpreadConstraint.java

示例11: tryUnassign

import org.cpsolver.coursett.Constants; //导入依赖的package包/类
private int tryUnassign(Assignment<Lecture, Placement> assignment, Placement placement, int[][] nrCourses) {
    SpreadConstraintContext context = getContext(assignment);
    // sLogger.debug("  -- trying to unassign "+placement);
    int firstSlot = placement.getTimeLocation().getStartSlot();
    if (firstSlot > iLastDaySlot)
        return 0;
    int endSlot = firstSlot + placement.getTimeLocation().getNrSlotsPerMeeting() - 1;
    if (endSlot < iFirstDaySlot)
        return 0;
    int improvement = 0;
    for (int i = Math.max(firstSlot, iFirstDaySlot); i <= Math.min(endSlot, iLastDaySlot); i++) {
        for (int j = iFirstWorkDay; j <= iLastWorkDay; j++) {
            int dayCode = Constants.DAY_CODES[j % 7];
            if ((dayCode & placement.getTimeLocation().getDayCode()) != 0) {
                if (nrCourses[i - iFirstDaySlot][j - iFirstWorkDay] > context.getMaxCourses(i, j))
                    improvement++;
                nrCourses[i - iFirstDaySlot][j - iFirstWorkDay]--;
            }
        }
    }
    // sLogger.debug("  -- penalty is decreased by "+improvement);
    return improvement;
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:24,代码来源:SpreadConstraint.java

示例12: tryAssign

import org.cpsolver.coursett.Constants; //导入依赖的package包/类
private int tryAssign(Assignment<Lecture, Placement> assignment, Placement placement, int[][] nrCourses) {
    SpreadConstraintContext context = getContext(assignment);
    // sLogger.debug("  -- trying to assign "+placement);
    int firstSlot = placement.getTimeLocation().getStartSlot();
    if (firstSlot > iLastDaySlot)
        return 0;
    int endSlot = firstSlot + placement.getTimeLocation().getNrSlotsPerMeeting() - 1;
    if (endSlot < iFirstDaySlot)
        return 0;
    int penalty = 0;
    for (int i = Math.max(firstSlot, iFirstDaySlot); i <= Math.min(endSlot, iLastDaySlot); i++) {
        for (int j = iFirstWorkDay; j <= iLastWorkDay; j++) {
            int dayCode = Constants.DAY_CODES[j % 7];
            if ((dayCode & placement.getTimeLocation().getDayCode()) != 0) {
                nrCourses[i - iFirstDaySlot][j - iFirstWorkDay]++;
                if (nrCourses[i - iFirstDaySlot][j - iFirstWorkDay] > context.getMaxCourses(i, j))
                    penalty++;
            }
        }
    }
    // sLogger.debug("  -- penalty is incremented by "+penalty);
    return penalty;
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:24,代码来源:SpreadConstraint.java

示例13: getMaxPenalty

import org.cpsolver.coursett.Constants; //导入依赖的package包/类
public int getMaxPenalty(Assignment<Lecture, Placement> assignment, Placement placement) {
    SpreadConstraintContext context = getContext(assignment);
    int penalty = 0;
    for (Enumeration<Integer> e = placement.getTimeLocation().getSlots(); e.hasMoreElements();) {
        int slot = e.nextElement();
        int day = slot / Constants.SLOTS_PER_DAY;
        int time = slot % Constants.SLOTS_PER_DAY;
        if (time < iFirstDaySlot || time > iLastDaySlot)
            continue;
        if (iLastWorkDay < 7) {
            if (day < iFirstWorkDay || day > iLastWorkDay)
                continue;
        } else {
            if (day < iFirstWorkDay && day > iLastWorkDay - 7)
                continue;
            if (day < iFirstWorkDay) day += 7;
        }
        int dif = 1 + context.getNrCourses(time, day, placement) - context.getMaxCourses(time, day);
        if (dif > penalty)
            penalty = dif;
    }
    return penalty;
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:24,代码来源:SpreadConstraint.java

示例14: assigned

import org.cpsolver.coursett.Constants; //导入依赖的package包/类
@Override
public void assigned(Assignment<Lecture, Placement> assignment, Placement placement) {
    int firstSlot = placement.getTimeLocation().getStartSlot();
    if (firstSlot > iLastDaySlot)
        return;
    int endSlot = firstSlot + placement.getTimeLocation().getNrSlotsPerMeeting() - 1;
    if (endSlot < iFirstDaySlot)
        return;
    getCriterion().inc(assignment, -iCurrentPenalty);
    for (int i = Math.max(firstSlot, iFirstDaySlot); i <= Math.min(endSlot, iLastDaySlot); i++) {
        for (int j = iFirstWorkDay; j <= iLastWorkDay; j++) {
            int dayCode = Constants.DAY_CODES[j % 7];
            if ((dayCode & placement.getTimeLocation().getDayCode()) != 0) {
                iCourses[i - iFirstDaySlot][j - iFirstWorkDay].add(placement);
                if (iCourses[i - iFirstDaySlot][j - iFirstWorkDay].size() > iMaxCourses[i - iFirstDaySlot][j - iFirstWorkDay])
                    iCurrentPenalty++;
            }
        }
    }
    getCriterion().inc(assignment, iCurrentPenalty);
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:22,代码来源:SpreadConstraint.java

示例15: unassigned

import org.cpsolver.coursett.Constants; //导入依赖的package包/类
@Override
public void unassigned(Assignment<Lecture, Placement> assignment, Placement placement) {
    int firstSlot = placement.getTimeLocation().getStartSlot();
    if (firstSlot > iLastDaySlot)
        return;
    int endSlot = firstSlot + placement.getTimeLocation().getNrSlotsPerMeeting() - 1;
    if (endSlot < iFirstDaySlot)
        return;
    getCriterion().inc(assignment, -iCurrentPenalty);
    for (int i = Math.max(firstSlot, iFirstDaySlot); i <= Math.min(endSlot, iLastDaySlot); i++) {
        for (int j = iFirstWorkDay; j <= iLastWorkDay; j++) {
            int dayCode = Constants.DAY_CODES[j % 7];
            if ((dayCode & placement.getTimeLocation().getDayCode()) != 0) {
                if (iCourses[i - iFirstDaySlot][j - iFirstWorkDay].size() > iMaxCourses[i - iFirstDaySlot][j - iFirstWorkDay])
                    iCurrentPenalty--;
                iCourses[i - iFirstDaySlot][j - iFirstWorkDay].remove(placement);
            }
        }
    }
    getCriterion().inc(assignment, iCurrentPenalty);
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:22,代码来源:SpreadConstraint.java


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