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


Java Solver类代码示例

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


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

示例1: init

import org.cpsolver.ifs.solver.Solver; //导入依赖的package包/类
private void init(Solver solver, Placement[] resource, TimetableGridContext context) {
	Map<Lecture, TimetableGridCell> processed = new HashMap<Lecture, TimetableGridCell>();
	List<Placement> placements = new ArrayList<Placement>();
	for (int i=0;i<Constants.DAY_CODES.length;i++) {
		for (int j=0;j<Constants.SLOTS_PER_DAY;j++) {
			Placement placement = resource[i*Constants.SLOTS_PER_DAY+j];
			if (placement==null) continue;
			Lecture lecture = placement.variable();
			if (lecture.isCommitted()) continue;
			TimetableGridCell cell = processed.get(lecture);
			if (cell == null) {
				cell = createCell(solver, i,j,lecture, placement, context.getBgMode());
				processed.put(lecture, cell);
				placements.add(placement);
			} else {
				cell = cell.copyCell(i,cell.getMeetingNumber()+1);
			}
			addCell(i,j,cell);
			j+=placement.getTimeLocation().getNrSlotsPerMeeting()-1;
		}
	}
	setUtilization(countUtilization(context, placements));
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:24,代码来源:SolverGridModel.java

示例2: DeptBalancingGroup

import org.cpsolver.ifs.solver.Solver; //导入依赖的package包/类
public DeptBalancingGroup(Solver solver, DepartmentSpreadConstraint deptSpread) {
	Assignment<Lecture, Placement> assignment = solver.currentSolution().getAssignment();
	iDeptId = deptSpread.getDepartmentId();
	iDeptName = deptSpread.getName();
	iLimit = new int[iLastDaySlot - iFirstDaySlot + 1][iLastWorkDay - iFirstWorkDay + 1];
	iUsage = new int[iLastDaySlot - iFirstDaySlot + 1][iLastWorkDay - iFirstWorkDay + 1];
	iCourses = new HashSet[iLastDaySlot - iFirstDaySlot + 1][iLastWorkDay - iFirstWorkDay + 1];
	Hashtable detailCache = new Hashtable();
	SpreadConstraint.SpreadConstraintContext context = deptSpread.getContext(assignment);
	for (int i=0;i<iLastDaySlot - iFirstDaySlot + 1;i++) {
		for (int j=0;j<iLastWorkDay - iFirstWorkDay + 1;j++) {
			iLimit[i][j]=context.getMaxCourses(i + iFirstDaySlot, j + iFirstWorkDay);
			iUsage[i][j]=context.getCourses(i + iFirstDaySlot, j + iFirstWorkDay).size();
			iCourses[i][j]=new HashSet(context.getCourses(i + iFirstDaySlot, j + iFirstWorkDay).size());
			for (Placement placement: context.getCourses(i + iFirstDaySlot, j + iFirstWorkDay)) {
				Lecture lecture = (Lecture)placement.variable();
				ClassAssignmentDetails ca = (ClassAssignmentDetails)detailCache.get(lecture.getClassId());
				if (ca==null) {
					ca = new ClassAssignmentDetails(solver, lecture, false);
					detailCache.put(lecture.getClassId(),ca);
				}
				iCourses[i][j].add(ca);
			}
		}
	}
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:27,代码来源:DeptBalancingReport.java

示例3: StudentGroupInfo

import org.cpsolver.ifs.solver.Solver; //导入依赖的package包/类
public StudentGroupInfo(Solver<Lecture, Placement> solver, StudentGroup group) {
	super();
	iId = group.getId();
	iName = group.getName();
	iWeight = group.getWeight();
	iValue = value(group);
	
	Map<Lecture, List<Student>> class2students = new HashMap<Lecture, List<Student>>();
	for (Student student: group.getStudents()) {
		for (Lecture lecture: student.getLectures()) {
			List<Student> students = class2students.get(lecture);
			if (students == null) {
				students = new ArrayList<Student>();
				class2students.put(lecture, students);
			}
			students.add(student);
		}
	}
	iClasses = new ArrayList<ClassInfo>();
	for (Map.Entry<Lecture, List<Student>> entry: class2students.entrySet()) {
		iClasses.add(new ClassInfo(entry.getKey(), entry.getValue()));
	}
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:24,代码来源:StudentGroupInfo.java

示例4: SameSubpartBalancingGroup

import org.cpsolver.ifs.solver.Solver; //导入依赖的package包/类
public SameSubpartBalancingGroup(Solver solver, SpreadConstraint spread) {
	Assignment<Lecture, Placement> assignment = solver.currentSolution().getAssignment();
	SpreadConstraint.SpreadConstraintContext context = spread.getContext(assignment);
	iName = spread.getName();
	iLimit = new int[iLastDaySlot - iFirstDaySlot + 1][iLastWorkDay - iFirstWorkDay + 1];
	iUsage = new int[iLastDaySlot - iFirstDaySlot + 1][iLastWorkDay - iFirstWorkDay + 1];
	iCourses = new HashSet[iLastDaySlot - iFirstDaySlot + 1][iLastWorkDay - iFirstWorkDay + 1];
	Hashtable detailCache = new Hashtable();
	for (int i=0;i<iLastDaySlot - iFirstDaySlot + 1;i++) {
		for (int j=0;j<iLastWorkDay - iFirstWorkDay + 1;j++) {
			iLimit[i][j]=context.getMaxCourses(i + iFirstDaySlot, j + iFirstWorkDay);
			iUsage[i][j]=context.getCourses(i + iFirstDaySlot, j + iFirstWorkDay).size();
			iCourses[i][j]=new HashSet(context.getCourses(i + iFirstDaySlot, j + iFirstWorkDay).size());
			for (Placement placement: context.getCourses(i + iFirstDaySlot, j + iFirstWorkDay)) {
				Lecture lecture = (Lecture)placement.variable();
				ClassAssignmentDetails ca = (ClassAssignmentDetails)detailCache.get(lecture.getClassId());
				if (ca==null) {
					ca = new ClassAssignmentDetails(solver, lecture, false);
					detailCache.put(lecture.getClassId(),ca);
				}
				iCourses[i][j].add(ca);
			}
		}
	}
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:26,代码来源:SameSubpartBalancingReport.java

示例5: TimetableXMLSaver

import org.cpsolver.ifs.solver.Solver; //导入依赖的package包/类
public TimetableXMLSaver(Solver<Lecture, Placement> solver) {
    super(solver);
    
    
    iOutputFolder = new File(getModel().getProperties().getProperty("General.Output",
            "." + File.separator + "output"));
    iShowNames = getModel().getProperties().getPropertyBoolean("Xml.ShowNames", false);
    iExportStudentSectioning = getModel().getProperties().getPropertyBoolean("Xml.ExportStudentSectioning", false);
    if (ANONYMISE) {
        // anonymise saved XML file -- if not set otherwise in the
        // configuration
        iConvertIds = getModel().getProperties().getPropertyBoolean("Xml.ConvertIds", true);
        iSaveBest = getModel().getProperties().getPropertyBoolean("Xml.SaveBest", false);
        iSaveInitial = getModel().getProperties().getPropertyBoolean("Xml.SaveInitial", false);
        iSaveCurrent = getModel().getProperties().getPropertyBoolean("Xml.SaveCurrent", true);
    } else {
        // normal operation -- if not set otherwise in the configuration
        iConvertIds = getModel().getProperties().getPropertyBoolean("Xml.ConvertIds", false);
        iSaveBest = getModel().getProperties().getPropertyBoolean("Xml.SaveBest", true);
        iSaveInitial = getModel().getProperties().getPropertyBoolean("Xml.SaveInitial", true);
        iSaveCurrent = getModel().getProperties().getPropertyBoolean("Xml.SaveCurrent", true);
    }
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:24,代码来源:TimetableXMLSaver.java

示例6: init

import org.cpsolver.ifs.solver.Solver; //导入依赖的package包/类
/**
 * Initialization
 */
@Override
public void init(Solver<Exam, ExamPlacement> solver) {
    super.init(solver);
    if (iColor != null)
        iColor.init(solver);
    iCon.init(solver);
    iStd.init(solver);
    iSA.init(solver);
    iHC.init(solver);
    iFin.init(solver);
    iGD.init(solver);
    if (iTerm == null) {
        iTerm = solver.getTerminationCondition();
        solver.setTerminalCondition(this);
    }
    iFinalPhase = false;
    iProgress = Progress.getInstance(solver.currentSolution().getModel());
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:22,代码来源:ExamNeighbourSelection.java

示例7: SolverGridModel

import org.cpsolver.ifs.solver.Solver; //导入依赖的package包/类
public SolverGridModel(Solver solver, int resourceType, long resourceId, String name, int size, Collection<Placement> placements, TimetableGridContext context) {
	super(resourceType, resourceId);
	setName(name);
	setSize(size);
	setFirstDay(context.getFirstDay());
	init(solver, placements, context.getBgMode(), context);
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:8,代码来源:SolverGridModel.java

示例8: InstructorSchedulingDatabaseSaver

import org.cpsolver.ifs.solver.Solver; //导入依赖的package包/类
public InstructorSchedulingDatabaseSaver(Solver solver) {
    super(solver);
    iProgress = Progress.getInstance(getModel());
    iSessionId = getModel().getProperties().getPropertyLong("General.SessionId", (Long)null);
	for (Long id: getModel().getProperties().getPropertyLongArry("General.SolverGroupId", null))
		iSolverGroupId.add(id);
	iTentative = !getModel().getProperties().getPropertyBoolean("Save.Commit", false);
	iInstructorFormat = getModel().getProperties().getProperty("General.InstructorFormat", NameFormat.LAST_FIRST.reference());
	iShowClassSuffix = ApplicationProperty.SolverShowClassSufix.isTrue();
	iShowConfigName = ApplicationProperty.SolverShowConfiguratioName.isTrue();
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:12,代码来源:InstructorSchedulingDatabaseSaver.java

示例9: DeptBalancingReport

import org.cpsolver.ifs.solver.Solver; //导入依赖的package包/类
public DeptBalancingReport(Solver solver) {
	TimetableModel model = (TimetableModel)solver.currentSolution().getModel();
	iFirstDaySlot = model.getProperties().getPropertyInt("General.FirstDaySlot", Constants.DAY_SLOTS_FIRST);
       iLastDaySlot = model.getProperties().getPropertyInt("General.LastDaySlot", Constants.DAY_SLOTS_LAST);
       iFirstWorkDay = model.getProperties().getPropertyInt("General.FirstWorkDay", 0);
       iLastWorkDay = model.getProperties().getPropertyInt("General.LastWorkDay", Constants.NR_DAYS_WEEK - 1);
	for (DepartmentSpreadConstraint deptSpread: model.getDepartmentSpreadConstraints()) {
		iGroups.add(new DeptBalancingGroup(solver,deptSpread));
	}
	
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:12,代码来源:DeptBalancingReport.java

示例10: ViolatedDistrPreferencesReport

import org.cpsolver.ifs.solver.Solver; //导入依赖的package包/类
public ViolatedDistrPreferencesReport(Solver solver) {
	TimetableModel model = (TimetableModel)solver.currentSolution().getModel();
	Assignment<Lecture, Placement> assignment = solver.currentSolution().getAssignment();
	for (GroupConstraint gc: model.getGroupConstraints()) {
		if (!gc.isSatisfied(assignment))
			iGroups.add(new ViolatedDistrPreference(solver, gc));
	}
	for (FlexibleConstraint fc: model.getFlexibleConstraints()) {
		if (!fc.isHard() && fc.getContext(assignment).getPreference() > 0.0) {
			iGroups.add(new ViolatedDistrPreference(solver, fc));
		}
	}
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:14,代码来源:ViolatedDistrPreferencesReport.java

示例11: ViolatedDistrPreference

import org.cpsolver.ifs.solver.Solver; //导入依赖的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: SameSubpartBalancingReport

import org.cpsolver.ifs.solver.Solver; //导入依赖的package包/类
public SameSubpartBalancingReport(Solver solver) {
	TimetableModel model = (TimetableModel)solver.currentSolution().getModel();
	iFirstDaySlot = model.getProperties().getPropertyInt("General.FirstDaySlot", Constants.DAY_SLOTS_FIRST);
       iLastDaySlot = model.getProperties().getPropertyInt("General.LastDaySlot", Constants.DAY_SLOTS_LAST);
       iFirstWorkDay = model.getProperties().getPropertyInt("General.FirstWorkDay", 0);
       iLastWorkDay = model.getProperties().getPropertyInt("General.LastWorkDay", Constants.NR_DAYS_WEEK - 1);
	Assignment<Lecture, Placement> assignment = solver.currentSolution().getAssignment();
	for (SpreadConstraint spread: model.getSpreadConstraints()) {
		if (spread.getPenalty(assignment)==0) continue;
		iGroups.add(new SameSubpartBalancingGroup(solver,spread));
	}
	
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:14,代码来源:SameSubpartBalancingReport.java

示例13: DiscouragedBtb

import org.cpsolver.ifs.solver.Solver; //导入依赖的package包/类
public DiscouragedBtb(Solver solver, InstructorConstraint ic, double distance, Placement first, Placement second, String pref) {
	iPreference = pref;
	iInstructorId = ic.getResourceId();
	iInstructorName = ic.getName();
	iDistance = distance;
	iFirst = new ClassAssignmentDetails(solver,(Lecture)first.variable(),false);
	iSecond = new ClassAssignmentDetails(solver,(Lecture)second.variable(),false);
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:9,代码来源:DiscouragedInstructorBtbReport.java

示例14: PerturbationReport

import org.cpsolver.ifs.solver.Solver; //导入依赖的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

示例15: StudentSectioningDatabaseSaver

import org.cpsolver.ifs.solver.Solver; //导入依赖的package包/类
public StudentSectioningDatabaseSaver(Solver solver) {
    super(solver);
    iIncludeCourseDemands = solver.getProperties().getPropertyBoolean("Load.IncludeCourseDemands", iIncludeCourseDemands);
    iInitiative = solver.getProperties().getProperty("Data.Initiative");
    iYear = solver.getProperties().getProperty("Data.Year");
    iTerm = solver.getProperties().getProperty("Data.Term");
    iProgress = Progress.getInstance(getModel());
    iProjections = "Projection".equals(solver.getProperties().getProperty("StudentSctBasic.Mode", "Initial"));
    iUpdateCourseRequests = solver.getProperties().getPropertyBoolean("Interactive.UpdateCourseRequests", true);
    iOwnerId = solver.getProperties().getProperty("General.OwnerPuid");
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:12,代码来源:StudentSectioningDatabaseSaver.java


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