本文整理汇总了Java中org.cpsolver.studentsct.extension.DistanceConflict.Conflict方法的典型用法代码示例。如果您正苦于以下问题:Java DistanceConflict.Conflict方法的具体用法?Java DistanceConflict.Conflict怎么用?Java DistanceConflict.Conflict使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.cpsolver.studentsct.extension.DistanceConflict
的用法示例。
在下文中一共展示了DistanceConflict.Conflict方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例3: 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;
}
示例4: 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;
}
示例5: 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;
}
示例6: 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));
}
}
示例7: 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);
}
示例8: 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());
}
}
示例9: getDistanceConflictWeight
import org.cpsolver.studentsct.extension.DistanceConflict; //导入方法依赖的package包/类
@Override
public double getDistanceConflictWeight(Assignment<Request, Enrollment> assignment,
DistanceConflict.Conflict distanceConflict) {
return iParent.getDistanceConflictWeight(assignment, distanceConflict);
}
示例10: 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);
}
示例11: remove
import org.cpsolver.studentsct.extension.DistanceConflict; //导入方法依赖的package包/类
public void remove(Assignment<Request, Enrollment> assignment, DistanceConflict.Conflict c) {
iTotalValue -= avg(c.getR1().getWeight(), c.getR2().getWeight()) * iStudentWeights.getDistanceConflictWeight(assignment, c);
}
示例12: getWeight
import org.cpsolver.studentsct.extension.DistanceConflict; //导入方法依赖的package包/类
/**
* Return weight of the given enrollment
* @param assignment current assignment
* @param enrollment given enrollment
* @param distanceConflicts distance conflicts
* @param timeOverlappingConflicts time overlapping conflicts
* @return weight (higher weight means better value)
*/
public double getWeight(Assignment<Request, Enrollment> assignment, Enrollment enrollment, Set<DistanceConflict.Conflict> distanceConflicts, Set<TimeOverlapsCounter.Conflict> timeOverlappingConflicts);
示例13: getDistanceConflictWeight
import org.cpsolver.studentsct.extension.DistanceConflict; //导入方法依赖的package包/类
/**
* Return weight of a distance conflict
* @param assignment current assignment
* @param distanceConflict distance conflict
* @return weight of the conflict
*/
public double getDistanceConflictWeight(Assignment<Request, Enrollment> assignment, DistanceConflict.Conflict distanceConflict);