@@ -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