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


Java TimeOverlapsCounter类代码示例

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


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

示例1: getWeight

import org.cpsolver.studentsct.extension.TimeOverlapsCounter; //导入依赖的package包/类
@Override
protected double getWeight(Enrollment enrollment, Set<DistanceConflict.Conflict> distanceConflicts,
        Set<TimeOverlapsCounter.Conflict> timeOverlappingConflicts) {
    double weight = super.getWeight(enrollment, distanceConflicts, timeOverlappingConflicts);
    if (enrollment.isCourseRequest() && iPreferredSections != null) {
        Set<Section> preferred = iPreferredSections.get(enrollment.getRequest());
        if (preferred != null && !preferred.isEmpty()) {
            double nrPreferred = 0;
            for (Section section : enrollment.getSections())
                if (preferred.contains(section))
                    nrPreferred++;
            double preferredFraction = nrPreferred / preferred.size();
            weight *= 1.0 + iPreferenceFactor * preferredFraction;
        }
    }
    return weight;
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:18,代码来源:SuggestionSelection.java

示例2: getTimeOverlappingConflicts

import org.cpsolver.studentsct.extension.TimeOverlapsCounter; //导入依赖的package包/类
/**
 * Time overlapping conflicts of idx-th assignment of the current schedule
 */
public Set<TimeOverlapsCounter.Conflict> getTimeOverlappingConflicts(Enrollment[] assignment, int idx) {
    if (getModel().getTimeOverlaps() == null || assignment[idx] == null)
        return null;
    Set<TimeOverlapsCounter.Conflict> overlaps = new HashSet<TimeOverlapsCounter.Conflict>();
    for (int x = 0; x < idx; x++)
        if (assignment[x] != null) {
            overlaps.addAll(getModel().getTimeOverlaps().conflicts(assignment[x], assignment[idx]));
        } else if (getStudent().getRequests().get(x) instanceof FreeTimeRequest)
            overlaps.addAll(getModel().getTimeOverlaps().conflicts(
                    ((FreeTimeRequest) getStudent().getRequests().get(x)).createEnrollment(), assignment[idx]));
    overlaps.addAll(getModel().getTimeOverlaps().notAvailableTimeConflicts(assignment[idx]));
    return overlaps;
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:17,代码来源:OnlineSectioningCriterion.java

示例3: Test

import org.cpsolver.studentsct.extension.TimeOverlapsCounter; //导入依赖的package包/类
public Test(DataProperties config) {
    iModel = new TestModel(config);
    iModel.setDistanceConflict(new DistanceConflict(new DistanceMetric(iModel.getProperties()), iModel.getProperties()));
    iModel.getDistanceConflict().register(iModel);
    iModel.getDistanceConflict().setAssignmentContextReference(iModel.createReference(iModel.getDistanceConflict()));
    iModel.setTimeOverlaps(new TimeOverlapsCounter(null, iModel.getProperties()));
    iModel.getTimeOverlaps().register(iModel);
    iModel.getTimeOverlaps().setAssignmentContextReference(iModel.createReference(iModel.getTimeOverlaps()));
    iModel.setStudentWeights(new StudentSchedulingAssistantWeights(iModel.getProperties()));
    iAssignment = new DefaultSingleAssignment<Request, Enrollment>();
    iSuggestions = "true".equals(System.getProperty("suggestions", iSuggestions ? "true" : "false"));

    String overexp = System.getProperty("overexp");
    if (overexp != null) {
        boolean bal = false;
        if (overexp.startsWith("b")) {
            bal = true;
            overexp = overexp.substring(1);
        }
        String[] x = overexp.split("[/\\-]");
        if (x.length == 1) {
            iModel.setOverExpectedCriterion(new PercentageOverExpected(Double.valueOf(x[0])));
        } else if (x.length == 2) {
            iModel.setOverExpectedCriterion(bal ? new AvoidUnbalancedWhenNoExpectations(Double.valueOf(x[0]), Double.valueOf(x[1]) / 100.0) :
                new FractionallyOverExpected(Double.valueOf(x[0]), Double.valueOf(x[1])));
        } else {
            iModel.setOverExpectedCriterion(new FractionallyUnbalancedWhenNoExpectations(Double.valueOf(x[0]),
                    Double.valueOf(x[1]), Double.valueOf(x[2]) / 100.0));
        }
    }

    sLog.info("Using " + (config.getPropertyBoolean("StudentWeights.MultiCriteria", true) ? "multi-criteria " : "")
            + (config.getPropertyBoolean("StudentWeights.PriorityWeighting", true) ? "priority" : "equal")
            + " weighting model" + " with over-expected " + iModel.getOverExpectedCriterion()
            + (iSuggestions ? ", suggestions" : "") + ", " + System.getProperty("sort", "shuffle") + " order"
            + " and " + config.getPropertyInt("Neighbour.BranchAndBoundTimeout", 1000) + " ms time limit.");
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:38,代码来源:Test.java

示例4: toString

import org.cpsolver.studentsct.extension.TimeOverlapsCounter; //导入依赖的package包/类
public String toString(Assignment<Request, Enrollment> a) {
    if (getAssignments().isEmpty()) return "not assigned";
    Set<DistanceConflict.Conflict> dc = distanceConflicts(a);
    Set<TimeOverlapsCounter.Conflict> toc = timeOverlappingConflicts(a);
    int share = 0;
    if (toc != null)
        for (TimeOverlapsCounter.Conflict c: toc)
            share += c.getShare();
    String ret = toDouble(a) + "/" + sDF.format(getRequest().getBound())
            + (getPenalty() == 0.0 ? "" : "/" + sDF.format(getPenalty()))
            + (dc == null || dc.isEmpty() ? "" : "/dc:" + dc.size())
            + (share <= 0 ? "" : "/toc:" + share);
    if (getRequest() instanceof CourseRequest) {
        double sameGroup = 0.0; int groupCount = 0;
        for (RequestGroup g: ((CourseRequest)getRequest()).getRequestGroups()) {
            if (g.getCourse().equals(getCourse())) {
                sameGroup += g.getEnrollmentSpread(a, this, 1.0, 0.0);
                groupCount ++;
            }
        }
        if (groupCount > 0)
            ret += "/g:" + sDF.format(sameGroup / groupCount);
    }
    if (getRequest() instanceof CourseRequest) {
        ret += " ";
        for (Iterator<? extends SctAssignment> i = getAssignments().iterator(); i.hasNext();) {
            SctAssignment assignment = i.next();
            ret += assignment + (i.hasNext() ? ", " : "");
        }
    }
    if (getReservation() != null) ret = "(r) " + ret;
    return ret;
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:34,代码来源:Enrollment.java

示例5: timeOverlappingConflicts

import org.cpsolver.studentsct.extension.TimeOverlapsCounter; //导入依赖的package包/类
/** Time overlapping conflicts, in which this enrollment is involved. 
 * @param assignment current assignment
 * @return time overlapping conflicts
 **/
public Set<TimeOverlapsCounter.Conflict> timeOverlappingConflicts(Assignment<Request, Enrollment> assignment) {
    if (getRequest().getModel() instanceof StudentSectioningModel) {
        TimeOverlapsCounter toc = ((StudentSectioningModel) getRequest().getModel()).getTimeOverlaps();
        if (toc == null)
            return null;
        return toc.allConflicts(assignment, this);
    } else
        return null;
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:14,代码来源:Enrollment.java

示例6: getTimeOverlappingConflicts

import org.cpsolver.studentsct.extension.TimeOverlapsCounter; //导入依赖的package包/类
/**
 * Time overlapping conflicts of idx-th assignment of the current
 * schedule
 * @param idx index of the request
 * @return set of time overlapping conflicts
 */
public Set<TimeOverlapsCounter.Conflict> getTimeOverlappingConflicts(int idx) {
    if (iTimeOverlaps == null || iAssignment[idx] == null)
        return null;
    Set<TimeOverlapsCounter.Conflict> overlaps = new HashSet<TimeOverlapsCounter.Conflict>();
    for (int x = 0; x < idx; x++)
        if (iAssignment[x] != null)
            overlaps.addAll(iTimeOverlaps.conflicts(iAssignment[x], iAssignment[idx]));
        else if (iStudent.getRequests().get(x) instanceof FreeTimeRequest)
            overlaps.addAll(iTimeOverlaps.conflicts(((FreeTimeRequest)iStudent.getRequests().get(x)).createEnrollment(), iAssignment[idx]));
    overlaps.addAll(iTimeOverlaps.notAvailableTimeConflicts(iAssignment[idx]));
    return overlaps;
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:19,代码来源:BranchBoundSelection.java

示例7: getWeight

import org.cpsolver.studentsct.extension.TimeOverlapsCounter; //导入依赖的package包/类
@Override
public double getWeight(Assignment<Request, Enrollment> assignment, Enrollment enrollment, Set<DistanceConflict.Conflict> distanceConflicts, Set<TimeOverlapsCounter.Conflict> timeOverlappingConflicts) {
    int share = 0;
    if (timeOverlappingConflicts != null) 
        for (TimeOverlapsCounter.Conflict c: timeOverlappingConflicts)
            share += c.getShare();
    return getWeight(assignment, enrollment)
           * (distanceConflicts == null || distanceConflicts.isEmpty() ? 1.0 : Math.pow(iDistConfWeight, distanceConflicts.size()))
           * Math.max(share == 0 ? 1.0 : 1.0 - (((double)share) / enrollment.getNrSlots()) / 2.0, 0.5);
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:11,代码来源:OriginalStudentWeights.java

示例8: solutionUpdated

import org.cpsolver.studentsct.extension.TimeOverlapsCounter; //导入依赖的package包/类
@Override
public void solutionUpdated(Solution<Request, Enrollment> solution) {
    StudentSectioningModel m = (StudentSectioningModel) solution.getModel();
    if (m.getTimeOverlaps() != null && TimeOverlapsCounter.sDebug)
        m.getTimeOverlaps().checkTotalNrConflicts(solution.getAssignment());
    if (m.getDistanceConflict() != null && DistanceConflict.sDebug)
        m.getDistanceConflict().checkAllConflicts(solution.getAssignment());
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:9,代码来源:Test.java

示例9: resection

import org.cpsolver.studentsct.extension.TimeOverlapsCounter; //导入依赖的package包/类
public XEnrollment resection(OnlineSectioningServer server, ResectioningWeights w, DistanceConflict dc, TimeOverlapsCounter toc) {
	w.setLastSectionProvider(this);
	
	List<Enrollment> enrollments = new ArrayList<Enrollment>();
	double bestValue = 0.0;
	
	Assignment<Request, Enrollment> assignment = new AssignmentMap<Request, Enrollment>();
	CourseRequest request = convert(assignment, getRequest(), server);
	if (request == null) return null;
	
	if (getLastEnrollment() != null)
		for (Long sectionId: getLastEnrollment().getSectionIds()) {
			for (Course course: request.getCourses()) {
				Section section = course.getOffering().getSection(sectionId);
				if (section != null) iLastSections.add(section);
			}
		}
	
	enrollments: for (Enrollment e: request.getAvaiableEnrollments(assignment)) {
		// only consider enrollments of the offering that is being checked
		if (e.getOffering().getId() != getOffering().getOfferingId()) continue;
		
		for (Request other: request.getStudent().getRequests()) {
			if (other.equals(request)) continue;
			Enrollment x = assignment.getValue(other);
			if (e.isOverlapping(x))
				continue enrollments;
			if (!w.isFreeTimeAllowOverlaps() && other instanceof FreeTimeRequest && other.getPriority() < request.getPriority() && isOverlappingFreeTime((FreeTimeRequest) other, e))
				continue enrollments;
		}
		
		for (Section s: e.getSections()) {
			if (getLastEnrollment() == null) {
				if (!server.checkDeadline(e.getCourse().getId(), s.getTime() == null ? null : new XTime(s.getTime()), OnlineSectioningServer.Deadline.NEW)) continue enrollments;
			} else {
				if (!getLastEnrollment().getSectionIds().contains(s.getId()) &&
					!server.checkDeadline(e.getCourse().getId(), s.getTime() == null ? null : new XTime(s.getTime()), OnlineSectioningServer.Deadline.CHANGE)) continue enrollments;
			}
		}
		
		double value = w.getWeight(assignment, e, dc.allConflicts(assignment, e), toc.allConflicts(assignment, e));
		if (enrollments.isEmpty() || value > bestValue) {
			enrollments.clear();
			enrollments.add(e); bestValue = value;
		} else if (value == bestValue) {
			enrollments.add(e); 
		}
	}
	
	return (enrollments.isEmpty() ? null : new XEnrollment(ToolBox.random(enrollments)));
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:52,代码来源:SectioningRequest.java

示例10: ServerConfig

import org.cpsolver.studentsct.extension.TimeOverlapsCounter; //导入依赖的package包/类
private ServerConfig() {
	super();
	setProperty("Neighbour.BranchAndBoundTimeout", "1000");
	setProperty("Suggestions.Timeout", "1000");
	setProperty("Extensions.Classes", DistanceConflict.class.getName() + ";" + TimeOverlapsCounter.class.getName());
	setProperty("StudentWeights.Class", StudentSchedulingAssistantWeights.class.getName());
	setProperty("StudentWeights.PriorityWeighting", "true");
	setProperty("StudentWeights.LeftoverSpread", "true");
	setProperty("StudentWeights.BalancingFactor", "0.0");
	setProperty("StudentWeights.MultiCriteria", "true");
	setProperty("Reservation.CanAssignOverTheLimit", "true");
	setProperty("General.SaveDefaultProperties", "false");
	setProperty("General.StartUpDate", String.valueOf(new Date().getTime()));
	setProperty("check-assignment.ExcludeLockedOfferings", "false");
	setProperty("check-offering.ExcludeLockedOfferings", "false");
	setProperty("approve-enrollments.ExcludeLockedOfferings", "false");
	setProperty("reject-enrollments.ExcludeLockedOfferings", "false");
	setProperty("status-change.LockOfferings", "false");
	setProperty("student-email.LockOfferings", "false");
	setProperty("eligibility.LockOfferings", "false");
	
	org.hibernate.Session hibSession = SessionDAO.getInstance().createNewSession();
	try {
		for (SolverParameterDef def: (List<SolverParameterDef>)hibSession.createQuery(
				"from SolverParameterDef x where x.group.type = :type and x.default is not null")
				.setInteger("type", SolverParameterGroup.SolverType.STUDENT.ordinal()).list()) {
			setProperty(def.getName(), def.getDefault());
		}
		SolverPredefinedSetting settings = (SolverPredefinedSetting)hibSession.createQuery(
				"from SolverPredefinedSetting x where x.name = :reference")
				.setString("reference", "StudentSct.Online").setMaxResults(1).uniqueResult();
		if (settings != null) {
			for (SolverParameter param: settings.getParameters()) {
				if (!param.getDefinition().isVisible().booleanValue()) continue;
				if (param.getDefinition().getGroup().getSolverType() != SolverParameterGroup.SolverType.STUDENT) continue;
				setProperty(param.getDefinition().getName(), param.getValue());
			}
			setProperty("General.SettingsId", settings.getUniqueId().toString());
		}
		if (getProperty("Distances.Ellipsoid") == null || "DEFAULT".equals(getProperty("Distances.Ellipsoid")))
			setProperty("Distances.Ellipsoid", ApplicationProperty.DistanceEllipsoid.value());
		if ("Priority".equals(getProperty("StudentWeights.Mode")))
			setProperty("StudentWeights.PriorityWeighting", "true");
		else if ("Equal".equals(getProperty("StudentWeights.Mode")))
			setProperty("StudentWeights.PriorityWeighting", "false");
	} finally {
		hibSession.close();
	}
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:50,代码来源:AbstractServer.java

示例11: getTimeOverlapConflictWeight

import org.cpsolver.studentsct.extension.TimeOverlapsCounter; //导入依赖的package包/类
@Override
public double getTimeOverlapConflictWeight(Assignment<Request, Enrollment> assignment, Enrollment enrollment,
        TimeOverlapsCounter.Conflict timeOverlap) {
    return iParent.getTimeOverlapConflictWeight(assignment, enrollment, timeOverlap);
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:6,代码来源:StudentSchedulingAssistantWeights.java

示例12: main

import org.cpsolver.studentsct.extension.TimeOverlapsCounter; //导入依赖的package包/类
public static void main(String[] args) {
    try {
        System.setProperty("jprof", "cpu");
        BasicConfigurator.configure();

        DataProperties cfg = new DataProperties();
        cfg.setProperty("Neighbour.BranchAndBoundTimeout", "5000");
        cfg.setProperty("Suggestions.Timeout", "1000");
        cfg.setProperty("Extensions.Classes", DistanceConflict.class.getName() + ";" + TimeOverlapsCounter.class.getName());
        cfg.setProperty("StudentWeights.Class", StudentSchedulingAssistantWeights.class.getName());
        cfg.setProperty("StudentWeights.PriorityWeighting", "true");
        cfg.setProperty("StudentWeights.LeftoverSpread", "true");
        cfg.setProperty("StudentWeights.BalancingFactor", "0.0");
        cfg.setProperty("Reservation.CanAssignOverTheLimit", "true");
        cfg.setProperty("Distances.Ellipsoid", DistanceMetric.Ellipsoid.WGS84.name());
        cfg.setProperty("StudentWeights.MultiCriteria", "true");
        cfg.setProperty("CourseRequest.SameTimePrecise", "true");

        cfg.setProperty("log4j.rootLogger", "INFO, A1");
        cfg.setProperty("log4j.appender.A1", "org.apache.log4j.ConsoleAppender");
        cfg.setProperty("log4j.appender.A1.layout", "org.apache.log4j.PatternLayout");
        cfg.setProperty("log4j.appender.A1.layout.ConversionPattern", "%-5p %c{2}: %m%n");
        cfg.setProperty("log4j.logger.org.hibernate", "INFO");
        cfg.setProperty("log4j.logger.org.hibernate.cfg", "WARN");
        cfg.setProperty("log4j.logger.org.hibernate.cache.EhCacheProvider", "ERROR");
        cfg.setProperty("log4j.logger.org.unitime.commons.hibernate", "INFO");
        cfg.setProperty("log4j.logger.net", "INFO");

        cfg.setProperty("Xml.LoadBest", "false");
        cfg.setProperty("Xml.LoadCurrent", "false");

        cfg.putAll(System.getProperties());

        PropertyConfigurator.configure(cfg);

        final Test test = new Test(cfg);

        final File input = new File(args[0]);
        StudentSectioningXMLLoader loader = new StudentSectioningXMLLoader(test.model(), test.assignment());
        loader.setInputFile(input);
        loader.load();

        test.run();

        Solver<Request, Enrollment> s = new Solver<Request, Enrollment>(cfg);
        s.setInitalSolution(test.model());
        StudentSectioningXMLSaver saver = new StudentSectioningXMLSaver(s);
        File output = new File(input.getParentFile(), input.getName().substring(0, input.getName().lastIndexOf('.')) +
                "-" + cfg.getProperty("run", "r0") + ".xml");
        saver.save(output);

        test.stats(input);
    } catch (Exception e) {
        sLog.error("Test failed: " + e.getMessage(), e);
    }
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:57,代码来源:Test.java

示例13: add

import org.cpsolver.studentsct.extension.TimeOverlapsCounter; //导入依赖的package包/类
public void add(Assignment<Request, Enrollment> assignment, TimeOverlapsCounter.Conflict c) {
    if (c.getR1() != null) iTotalValue += c.getR1Weight() * iStudentWeights.getTimeOverlapConflictWeight(assignment, c.getE1(), c);
    if (c.getR2() != null) iTotalValue += c.getR2Weight() * iStudentWeights.getTimeOverlapConflictWeight(assignment, c.getE2(), c);
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:5,代码来源:StudentSectioningModel.java

示例14: remove

import org.cpsolver.studentsct.extension.TimeOverlapsCounter; //导入依赖的package包/类
public void remove(Assignment<Request, Enrollment> assignment, TimeOverlapsCounter.Conflict c) {
    if (c.getR1() != null) iTotalValue -= c.getR1Weight() * iStudentWeights.getTimeOverlapConflictWeight(assignment, c.getE1(), c);
    if (c.getR2() != null) iTotalValue -= c.getR2Weight() * iStudentWeights.getTimeOverlapConflictWeight(assignment, c.getE2(), c);
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:5,代码来源:StudentSectioningModel.java

示例15: getTimeOverlapConflictWeight

import org.cpsolver.studentsct.extension.TimeOverlapsCounter; //导入依赖的package包/类
@Override
public double getTimeOverlapConflictWeight(Assignment<Request, Enrollment> assignment, Enrollment e, TimeOverlapsCounter.Conflict c) {
    if (e == null || e.getRequest() == null) return 0.0;
    double toc = Math.min(iTimeOverlapMaxLimit * c.getShare() / e.getNrSlots(), iTimeOverlapMaxLimit);
    return round(getWeight(assignment, e) * toc);
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:7,代码来源:PriorityStudentWeights.java


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