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


Java Assignment.getValue方法代码示例

本文整理汇总了Java中org.cpsolver.ifs.assignment.Assignment.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java Assignment.getValue方法的具体用法?Java Assignment.getValue怎么用?Java Assignment.getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.cpsolver.ifs.assignment.Assignment的用法示例。


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

示例1: selectNeighbour

import org.cpsolver.ifs.assignment.Assignment; //导入方法依赖的package包/类
@Override
public Neighbour<CurVariable, CurValue> selectNeighbour(Solution<CurVariable, CurValue> solution) {
	CurModel model = (CurModel)solution.getModel();
	Assignment<CurVariable, CurValue> assignment = solution.getAssignment();
	int ix = ToolBox.random(model.variables().size());
	for (int i = 0; i < model.variables().size(); i++) {
		CurVariable course = model.variables().get((ix + i) % model.variables().size());
		CurValue current = assignment.getValue(course);
		if (!course.getCourse().isComplete(assignment) && current != null) continue;
		int jx = ToolBox.random(course.values(solution.getAssignment()).size());
		if (current != null && current.getStudent().getCourses(assignment).size() <= model.getStudentLimit().getMinLimit()) continue;
		for (int j = 0; j < course.values(solution.getAssignment()).size(); j++) {
			CurValue student = course.values(solution.getAssignment()).get((j + jx) % course.values(solution.getAssignment()).size());
			if (course.getCourse().getStudents(assignment).contains(student.getStudent())) continue;
			if (student.getStudent().getCourses(assignment).size() >= model.getStudentLimit().getMaxLimit()) continue;
			if (course.getCourse().getSize(assignment) + student.getStudent().getWeight() - (current == null ? 0.0 : current.getStudent().getWeight())
					> course.getCourse().getMaxSize()) continue;
			if (current != null && course.getCourse().getSize(assignment) + student.getStudent().getWeight() - current.getStudent().getWeight()
					< course.getCourse().getMaxSize() - model.getMinStudentWidth()) continue;
			return new CurSimpleAssignment(student);
		}
	}
	return null;
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:25,代码来源:CurHillClimber.java

示例2: createModel

import org.cpsolver.ifs.assignment.Assignment; //导入方法依赖的package包/类
public static TimetableGridModel createModel(TimetableSolver solver, DepartmentSpreadConstraint department, TimetableGridContext context) {
	TimetableGridModel model = new TimetableGridModel(ResourceType.DEPARTMENT.ordinal(), department.getDepartmentId());
   	model.setName(department.getName());
   	model.setSize(department.variables().size());
   	model.setFirstDay(context.getFirstDay());
   	model.setFirstSessionDay(context.getFirstSessionDay());
   	model.setFirstDate(context.getFirstDate());

   	Assignment<Lecture, Placement> assignment = solver.currentSolution().getAssignment();
   	List<Placement> placements = new ArrayList<Placement>();
	for (Lecture lecture: department.variables()) {
		Placement placement = assignment.getValue(lecture);
		if (placement != null)
			placements.add(placement);
	}
	createCells(model, solver, placements, context, false);
	
	return model;
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:20,代码来源:TimetableGridSolverHelper.java

示例3: nrSlotsADay

import org.cpsolver.ifs.assignment.Assignment; //导入方法依赖的package包/类
private int nrSlotsADay(Assignment<Lecture, Placement> assignment, int dayCode, BitSet week, HashMap<Lecture, Placement> assignments, Set<Placement> conflicts) {
    Set<Integer> slots = new HashSet<Integer>();
    for (Lecture lecture: variables()) {
        Placement placement = null;
        if (assignments != null && assignments.containsKey(lecture))
            placement = assignments.get(lecture);
        else if (assignment != null)
            placement = assignment.getValue(lecture);
        if (placement == null || placement.getTimeLocation() == null) continue;
        if (conflicts != null && conflicts.contains(placement)) continue;
        TimeLocation t = placement.getTimeLocation();
        if (t == null || (t.getDayCode() & dayCode) == 0 || (week != null && !t.shareWeeks(week))) continue;
        for (int i = 0; i < t.getLength(); i++)
            slots.add(i + t.getStartSlot());
    }
    return slots.size();
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:18,代码来源:GroupConstraint.java

示例4: check

import org.cpsolver.ifs.assignment.Assignment; //导入方法依赖的package包/类
/**
 * Check for overlapping sections that are attended by the same student
 * @param a current assignment
 * @return false, if there is such a case
 */
public boolean check(Assignment<Request, Enrollment> a) {
    sLog.info("Checking for overlaps...");
    boolean ret = true;
    for (Student student : getModel().getStudents()) {
        HashMap<TimeLocation, SctAssignment> times = new HashMap<TimeLocation, SctAssignment>();
        for (Request request : student.getRequests()) {
            Enrollment enrollment = a.getValue(request);
            if (enrollment == null)
                continue;
            for (SctAssignment assignment : enrollment.getAssignments()) {
                if (assignment.getTime() == null)
                    continue;
                for (TimeLocation time: times.keySet()) {
                    if (time.hasIntersection(assignment.getTime())) {
                        sLog.error("Student " + student + " assignment " + assignment + " overlaps with "
                                + times.get(time));
                        ret = false;
                    }
                }
                times.put(assignment.getTime(), assignment);
            }
        }
    }
    return ret;
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:31,代码来源:OverlapCheck.java

示例5: getInfo

import org.cpsolver.ifs.assignment.Assignment; //导入方法依赖的package包/类
/** Lists the split */
@Override
public void getInfo(Assignment<Exam, ExamPlacement> assignment, Map<String, String> info) {
    if (!iChildren.isEmpty()) {
        int parents = 0;
        String split = "";
        for (Exam parent: new TreeSet<Exam>(iChildren.keySet())) {
            List<Exam> children = iChildren.get(parent);
            if (children.isEmpty()) continue;
            split += "\n  ";
            parents ++;
            split += parent.getName() + ": " + parent.getStudents().size() + " (" + (assignment.getValue(parent) == null ? "N/A" : assignment.getValue(parent).getPeriod()) + ")";
            for (Exam child: children)
                split += " + " + child.getStudents().size() + " (" + (assignment.getValue(child) == null ? "N/A" : assignment.getValue(child).getPeriod()) + ")";
        }
        if (parents > 0)
            info.put("Examination Splits", parents + split);
    }
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:20,代码来源:ExamSplitter.java

示例6: computeAdepts

import org.cpsolver.ifs.assignment.Assignment; //导入方法依赖的package包/类
public void computeAdepts(Assignment<Lecture, Placement> assignment, Collection<Placement> adepts, List<Lecture> variables, Placement value,
        Set<Placement> conflicts) {
    for (Lecture lecture : variables) {
        if (lecture.isCommitted()) continue;
        Placement placement = assignment.getValue(lecture);
        if (placement != null && !placement.equals(value) && !conflicts.contains(placement)) {
            adepts.add(placement);
        }
        if (lecture.hasAnyChildren()) {
            for (Long subpartId: lecture.getChildrenSubpartIds()) {
                computeAdepts(assignment, adepts, lecture.getChildren(subpartId), value, conflicts);
            }
        }

    }
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:17,代码来源:ClassLimitConstraint.java

示例7: hasConflict

import org.cpsolver.ifs.assignment.Assignment; //导入方法依赖的package包/类
public boolean hasConflict(Assignment<Lecture, Placement> assignment, Student student) {
    for (Lecture lecture : student.getLectures()) {
        Placement placement = assignment.getValue(lecture);
        if (placement == null || !this.equals(lecture.getConfiguration()))
            continue;
        if (student.countConflictPlacements(placement) > 0)
            return true;
        for (Lecture x : student.getLectures()) {
            if (assignment.getValue(x) == null || x.equals(lecture))
                continue;
            JenrlConstraint jenrl = lecture.jenrlConstraint(x);
            if (jenrl != null && jenrl.isInConflict(assignment))
                return true;
        }
    }
    return false;
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:18,代码来源:Configuration.java

示例8: SolverGridModel

import org.cpsolver.ifs.assignment.Assignment; //导入方法依赖的package包/类
public SolverGridModel(Solver solver, DepartmentSpreadConstraint dept, TimetableGridContext context) {
	super(sResourceTypeInstructor, dept.getDepartmentId().longValue());
	Assignment<Lecture, Placement> assignment = solver.currentSolution().getAssignment();
	setName(dept.getName());
	setSize(dept.variables().size());
	setFirstDay(context.getFirstDay());
	Vector placements = new Vector();
	for (Lecture lecture: dept.variables()) {
		Placement placement = assignment.getValue(lecture);
		if (placement != null)
			placements.add(placement);
	}
	init(solver, placements, context.getBgMode(), context);
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:15,代码来源:SolverGridModel.java

示例9: getValue

import org.cpsolver.ifs.assignment.Assignment; //导入方法依赖的package包/类
public CurValue getValue(Assignment<CurVariable, CurValue> assignment, CurStudent student) {
	for (CurVariable var: variables()) {
		CurValue val = assignment.getValue(var);
		if (val != null && val.getStudent().equals(student))
			return val;
	}
	return null;
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:9,代码来源:CurCourse.java

示例10: CurModelContext

import org.cpsolver.ifs.assignment.Assignment; //导入方法依赖的package包/类
public CurModelContext(Assignment<CurVariable, CurValue> assignment) {
	for (CurVariable var: variables()) {
		CurValue val = assignment.getValue(var);
		if (val != null)
			assigned(assignment, val);
	}
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:8,代码来源:CurModel.java

示例11: ViolatedDistrPreference

import org.cpsolver.ifs.assignment.Assignment; //导入方法依赖的package包/类
public ViolatedDistrPreference(Solver solver, GroupConstraint gc) {
	Assignment<Lecture, Placement> assignment = solver.currentSolution().getAssignment();
	iPreference = gc.getPreference();
	iType = gc.getType().reference();
	iName = gc.getName();
	iViolations = gc.getCurrentPreference(assignment) / Math.abs(iPreference);
	for (Lecture lecture: gc.variables()) {
		if (assignment.getValue(lecture)==null) continue;
		iClasses.add(new ClassAssignmentDetails(solver,lecture,false));
	}
	Collections.sort(iClasses);
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:13,代码来源:ViolatedDistrPreferencesReport.java

示例12: PerturbationReport

import org.cpsolver.ifs.assignment.Assignment; //导入方法依赖的package包/类
public PerturbationReport(Solver solver) {
	Assignment<Lecture, Placement> assignment = solver.currentSolution().getAssignment();
	TimetableModel model = (TimetableModel)solver.currentSolution().getModel();
	for (Lecture lecture: model.perturbVariables(assignment)) {
		Placement placement = assignment.getValue(lecture);
		Placement initial = lecture.getInitialAssignment();
		if (placement==null || initial==null || placement.equals(initial)) continue;
		iGroups.add(new PerturbationGroup(solver,lecture));
	}
	
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:12,代码来源:PerturbationReport.java

示例13: conflictValues

import org.cpsolver.ifs.assignment.Assignment; //导入方法依赖的package包/类
private List<T> conflictValues(Assignment<V, T> assignment, Constraint<V, T> constraint, T aValue) {
    List<T> ret = new ArrayList<T>();

    for (V variable : constraint.variables()) {
        if (variable.equals(aValue.variable()))
            continue;
        if (assignment.getValue(variable) != null)
            continue;

        for (T value : goodValues(variable))
            if (!constraint.isConsistent(aValue, value))
                ret.add(value);
    }
    return ret;
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:16,代码来源:MacPropagation.java

示例14: conflictLectures

import org.cpsolver.ifs.assignment.Assignment; //导入方法依赖的package包/类
/**
 * Lectures different from this one, where it is student conflict of the
 * given student between this and the lecture
 * @param assignment current assignment
 * @param student a student
 * @return list of lectures with a student conflict 
 */
public List<Lecture> conflictLectures(Assignment<Lecture, Placement> assignment, Student student) {
    List<Lecture> ret = new ArrayList<Lecture>();
    if (assignment.getValue(this) == null)
        return ret;
    for (JenrlConstraint jenrl : activeJenrls(assignment)) {
        Lecture lect = jenrl.another(this);
        if (lect.students().contains(student))
            ret.add(lect);
    }
    return ret;
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:19,代码来源:Lecture.java

示例15: merge

import org.cpsolver.ifs.assignment.Assignment; //导入方法依赖的package包/类
/**
 * Merge an exam
 * @param assignment current assignment
 * @param child an exam to be merged
 * @param iteration solver iteration
 * @return parent exam of the exam that has been deleted; null if the given exam cannot be merged
 */
public Exam merge(Assignment<Exam, ExamPlacement> assignment, Exam child, long iteration) {
    if (!canMerge(child)) return null;
    
    // Update the parent and children structures
    Exam parent = iParent.get(child);
    iParent.remove(child);
    List<Exam> children = iChildren.get(parent);
    children.remove(child);
    iValue -= 1.0;
    
    // Unassign parent and the given exam
    ExamPlacement parentPlacement = assignment.getValue(parent);
    if (parentPlacement != null) assignment.unassign(iteration, parent);
    if (assignment.getValue(child) != null) assignment.unassign(iteration, child);

    // Move students back from the given exam
    for (ExamStudent student: new ArrayList<ExamStudent>(child.getStudents())) {
        student.removeVariable(child);
        student.addVariable(parent);
    }
    
    // Remove the given exam from the model
    for (ExamRoomPlacement room : child.getRoomPlacements()) 
        room.getRoom().removeVariable(child);
    parent.getModel().removeVariable(child);
    
    // Assign parent exam back
    if (parentPlacement != null) assignment.assign(iteration, parentPlacement);
    
    
    // Shuffle students between parent exam and its remaining children
    shuffle(assignment, parent, iteration);
    
    // Return parent exam
    return parent;
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:44,代码来源:ExamSplitter.java


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