本文整理匯總了Java中org.cpsolver.exam.criteria.StudentDistanceBackToBackConflicts類的典型用法代碼示例。如果您正苦於以下問題:Java StudentDistanceBackToBackConflicts類的具體用法?Java StudentDistanceBackToBackConflicts怎麽用?Java StudentDistanceBackToBackConflicts使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
StudentDistanceBackToBackConflicts類屬於org.cpsolver.exam.criteria包,在下文中一共展示了StudentDistanceBackToBackConflicts類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: ExamAssignment
import org.cpsolver.exam.criteria.StudentDistanceBackToBackConflicts; //導入依賴的package包/類
public ExamAssignment(org.cpsolver.exam.model.Exam exam, ExamPlacement placement, Assignment<org.cpsolver.exam.model.Exam, ExamPlacement> assignment) {
super(exam);
if (placement!=null) {
iNrDirectConflicts = (int)exam.getModel().getCriterion(StudentDirectConflicts.class).getValue(assignment, placement, null) +
(int)exam.getModel().getCriterion(StudentNotAvailableConflicts.class).getValue(assignment, placement, null);
iNrMoreThanTwoADayConflicts = (int)exam.getModel().getCriterion(StudentMoreThan2ADayConflicts.class).getValue(assignment, placement, null);
iNrBackToBackConflicts = (int)exam.getModel().getCriterion(StudentBackToBackConflicts.class).getValue(assignment, placement, null);
iNrDistanceBackToBackConflicts = (int)exam.getModel().getCriterion(StudentDistanceBackToBackConflicts.class).getValue(assignment, placement, null);
iPeriodPenalty = (int)exam.getModel().getCriterion(PeriodPenalty.class).getValue(assignment, placement, null);
iRoomSizePenalty = (int)exam.getModel().getCriterion(RoomSizePenalty.class).getValue(assignment, placement, null);
iRoomSplitPenalty = (int)exam.getModel().getCriterion(RoomSplitPenalty.class).getValue(assignment, placement, null);
iRotationPenalty = (int)exam.getModel().getCriterion(ExamRotationPenalty.class).getValue(assignment, placement, null);
iRoomPenalty = (int)exam.getModel().getCriterion(RoomPenalty.class).getValue(assignment, placement, null);
iNrInstructorDirectConflicts = (int)exam.getModel().getCriterion(InstructorDirectConflicts.class).getValue(assignment, placement, null) +
(int)exam.getModel().getCriterion(InstructorNotAvailableConflicts.class).getValue(assignment, placement, null);
iNrInstructorMoreThanTwoADayConflicts = (int)exam.getModel().getCriterion(InstructorMoreThan2ADayConflicts.class).getValue(assignment, placement, null);
iNrInstructorBackToBackConflicts = (int)exam.getModel().getCriterion(InstructorBackToBackConflicts.class).getValue(assignment, placement, null);
iNrInstructorDistanceBackToBackConflicts = (int)exam.getModel().getCriterion(InstructorDistanceBackToBackConflicts.class).getValue(assignment, placement, null);
iValue = placement.toDouble(assignment);
iPeriodId = placement.getPeriod().getId();
iPeriodIdx = placement.getPeriod().getIndex();
iRooms = new TreeSet<ExamRoomInfo>();
iPeriodPref = (exam.getPeriodPlacements().size()==1?PreferenceLevel.sRequired:PreferenceLevel.int2prolog(iPeriodPenalty));
if (placement.getRoomPlacements()!=null) {
boolean reqRoom = placement.getRoomPlacements().size()==exam.getRoomPlacements().size();
for (Iterator i=placement.getRoomPlacements().iterator();i.hasNext();) {
ExamRoomPlacement room = (ExamRoomPlacement)i.next();
iRooms.add(new ExamRoomInfo(room.getRoom(), (reqRoom?PreferenceLevel.sIntLevelRequired:room.getPenalty(placement.getPeriod()))));
}
}
MinMaxPreferenceCombination pc = new MinMaxPreferenceCombination();
for (ExamDistributionConstraint dc: placement.variable().getDistributionConstraints()) {
if (dc.isHard() || dc.isSatisfied(assignment)) continue;
pc.addPreferenceInt(dc.getWeight());
}
iDistPref = pc.getPreferenceProlog();
}
}
示例2: report
import org.cpsolver.exam.criteria.StudentDistanceBackToBackConflicts; //導入依賴的package包/類
/**
* generate report
* @param assignment current assignment
* @return resultant report
*/
public CSVFile report(Assignment<Exam, ExamPlacement> assignment) {
CSVFile csv = new CSVFile();
csv.setHeader(new CSVField[] { new CSVField("Exam"), new CSVField("Enrl"), new CSVField("Direct"),
new CSVField("Direct [%]"), new CSVField("More-2-Day"), new CSVField("More-2-Day [%]"),
new CSVField("Back-To-Back"), new CSVField("Back-To-Back [%]"), new CSVField("Dist Back-To-Back"),
new CSVField("Dist Back-To-Back [%]") });
DecimalFormat df = new DecimalFormat("0.0");
for (Exam exam : iModel.variables()) {
ExamPlacement placement = assignment.getValue(exam);
if (placement == null)
continue;
int dc = (int)iModel.getCriterion(StudentDirectConflicts.class).getValue(assignment, placement, null) +
(int)iModel.getCriterion(StudentNotAvailableConflicts.class).getValue(assignment, placement, null);
int btb = (int)iModel.getCriterion(StudentBackToBackConflicts.class).getValue(assignment, placement, null);
int dbtb = (int)iModel.getCriterion(StudentDistanceBackToBackConflicts.class).getValue(assignment, placement, null);
int m2d = (int)iModel.getCriterion(StudentMoreThan2ADayConflicts.class).getValue(assignment, placement, null);
if (dc == 0 && m2d == 0 && btb == 0 && dbtb == 0)
continue;
/*
* String section = ""; for (Enumeration
* f=exam.getCourseSections().elements();f.hasMoreElements();) {
* ExamCourseSection cs = (ExamCourseSection)f.nextElement(); if
* (section.length()>0) section+="\n"; section += cs.getName(); }
*/
csv.addLine(new CSVField[] {
new CSVField(exam.getName()),
new CSVField(exam.getStudents().size()),
new CSVField(dc),
new CSVField(df.format(100.0 * dc / exam.getStudents().size())),
new CSVField(m2d),
new CSVField(df.format(100.0 * m2d / exam.getStudents().size())),
new CSVField(btb),
new CSVField(df.format(100.0 * btb / exam.getStudents().size())),
new CSVField(dbtb),
new CSVField(df.format(100.0 * dbtb / exam.getStudents().size())) });
}
return csv;
}
示例3: report
import org.cpsolver.exam.criteria.StudentDistanceBackToBackConflicts; //導入依賴的package包/類
/**
* generate report
* @param assignment current assignment
* @return resultant report
*/
public CSVFile report(Assignment<Exam, ExamPlacement> assignment) {
CSVFile csv = new CSVFile();
csv.setHeader(new CSVField[] { new CSVField("Exam 1"), new CSVField("Enrl 1"), new CSVField("Period 1"),
new CSVField("Date 1"), new CSVField("Time 1"), new CSVField("Exam 2"), new CSVField("Enrl 2"),
new CSVField("Back-To-Back"), new CSVField("Back-To-Back [%]"), new CSVField("Distance") });
DecimalFormat df = new DecimalFormat("0.0");
boolean isDayBreakBackToBack = ((StudentBackToBackConflicts)iModel.getCriterion(StudentBackToBackConflicts.class)).isDayBreakBackToBack();
double backToBackDistance = ((StudentDistanceBackToBackConflicts)iModel.getCriterion(StudentDistanceBackToBackConflicts.class)).getBackToBackDistance();
for (Exam ex1 : iModel.variables()) {
ExamPlacement p1 = assignment.getValue(ex1);
if (p1 == null || p1.getPeriod().next() == null)
continue;
if (!isDayBreakBackToBack && p1.getPeriod().getDay() != p1.getPeriod().next().getDay())
continue;
for (Exam ex2 : iModel.variables()) {
ExamPlacement p2 = assignment.getValue(ex2);
if (p2 == null || !p2.getPeriod().equals(p1.getPeriod().next()))
continue;
List<ExamStudent> students = ex1.getJointEnrollments().get(ex2);
if (students == null || students.isEmpty())
continue;
String distStr = "";
if (backToBackDistance >= 0) {
double dist = p1.getDistanceInMeters(p2);
if (dist > 0)
distStr = String.valueOf(dist);
}
csv
.addLine(new CSVField[] {
new CSVField(ex1.getName()),
new CSVField(ex1.getStudents().size()),
new CSVField(p1.getPeriod().getIndex() + 1),
new CSVField(p1.getPeriod().getDayStr()),
new CSVField(p1.getPeriod().getTimeStr()),
new CSVField(ex2.getName()),
new CSVField(ex2.getStudents().size()),
new CSVField(students.size()),
new CSVField(df.format(100.0 * students.size()
/ Math.min(ex1.getStudents().size(), ex2.getStudents().size()))),
new CSVField(distStr) });
}
}
return csv;
}
示例4: getBackToBackDistance
import org.cpsolver.exam.criteria.StudentDistanceBackToBackConflicts; //導入依賴的package包/類
/**
* Back-to-back distance, can be set by
* problem property Exams.BackToBackDistance, or in the input xml file,
* property backToBackDistance)
* @return back-to-back distance in meters
*/
public double getBackToBackDistance() {
return ((StudentDistanceBackToBackConflicts)getCriterion(StudentDistanceBackToBackConflicts.class)).getBackToBackDistance();
}