Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7f575d8

Browse files
Justina LemJustina Lem
Justina Lem
authored and
Justina Lem
committed
813/913 constraint fix
1 parent 19d2e58 commit 7f575d8

File tree

5 files changed

+674
-49
lines changed

5 files changed

+674
-49
lines changed

‎CourseLab.java‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ public class CourseLab {
2525
private ArrayList<CourseLab> notCompatibleCoursesLabs;//replaces associatedLecture/Course/Lab, plus additional not compatible CourseLabs
2626
private int slotId = -1;//default value is -1 for unassigned slot
2727
private ArrayList<Integer> unwantedSlotIds;
28+
private ArrayList<slotPref> slotPrefList;
29+
private ArrayList<CourseLab> pairList;
2830

2931
//TODO: provide documentation for this constructor. What is int id argument for?
3032
public CourseLab(String name, int id, int lectureNumber, int labNumber, boolean isCourse, boolean isLab, CourseLab associatedLecture){
@@ -37,6 +39,8 @@ public CourseLab(String name, int id, int lectureNumber, int labNumber, boolean
3739
this.associatedLecture = associatedLecture;
3840
this.notCompatibleCoursesLabs = new ArrayList<>();
3941
this.unwantedSlotIds = new ArrayList<>();
42+
this.slotPrefList = new ArrayList<>();
43+
this.pairList = new ArrayList<>();
4044

4145
String[] s = name.split(" ");
4246
this.general = s[0]+" "+s[1];
@@ -98,5 +102,13 @@ public CourseLab getAssociatedLecture(){
98102
public ArrayList<Integer> getUnWantedList(){
99103
return this.unwantedSlotIds;
100104
}
105+
106+
public ArrayList<slotPref> getSlotPrefList(){
107+
return this.slotPrefList;
108+
}
109+
110+
public ArrayList<CourseLab> getPairList(){
111+
return this.pairList;
112+
}
101113

102114
}

‎Driver.java‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,11 @@ public void actionPerformed(ActionEvent evt) {
8383
setLocationRelativeTo(null); // centers on screen
8484
}
8585

86-
/* public static void main(String[]args){
87-
86+
public static void main(String[]args){
87+
Parser aParser = new Parser("SE2.txt");
88+
aParser.start();
89+
}
90+
/*
8891
String input = null;
8992
File file = null;
9093
do {

‎OTS.java‎

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ else if(constr(byParent2) == true){
289289
* check if assign is valid (against hard constraints)
290290
* returns true for valid, false for invalid
291291
*/
292-
public boolean constr(int[] assign) {
292+
public boolean constr(int[] assign) {//TODO: change this back to private when done testing
293293
//In this loop, check for course incompatibility as well as unwanted time slots
294294
for(int i = 0; i < assign.length; i++){
295295
int slotId = assign[i];
@@ -421,23 +421,26 @@ public boolean slotsOverlap(int slotId, int otherSlotId){
421421

422422
// Control 1
423423
public int[] getIndividual(){
424-
foundIndividual = 0;
425-
altern(root);
426-
427-
//System.out.println("********************** DUBUG: assignment vectors of children of root:");
428-
ArrayList<otsNode> childrenOfRoot = root.getChildren();
429-
430-
System.out.println("********************** DUBUG: Returned from altern(root)");
431-
System.out.println("********************** DUBUG: Root has " + childrenOfRoot.size() + " children.");
432-
System.out.println("********************** DUBUG: assignment vectors of children of root:");
433-
for(int i = 0; i < childrenOfRoot.size(); i++){ ////////////////////////////////DEBUG
434-
int[] cAssign = childrenOfRoot.get(i).getAssign();
435-
System.out.println("********************** DUBUG: " + Arrays.toString(cAssign));
436-
System.out.println("****************************** DUBUG: this child has " + childrenOfRoot.get(i).getChildren().size() + " children.");
437-
}
424+
long terminateSearchAtThisTime = System.currentTimeMillis() + 1000;
425+
foundIndividual = 0;
426+
altern(root);
427+
ArrayList<otsNode> childrenOfRoot = root.getChildren();
428+
429+
System.out.println("********************** DUBUG: Returned from altern(root)");
430+
System.out.println("********************** DUBUG: Root has " + childrenOfRoot.size() + " children.");
431+
System.out.println("********************** DUBUG: assignment vectors of children of root:");
432+
for(int i = 0; i < childrenOfRoot.size(); i++){ ////////////////////////////////DEBUG
433+
int[] cAssign = childrenOfRoot.get(i).getAssign();
434+
System.out.println("********************** DUBUG: " + Arrays.toString(cAssign));
435+
System.out.println("****************************** DUBUG: this child has " + childrenOfRoot.get(i).getChildren().size() + " children.");
436+
}
438437

439438
otsNode currentNode = root;
440439
while (foundIndividual == 0){
440+
if (System.currentTimeMillis() > terminateSearchAtThisTime) {
441+
int[] empty = new int[0];
442+
return empty;
443+
}
441444
currentNode = chooseNode(currentNode);
442445
System.out.println("********************** DUBUG: returned from chooseNode");
443446
if (isFullVector(currentNode)){

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /