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


Java Course类代码示例

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


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

示例1: XSubpart

import org.cpsolver.studentsct.model.Course; //导入依赖的package包/类
public XSubpart(Subpart subpart, boolean courseCredit) {
	iUniqueId = subpart.getId();
	iInstructionalType = subpart.getInstructionalType();
	iAllowOverlap = subpart.isAllowOverlap();
	iName = subpart.getName();
	iConfigId = subpart.getConfig().getId();
	iParentId = (subpart.getParent() == null ? null : subpart.getParent().getId());
	if (subpart.getCredit() != null)
		iCredit = new XCredit(subpart.getCredit());
	if (courseCredit) {
		for (Course course: subpart.getConfig().getOffering().getCourses()) {
			if (course.getCredit() != null)
				iCreditByCourse.put(course.getId(), new XCredit(course.getCredit()));
		}
	}
	for (Section section: subpart.getSections())
		iSections.add(new XSection(section));
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:19,代码来源:XSubpart.java

示例2: XConfig

import org.cpsolver.studentsct.model.Course; //导入依赖的package包/类
public XConfig(Config config) {
	iUniqueId = config.getId();
	iName = config.getName();
	iOfferingId = config.getOffering().getId();
	iLimit = config.getLimit();
    boolean credit = false;
    for (Course course: config.getOffering().getCourses()) {
    	if (course.getCredit() != null) { credit = true; break; }
    }
	for (Subpart subpart: config.getSubparts()) {
		iSubparts.add(new XSubpart(subpart, credit));
		credit = false;
	}
	if (config.getInstructionalMethodId() != null)
		iInstructionalMethod = new XInstructionalMethod(config.getInstructionalMethodId(), config.getInstructionalMethodName());
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:17,代码来源:XConfig.java

示例3: toProto

import org.cpsolver.studentsct.model.Course; //导入依赖的package包/类
public static OnlineSectioningLog.Request.Builder toProto(Request r) {
	OnlineSectioningLog.Request.Builder request = OnlineSectioningLog.Request.newBuilder();
	request.setPriority(r.getPriority());
	request.setAlternative(r.isAlternative());
	if (r instanceof FreeTimeRequest) {
		FreeTimeRequest ft = (FreeTimeRequest)r;
		if (ft.getTime() != null) {
			request.addFreeTime(OnlineSectioningLog.Time.newBuilder()
					.setDays(ft.getTime().getDayCode())
					.setStart(ft.getTime().getStartSlot())
					.setLength(ft.getTime().getLength()));
		}
	} else if (r instanceof CourseRequest) {
		CourseRequest cr = (CourseRequest)r;
		for (Course course: cr.getCourses()) {
			request.addCourse(OnlineSectioningLog.Entity.newBuilder()
					.setUniqueId(course.getId())
					.setName(course.getName()));
		}
		if (cr.getTimeStamp() != null)
			request.setTimeStamp(cr.getTimeStamp());
    	request.setWaitList(cr.isWaitlist());
	}
	return request;
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:26,代码来源:OnlineSectioningHelper.java

示例4: inConflict

import org.cpsolver.studentsct.model.Course; //导入依赖的package包/类
/**
 * A given enrollment is conflicting, if the course's enrollment (computed by
 * {@link CourseLimit#getEnrollmentWeight(Assignment, Course, Request)}) exceeds the
 * limit.
 * 
 * @param enrollment
 *            {@link Enrollment} that is being considered
 * @return true, if the enrollment cannot be assigned without exceeding the limit
 */
@Override
public boolean inConflict(Assignment<Request, Enrollment> assignment, Enrollment enrollment) {
    // check reservation can assign over the limit
    if (enrollment.getReservation() != null && enrollment.getReservation().canBatchAssignOverLimit())
        return false;

    // enrollment's course
    Course course = enrollment.getCourse();

    // exclude free time requests
    if (course == null)
        return false;

    // unlimited course
    if (course.getLimit() < 0)
        return false;


    // new enrollment weight
    double enrlWeight = getEnrollmentWeight(assignment, course, enrollment.getRequest());
    
    // above limit -> conflict
    return (enrlWeight > course.getLimit());
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:34,代码来源:CourseLimit.java

示例5: createConstraint

import org.cpsolver.studentsct.model.Course; //导入依赖的package包/类
/**
 * Create linked-section constraints for a given student
 */
private LinkedSectionsConstraint createConstraint(Student student) {
    List<Request> requests = new ArrayList<Request>();
    int nrOfferings = 0;
    requests: for (Request request: student.getRequests()) {
        if (request instanceof CourseRequest) {
            for (Course course: ((CourseRequest)request).getCourses()) {
                Map<Subpart, Set<Section>> subpartsThisOffering = iSections.get(course.getOffering());
                if (subpartsThisOffering != null) {
                    requests.add(request);
                    nrOfferings++;
                    continue requests;
                }
            }
        }
    }
    if (nrOfferings <= 1) return null;
    LinkedSectionsConstraint constraint = new LinkedSectionsConstraint(student, requests);
    student.getRequests().get(0).getModel().addConstraint(constraint);
    return constraint;
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:24,代码来源:LinkedSections.java

示例6: removeVariable

import org.cpsolver.studentsct.model.Course; //导入依赖的package包/类
@Override
public void removeVariable(Request request) {
    super.removeVariable(request);
    if (request instanceof CourseRequest) {
        CourseRequest cr = (CourseRequest)request;
        for (Course course: cr.getCourses())
            course.getRequests().remove(request);
    }
    if (request.getStudent().isDummy()) {
        iNrDummyRequests--;
        iTotalDummyWeight -= request.getWeight();
        if (request instanceof CourseRequest)
            iTotalDummyCRWeight -= request.getWeight();
    }
    if (request.isMPP())
        iTotalMPPCRWeight -= request.getWeight();
    if (request.hasSelection())
        iTotalSelCRWeight -= request.getWeight();
    if (request instanceof CourseRequest)
        iTotalCRWeight -= request.getWeight();
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:22,代码来源:StudentSectioningModel.java

示例7: toString

import org.cpsolver.studentsct.model.Course; //导入依赖的package包/类
@Override
public String toString(Assignment<Request, Enrollment> assignment) {
    double groupSpread = 0.0; double groupCount = 0;
    for (Offering offering: iOfferings) {
        for (Course course: offering.getCourses()) {
            for (RequestGroup group: course.getRequestGroups()) {
                groupSpread += group.getAverageSpread(assignment) * group.getEnrollmentWeight(assignment, null);
                groupCount += group.getEnrollmentWeight(assignment, null);
            }
        }
    }
    return   (getNrRealStudents(false) > 0 ? "RRq:" + getNrAssignedRealRequests(assignment, false) + "/" + getNrRealRequests(false) + ", " : "")
            + (getNrLastLikeStudents(false) > 0 ? "DRq:" + getNrAssignedLastLikeRequests(assignment, false) + "/" + getNrLastLikeRequests(false) + ", " : "")
            + (getNrRealStudents(false) > 0 ? "RS:" + getNrCompleteRealStudents(assignment, false) + "/" + getNrRealStudents(false) + ", " : "")
            + (getNrLastLikeStudents(false) > 0 ? "DS:" + getNrCompleteLastLikeStudents(assignment, false) + "/" + getNrLastLikeStudents(false) + ", " : "")
            + "V:"
            + sDecimalFormat.format(-getTotalValue(assignment))
            + (getDistanceConflict() == null ? "" : ", DC:" + getDistanceConflict().getTotalNrConflicts(assignment))
            + (getTimeOverlaps() == null ? "" : ", TOC:" + getTimeOverlaps().getTotalNrConflicts(assignment))
            + (iMPP ? ", IS:" + sDecimalFormat.format(100.0 * getContext(assignment).iAssignedSameSectionWeight / iTotalMPPCRWeight) + "%" : "")
            + (iMPP ? ", IT:" + sDecimalFormat.format(100.0 * getContext(assignment).iAssignedSameTimeWeight / iTotalMPPCRWeight) + "%" : "")
            + ", %:" + sDecimalFormat.format(-100.0 * getTotalValue(assignment) / (getStudents().size() - iNrDummyStudents + 
                    (iProjectedStudentWeight < 0.0 ? iNrDummyStudents * (iTotalDummyWeight / iNrDummyRequests) :iProjectedStudentWeight * iTotalDummyWeight)))
            + (groupCount > 0 ? ", SG:" + sDecimalFormat.format(100.0 * groupSpread / groupCount) + "%" : "");

}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:27,代码来源:StudentSectioningModel.java

示例8: setPenalties

import org.cpsolver.studentsct.model.Course; //导入依赖的package包/类
/**
 * Set online sectioning penalties to all sections of all courses of the
 * given student
 */
private static void setPenalties(Assignment<Request, Enrollment> assignment, Student student) {
    for (Request request : student.getRequests()) {
        if (!(request instanceof CourseRequest))
            continue;
        CourseRequest courseRequest = (CourseRequest) request;
        for (Course course : courseRequest.getCourses()) {
            for (Config config : course.getOffering().getConfigs()) {
                for (Subpart subpart : config.getSubparts()) {
                    for (Section section : subpart.getSections()) {
                        section.setPenalty(section.getOnlineSectioningPenalty(assignment));
                    }
                }
            }
        }
        courseRequest.clearCache();
    }
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:22,代码来源:OnlineSelection.java

示例9: avgNrChoices

import org.cpsolver.studentsct.model.Course; //导入依赖的package包/类
/** Average number of choices for each student 
 * @param student given student
 * @return average number of choices of the given student
 **/
public double avgNrChoices(Student student) {
    int nrRequests = 0;
    int nrChoices = 0;
    for (Request request : student.getRequests()) {
        if (request instanceof CourseRequest) {
            CourseRequest cr = (CourseRequest) request;
            for (Course course : cr.getCourses()) {
                for (Config config : course.getOffering().getConfigs()) {
                    Integer nrChoicesThisCfg = iCache.get(config);
                    if (nrChoicesThisCfg == null) {
                        nrChoicesThisCfg = new Integer(nrChoices(config, 0, new HashSet<Section>()));
                        iCache.put(config, nrChoicesThisCfg);
                    }
                    nrChoices += nrChoicesThisCfg.intValue();
                }
            }
            nrRequests++;
        }
    }
    return (nrRequests == 0 ? 0.0 : ((double) nrChoices) / nrRequests);
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:26,代码来源:StudentChoiceOrder.java

示例10: load

import org.cpsolver.studentsct.model.Course; //导入依赖的package包/类
public void load(Document document) {
    Element root = document.getRootElement();
    
    if (getModel().getDistanceConflict() != null && root.element("travel-times") != null)
        loadTravelTimes(root.element("travel-times"), getModel().getDistanceConflict().getDistanceMetric());
    
    Progress.getInstance(getModel()).load(root, true);
    Progress.getInstance(getModel()).message(Progress.MSGLEVEL_STAGE, "Restoring from backup ...");

    Map<Long, Offering> offeringTable = new HashMap<Long, Offering>();
    Map<Long, Course> courseTable = new HashMap<Long, Course>();

    if (root.element("offerings") != null) {
        loadOfferings(root.element("offerings"), offeringTable, courseTable, null);
    }
    
    if (root.element("students") != null) {
        loadStudents(root.element("students"), offeringTable, courseTable);
    }
    
    if (root.element("constraints") != null) 
        loadLinkedSections(root.element("constraints"), offeringTable);
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:24,代码来源:StudentSectioningXMLLoader.java

示例11: loadEnrollment

import org.cpsolver.studentsct.model.Course; //导入依赖的package包/类
/**
 * Load enrollment
 * @param enrollmentEl enrollment element (current, best, or initial)
 * @param request parent request
 * @return loaded enrollment
 */
protected Enrollment loadEnrollment(Element enrollmentEl, Request request) {
    if (request instanceof CourseRequest) {
        CourseRequest courseRequest = (CourseRequest) request;
        HashSet<Section> sections = new HashSet<Section>();
        for (Iterator<?> k = enrollmentEl.elementIterator("section"); k.hasNext();) {
            Element sectionEl = (Element) k.next();
            Section section = courseRequest.getSection(Long.parseLong(sectionEl
                    .attributeValue("id")));
            sections.add(section);
        }
        Reservation reservation = null;
        if (enrollmentEl.attributeValue("reservation", null) != null) {
            long reservationId = Long.valueOf(enrollmentEl.attributeValue("reservation"));
            for (Course course: courseRequest.getCourses())
                for (Reservation r: course.getOffering().getReservations())
                    if (r.getId() == reservationId) { reservation = r; break; }
        }
        if (!sections.isEmpty())
            return courseRequest.createEnrollment(sections, reservation);
    } else if (request instanceof FreeTimeRequest) {
        return ((FreeTimeRequest)request).createEnrollment();
    }
    return null;
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:31,代码来源:StudentSectioningXMLLoader.java

示例12: getLastLikeStudentWeight

import org.cpsolver.studentsct.model.Course; //导入依赖的package包/类
/**
 * Compute last-like student weight for the given course
 * 
 * @param course
 *            given course
 * @param real
 *            number of real students for the course
 * @param lastLike
 *            number of last-like students for the course
 * @return weight of a student request for the given course
 */
public static double getLastLikeStudentWeight(Course course, int real, int lastLike) {
    int projected = course.getProjected();
    int limit = course.getLimit();
    if (course.getLimit() < 0) {
        sLog.debug("  -- Course " + course.getName() + " is unlimited.");
        return 1.0;
    }
    if (projected <= 0) {
        sLog.warn("  -- No projected demand for course " + course.getName() + ", using course limit (" + limit
                + ")");
        projected = limit;
    } else if (limit < projected) {
        sLog.warn("  -- Projected number of students is over course limit for course " + course.getName() + " ("
                + Math.round(projected) + ">" + limit + ")");
        projected = limit;
    }
    if (lastLike == 0) {
        sLog.warn("  -- No last like info for course " + course.getName());
        return 1.0;
    }
    double weight = ((double) Math.max(0, projected - real)) / lastLike;
    sLog.debug("  -- last like student weight for " + course.getName() + " is " + weight + " (lastLike=" + lastLike
            + ", real=" + real + ", projected=" + projected + ")");
    return weight;
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:37,代码来源:Test.java

示例13: readExternal

import org.cpsolver.studentsct.model.Course; //导入依赖的package包/类
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
	iUniqueId = in.readLong();
	iName = (String)in.readObject();
	
	int nrConfigs = in.readInt();
	iConfigs.clear();
	for (int i = 0; i < nrConfigs; i++)
		iConfigs.add(new XConfig(in));
	
	int nrCourses = in.readInt();
	for (int i = 0; i < nrCourses; i++)
		iCourses.add(new XCourse(in));
	
	int nrReservations = in.readInt();
	for (int i = 0; i < nrReservations; i++) {
		switch (XReservationType.values()[in.readInt()]) {
		case Course:
			iReservations.add(new XCourseReservation(in));
			break;
		case Curriculum:
			iReservations.add(new XCurriculumReservation(in));
			break;
		case Dummy:
			iReservations.add(new XDummyReservation(in));
			break;
		case Group:
			iReservations.add(new XGroupReservation(in));
			break;
		case Individual:
		case Override:
			iReservations.add(new XIndividualReservation(in));
			break;
		}
	}
	
	int nrDistributions = in.readInt();
	for (int i = 0; i < nrDistributions; i++)
		iDistrubutions.add(new XDistribution(in));
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:41,代码来源:XOffering.java

示例14: XCourse

import org.cpsolver.studentsct.model.Course; //导入依赖的package包/类
public XCourse(Course course) {
  	super(course);
iSubjectArea = course.getSubjectArea();
iCourseNumber = course.getCourseNumber();
iNote = course.getNote();
      iLimit = course.getLimit();
      iProjected = course.getProjected();
      if (course.getCredit() != null)
      	iCredit = new XCredit(course.getCredit());
      iControl = course.getName().equals(course.getOffering().getName());
  }
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:12,代码来源:XCourse.java

示例15: getCourse

import org.cpsolver.studentsct.model.Course; //导入依赖的package包/类
protected Course getCourse(StudentSectioningModel model, Long courseId, String courseName){
	for (Offering offering: model.getOfferings())
		for (Course course: offering.getCourses()) {
			if (courseId != null) {
				if (courseId.equals(course.getId())) return course;
			} else {
				if (course.getName().equalsIgnoreCase(courseName)) return course;
			}
		}
	return null;
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:12,代码来源:BatchEnrollStudent.java


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