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


Java Criterion类代码示例

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


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

示例1: InstructorSchedulingSuggestions

import org.cpsolver.ifs.criteria.Criterion; //导入依赖的package包/类
public InstructorSchedulingSuggestions(InstructorSchedulingSolver solver) {
	iSolver = solver;
	iModel = (InstructorSchedulingModel)solver.currentSolution().getModel();
	iAssignment = solver.currentSolution().getAssignment();
	for (TeachingRequest.Variable variable: iModel.variables()) {
		TeachingAssignment value = iAssignment.getValue(variable);
		if (value == null) {
			iInitialUnassignments.add(variable);
		} else {
			iInitialAssignments.put(variable, value);
		}
	}
	iValue = iModel.getTotalValue(iAssignment);
	for (Criterion<TeachingRequest.Variable, TeachingAssignment> c: iModel.getCriteria())
		iValues.put(c.getName(), c.getValue(iAssignment));
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:17,代码来源:InstructorSchedulingSuggestions.java

示例2: incJenrl

import org.cpsolver.ifs.criteria.Criterion; //导入依赖的package包/类
/**
 * Increment the number of joined enrollments (during student final
 * sectioning)
 * @param assignment current assignment
 * @param student student added in between the two classes of this constraint
 */
public void incJenrl(Assignment<Lecture, Placement> assignment, Student student) {
    JenrlConstraintContext context = getContext(assignment);
    boolean hard = context.isOverLimit();
    double jenrlWeight = student.getJenrlWeight(first(), second());
    iJenrl += jenrlWeight;
    Double conflictPriority = student.getConflictingPriorty(first(), second());
    if (conflictPriority != null) iPriority += conflictPriority * jenrlWeight;
    iStudents.add(student);
    if (student.getInstructor() != null && (student.getInstructor().variables().contains(first()) ||
            student.getInstructor().variables().contains(second())))
        iInstructors.add(student);
    for (Criterion<Lecture, Placement> criterion: getModel().getCriteria())
        if (criterion instanceof StudentConflict)
            ((StudentConflict)criterion).incJenrl(assignment, this, jenrlWeight, conflictPriority, student);
    if (!hard && context.isOverLimit() && isInConflict(assignment)) {
        context.incLimit(jenrlWeight);
    }
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:25,代码来源:JenrlConstraint.java

示例3: decJenrl

import org.cpsolver.ifs.criteria.Criterion; //导入依赖的package包/类
/**
 * Decrement the number of joined enrollments (during student final
 * sectioning)
 * @param assignment current assignment
 * @param student student removed from between the two classes of this constraint
 */
public void decJenrl(Assignment<Lecture, Placement> assignment, Student student) {
    JenrlConstraintContext context = getContext(assignment);
    boolean hard = context.isOverLimit();
    double jenrlWeight = student.getJenrlWeight(first(), second());
    iJenrl -= jenrlWeight;
    Double conflictPriority = student.getConflictingPriorty(first(), second());
    if (conflictPriority != null) iPriority -= conflictPriority * jenrlWeight;
    iStudents.remove(student);
    iInstructors.remove(student);
    for (Criterion<Lecture, Placement> criterion: getModel().getCriteria())
        if (criterion instanceof StudentConflict)
            ((StudentConflict)criterion).incJenrl(assignment, this, -jenrlWeight, conflictPriority, student);
    if (hard && !context.isOverLimit())
        context.decLimit(jenrlWeight);
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:22,代码来源:JenrlConstraint.java

示例4: toString

import org.cpsolver.ifs.criteria.Criterion; //导入依赖的package包/类
/**
 * String representation -- returns a list of values of objective criteria
 * @param assignment current assignment
 * @return comma separated string of {@link TimetablingCriterion#toString(Assignment)}
 */
public String toString(Assignment<V, T> assignment) {
    List<Criterion<V, T>> criteria = new ArrayList<Criterion<V,T>>(getCriteria());
    Collections.sort(criteria, new Comparator<Criterion<V, T>>() {
        @Override
        public int compare(Criterion<V, T> c1, Criterion<V, T> c2) {
            int cmp = -Double.compare(c1.getWeight(), c2.getWeight());
            if (cmp != 0) return cmp;
            return c1.getName().compareTo(c2.getName());
        }
    });
    String ret = "";
    for (Criterion<V, T> criterion: criteria) {
        String val = criterion.toString(assignment);
        if (val != null && !val.isEmpty())
            ret += ", " + val;
    }
    return (nrUnassignedVariables(assignment) == 0 ? "" : "V:" + nrAssignedVariables(assignment) + "/" + variables().size() + ", ") + "T:" + sDoubleFormat.format(getTotalValue(assignment)) + ret;
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:24,代码来源:Model.java

示例5: toInstructorInfo

import org.cpsolver.ifs.criteria.Criterion; //导入依赖的package包/类
protected InstructorInfo toInstructorInfo(TeachingAssignment assignment) {
	InstructorInfo info = toInstructorInfo(assignment.getInstructor());
	info.setAssignmentIndex(assignment.variable().getInstructorIndex());
	Instructor.Context context = assignment.getInstructor().getContext(currentSolution().getAssignment());
	if (context != null)
		info.setAssignedLoad(context.getLoad());
	for (Criterion<TeachingRequest.Variable, TeachingAssignment> c: assignment.variable().getModel().getCriteria()) {
		double value = c.getValue(currentSolution().getAssignment(), assignment, null);
		if (value != 0) info.setValue(c.getName(), value);
	}
	return info;
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:13,代码来源:InstructorSchedulingSolver.java

示例6: updateCriterion

import org.cpsolver.ifs.criteria.Criterion; //导入依赖的package包/类
/**
 * Update value of FlexibleConstraintCriterion and number of violated FlexibleConstraints
 */
protected void updateCriterion(Assignment<Lecture, Placement> assignment) {
    if (!isHard()) {
        Criterion<Lecture, Placement> criterion = getModel().getCriterion(FlexibleConstraintCriterion.class);
        if (criterion != null) {
            criterion.inc(assignment, -iLastPreference);                
            iLastPreference = getCurrentPreference(assignment, null, null);
            criterion.inc(assignment, iLastPreference);  
        }
    }
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:14,代码来源:FlexibleConstraint.java

示例7: MaxHalfDaysFlexibleConstraintContext

import org.cpsolver.ifs.criteria.Criterion; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public MaxHalfDaysFlexibleConstraintContext(Assignment<Lecture, Placement> assignment) {
    super();
    iHalfDayAssignments = new Set[getNrHalfDays() * Constants.NR_DAYS];
    for (int i = 0; i < iHalfDayAssignments.length; i++)
        iHalfDayAssignments[i] = new HashSet<Lecture>();
    
    for (Lecture variable: variables()) {
        Placement value = assignment.getValue(variable);
        if (value != null) {
            for (int i = 0; i < Constants.DAY_CODES.length; i++)
                if ((value.getTimeLocation().getDayCode() & Constants.DAY_CODES[i]) != 0)
                    iHalfDayAssignments[i * getNrHalfDays() + getHalfDay(value.getTimeLocation())].add(value.variable());
        }
    }
    
    if (!isHard()) {
        Criterion<Lecture, Placement> criterion = getModel().getCriterion(FlexibleConstraintCriterion.class);
        if (criterion != null) {
            double pref = nrViolations(null, null);
            if (pref == 0)
                iLastPreference = -Math.abs(iPreference);
            else 
                iLastPreference = Math.abs(iPreference) * pref;
            criterion.inc(assignment, iLastPreference);  
        }
    }
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:29,代码来源:MaxHalfDaysFlexibleConstraint.java

示例8: MaxDaysFlexibleConstraintContext

import org.cpsolver.ifs.criteria.Criterion; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public MaxDaysFlexibleConstraintContext(Assignment<Lecture, Placement> assignment) {
    super();
    iDayAssignments = new Set[Constants.NR_DAYS];
    for (int i = 0; i < iDayAssignments.length; i++)
        iDayAssignments[i] = new HashSet<Lecture>();
    
    for (Lecture variable: variables()) {
        Placement value = assignment.getValue(variable);
        if (value != null) {
            for (int i = 0; i < iDayAssignments.length; i++)
                if ((value.getTimeLocation().getDayCode() & Constants.DAY_CODES[i]) != 0)
                    iDayAssignments[i].add(value.variable());
        }
    }
    
    if (!isHard()) {
        Criterion<Lecture, Placement> criterion = getModel().getCriterion(FlexibleConstraintCriterion.class);
        if (criterion != null) {
            double pref = nrViolations(null, null);
            if (pref == 0)
                iLastPreference = -Math.abs(iPreference);
            else 
                iLastPreference = Math.abs(iPreference) * pref;
            criterion.inc(assignment, iLastPreference);  
        }
    }
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:29,代码来源:MaxDaysFlexibleConstraint.java

示例9: MaxWeeksFlexibleConstraintContext

import org.cpsolver.ifs.criteria.Criterion; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public MaxWeeksFlexibleConstraintContext(Assignment<Lecture, Placement> assignment) {
    super();
    iWeeks = ((TimetableModel)getModel()).getWeeks();
    iWeekAssignments = new Set[iWeeks.size()];
    for (int i = 0; i < iWeekAssignments.length; i++)
        iWeekAssignments[i] = new HashSet<Lecture>();
    
    for (Lecture variable: variables()) {
        Placement value = assignment.getValue(variable);
        if (value != null && isCorectDayOfWeek(value)) {
            for (int i = 0; i < iWeeks.size(); i++)
                if (value.getTimeLocation().shareWeeks(iWeeks.get(i)))
                    iWeekAssignments[i].add(value.variable());
        }
    }
    
    if (!isHard()) {
        Criterion<Lecture, Placement> criterion = getModel().getCriterion(FlexibleConstraintCriterion.class);
        if (criterion != null) {
            double pref = nrViolations(null, null);
            if (pref == 0)
                iLastPreference = -Math.abs(iPreference);
            else 
                iLastPreference = Math.abs(iPreference) * pref;
            criterion.inc(assignment, iLastPreference);  
        }
    }
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:30,代码来源:MaxWeeksFlexibleConstraint.java

示例10: getInfo

import org.cpsolver.ifs.criteria.Criterion; //导入依赖的package包/类
@Override
public void getInfo(Assignment<Lecture, Placement> assignment, Map<String, String> info) {
    super.getInfo(assignment, info);
    double conf = getValue(assignment);
    if (conf > 0.0) {
        Criterion<Lecture, Placement> c = getModel().getCriterion(InstructorStudentHardConflict.class);
        double hard = (c == null ? 0.0 : c.getValue(assignment));
        info.put("Instructor student conflicts", sDoubleFormat.format(conf) + (hard > 0.0 ? " [hard: " + sDoubleFormat.format(hard) + "]" : ""));
    }
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:11,代码来源:InstructorStudentConflict.java

示例11: getInfo

import org.cpsolver.ifs.criteria.Criterion; //导入依赖的package包/类
@Override
public void getInfo(Assignment<Lecture, Placement> assignment, Map<String, String> info) {
    super.getInfo(assignment, info);
    double conf = getValue(assignment);
    if (conf > 0.0) {
        Criterion<Lecture, Placement> c = getModel().getCriterion(ImportantStudentHardConflict.class);
        double hard = (c == null ? 0.0 : c.getValue(assignment));
        info.put("Important student conflicts", sDoubleFormat.format(conf) + (hard > 0.0 ? " [hard: " + sDoubleFormat.format(hard) + "]" : ""));
    }
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:11,代码来源:ImportantStudentConflict.java

示例12: getInfo

import org.cpsolver.ifs.criteria.Criterion; //导入依赖的package包/类
@Override
public void getInfo(Assignment<Lecture, Placement> assignment, Map<String, String> info) {
    super.getInfo(assignment, info);
    double conf = getValue(assignment);
    if (conf > 0.0) {
        Criterion<Lecture, Placement> c = getModel().getCriterion(IgnoredCommittedStudentConflict.class);
        double committed = (c == null ? 0.0 : c.getValue(assignment));
        info.put("Ignored student conflicts", sDoubleFormat.format(conf) + (committed > 0.0 ? " [committed: " + sDoubleFormat.format(committed) + "]" : ""));
    }
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:11,代码来源:IgnoredStudentConflict.java

示例13: getTotalValue

import org.cpsolver.ifs.criteria.Criterion; //导入依赖的package包/类
@Override
public double getTotalValue(Assignment<Lecture, Placement> assignment) {
    double ret = 0;
    for (Criterion<Lecture, Placement> criterion: getCriteria())
        ret += criterion.getWeightedValue(assignment);
    return ret;
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:8,代码来源:TimetableModel.java

示例14: toDouble

import org.cpsolver.ifs.criteria.Criterion; //导入依赖的package包/类
@Override
public double toDouble(Assignment<Lecture, Placement> assignment) {
    double ret = 0.0;
    for (Criterion<Lecture, Placement> criterion: variable().getModel().getCriteria())
        ret += criterion.getWeightedValue(assignment, this, null);
    return ret;
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:8,代码来源:Placement.java

示例15: currentValue

import org.cpsolver.ifs.criteria.Criterion; //导入依赖的package包/类
/** 
 * Use {@link Model#getTotalValue()} instead.
 * @param currentSolution current solution
 * @return current value
 */
@Deprecated
public double currentValue(Solution<Lecture, Placement> currentSolution) {
    double ret = 0.0;
    for (Criterion<Lecture, Placement> criterion: currentSolution.getModel().getCriteria())
        ret += criterion.getWeightedValue();
    return ret;
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:13,代码来源:TimetableComparator.java


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