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


Java DistanceConflict类代码示例

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


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

示例1: getWeight

import org.cpsolver.studentsct.extension.DistanceConflict; //导入依赖的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: getDistanceConflicts

import org.cpsolver.studentsct.extension.DistanceConflict; //导入依赖的package包/类
/**
 * Distance conflicts of idx-th assignment of the current schedule
 */
public Set<DistanceConflict.Conflict> getDistanceConflicts(Enrollment[] assignment, int idx) {
    if (getModel().getDistanceConflict() == null || assignment[idx] == null)
        return null;
    Set<DistanceConflict.Conflict> dist = getModel().getDistanceConflict().conflicts(assignment[idx]);
    for (int x = 0; x < idx; x++)
        if (assignment[x] != null)
            dist.addAll(getModel().getDistanceConflict().conflicts(assignment[x], assignment[idx]));
    return dist;
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:13,代码来源:OnlineSectioningCriterion.java

示例3: Test

import org.cpsolver.studentsct.extension.DistanceConflict; //导入依赖的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.DistanceConflict; //导入依赖的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: distanceConflicts

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

示例6: getDistanceConflicts

import org.cpsolver.studentsct.extension.DistanceConflict; //导入依赖的package包/类
/**
 * Distance conflicts of idx-th assignment of the current
 * schedule
 * @param idx index of the request
 * @return set of distance conflicts
 */
public Set<DistanceConflict.Conflict> getDistanceConflicts(int idx) {
    if (iDistanceConflict == null || iAssignment[idx] == null)
        return null;
    Set<DistanceConflict.Conflict> dist = iDistanceConflict.conflicts(iAssignment[idx]);
    for (int x = 0; x < idx; x++)
        if (iAssignment[x] != null)
            dist.addAll(iDistanceConflict.conflicts(iAssignment[x], iAssignment[idx]));
    return dist;
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:16,代码来源:BranchBoundSelection.java

示例7: getDistanceConflictWeight

import org.cpsolver.studentsct.extension.DistanceConflict; //导入依赖的package包/类
@Override
public double getDistanceConflictWeight(Assignment<Request, Enrollment> assignment, DistanceConflict.Conflict c) {
    if (c.getR1().getPriority() < c.getR2().getPriority()) {
        return round(getWeight(assignment, c.getE2()) * (c.getStudent().isNeedShortDistances() ? iShortDistanceConflict : iDistanceConflict));
    } else {
        return round(getWeight(assignment, c.getE1()) * (c.getStudent().isNeedShortDistances() ? iShortDistanceConflict : iDistanceConflict));
    }
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:9,代码来源:PriorityStudentWeights.java

示例8: getWeight

import org.cpsolver.studentsct.extension.DistanceConflict; //导入依赖的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

示例9: getDistanceConflictWeight

import org.cpsolver.studentsct.extension.DistanceConflict; //导入依赖的package包/类
@Override
public double getDistanceConflictWeight(Assignment<Request, Enrollment> assignment, DistanceConflict.Conflict c) {
    if (c.getR1().getPriority() < c.getR2().getPriority()) {
        return (1.0 - iDistConfWeight) * getWeight(assignment, c.getE1());
    } else {
        return (1.0 - iDistConfWeight) * getWeight(assignment, c.getE2());
    }
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:9,代码来源:OriginalStudentWeights.java

示例10: solutionUpdated

import org.cpsolver.studentsct.extension.DistanceConflict; //导入依赖的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

示例11: resection

import org.cpsolver.studentsct.extension.DistanceConflict; //导入依赖的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

示例12: ServerConfig

import org.cpsolver.studentsct.extension.DistanceConflict; //导入依赖的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

示例13: getDistanceConflictWeight

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

示例14: main

import org.cpsolver.studentsct.extension.DistanceConflict; //导入依赖的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

示例15: add

import org.cpsolver.studentsct.extension.DistanceConflict; //导入依赖的package包/类
public void add(Assignment<Request, Enrollment> assignment, DistanceConflict.Conflict c) {
    iTotalValue += avg(c.getR1().getWeight(), c.getR2().getWeight()) * iStudentWeights.getDistanceConflictWeight(assignment, c);
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:4,代码来源:StudentSectioningModel.java


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