Examples of UnavailablePeriodConstraint


Examples of org.drools.planner.examples.curriculumcourse.domain.UnavailablePeriodConstraint

                throws IOException {
            readHeader("UNAVAILABILITY_CONSTRAINTS:");
            List<UnavailablePeriodConstraint> constraintList = new ArrayList<UnavailablePeriodConstraint>(
                    unavailablePeriodConstraintListSize);
            for (int i = 0; i < unavailablePeriodConstraintListSize; i++) {
                UnavailablePeriodConstraint constraint = new UnavailablePeriodConstraint();
                constraint.setId((long) i);
                // Unavailability_Constraints: <CourseID> <Day> <Day_Period>
                String line = bufferedReader.readLine();
                String[] lineTokens = line.split(SPLIT_REGEX);
                if (lineTokens.length != 3) {
                    throw new IllegalArgumentException("Read line (" + line + ") is expected to contain 3 tokens.");
                }
                constraint.setCourse(courseMap.get(lineTokens[0]));
                int dayIndex = Integer.parseInt(lineTokens[1]);
                int timeslotIndex = Integer.parseInt(lineTokens[2]);
                Period period = periodMap.get(Arrays.asList(dayIndex, timeslotIndex));
                if (period == null) {
                    throw new IllegalArgumentException("Read line (" + line + ") uses an unexisting period("
                            + dayIndex + " " + timeslotIndex + ").");
                }
                constraint.setPeriod(period);
                constraintList.add(constraint);
            }
            schedule.setUnavailablePeriodConstraintList(constraintList);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.