Ga_time_table/classes/hospital.php
/*
	|--------------------------------------------------------------------------
	| Hour Reselect
	|--------------------------------------------------------------------------
	|	This function takes two scheduled hours in two different classrooms and swaps the courses within these hours. 
	|	Both classes have to be of same duration
	*/
|
| Hour Reselect
|
|       This function takes two scheduled hours in two different classrooms and swaps the courses within these hours.
|       Both classes have to be of same duration
| | Hour Reselect | | This function takes two scheduled hours in two different classrooms and swaps the courses within these hours . | Both classes have to be of same duration
public function hour_reselect(){			
		$rnds = $this->randClass();				
		$cls = array(0,0);
		do{			
			$cls[0] = array_rand($this->_sched[$rnds[0]],1);
			$cls[1] = array_rand($this->_sched[$rnds[1]],1);	
			if($this->_sched[$rnds[0]][$cls[0]]->getDuration() == $this->_sched[$rnds[1]][$cls[1]]->getDuration()){					
				break;
			}
		}while($this->_sched[$rnds[0]][$cls[0]]->getDuration() != $this->_sched[$rnds[1]][$cls[1]]->getDuration());
		for($i=0; $i<2; $i++){
			$sel_cls_time[] = $this->_classes[$rnds[$i]][$cls[$i]];	
		}
		$cls_duration = $this->_classes[$rnds[0]][$cls[0]]->getDuration();
		$clss_swapperA = array();
		$clss_swapperB = array();				
		$clss_swapperA = $this->fill_arr($cls[0],$cls_duration,$sel_cls_time[1]);	
		$clss_swapperB = $this->fill_arr($cls[1],$cls_duration,$sel_cls_time[0]);	
		$proxy_cls = array_replace($this->_classes[$rnds[0]],$clss_swapperA);
		$this->_classes[$rnds[0]] = $proxy_cls;		
		$proxy_cls = array_replace($this->_classes[$rnds[1]],$clss_swapperB);
		$this->_classes[$rnds[1]] = $proxy_cls;			
		$this->_sched = $this->map_class_to_hours($this->_classes);	
	}
public function hour_reselect ( ) { $ rnds = $ this -> randClass ( ) ; $ cls = array ( 0 , 0 ) ; do { $ cls [ 0 ] = array_rand ( $ this -> _sched [ $ rnds [ 0 ] ] , 1 ) ; $ cls [ 1 ] = array_rand ( $ this -> _sched [ $ rnds [ 1 ] ] , 1 ) ; if ( $ this -> _sched [ $ rnds [ 0 ] ] [ $ cls [ 0 ] ] -> getDuration ( ) == $ this -> _sched [ $ rnds [ 1 ] ] [ $ cls [ 1 ] ] -> getDuration ( ) ) { break ; } } while ( $ this -> _sched [ $ rnds [ 0 ] ] [ $ cls [ 0 ] ] -> getDuration ( ) != $ this -> _sched [ $ rnds [ 1 ] ] [ $ cls [ 1 ] ] -> getDuration ( ) ) ; for ( $ i = 0 ; $ i < 2 ; $ i ++ ) { $ sel_cls_time [ ] = $ this -> _classes [ $ rnds [ $ i ] ] [ $ cls [ $ i ] ] ; } $ cls_duration = $ this -> _classes [ $ rnds [ 0 ] ] [ $ cls [ 0 ] ] -> getDuration ( ) ; $ clss_swapperA = array ( ) ; $ clss_swapperB = array ( ) ; $ clss_swapperA = $ this -> fill_arr ( $ cls [ 0 ] , $ cls_duration , $ sel_cls_time [ 1 ] ) ; $ clss_swapperB = $ this -> fill_arr ( $ cls [ 1 ] , $ cls_duration , $ sel_cls_time [ 0 ] ) ; $ proxy_cls = array_replace ( $ this -> _classes [ $ rnds [ 0 ] ] , $ clss_swapperA ) ; $ this -> _classes [ $ rnds [ 0 ] ] = $ proxy_cls ; $ proxy_cls = array_replace ( $ this -> _classes [ $ rnds [ 1 ] ] , $ clss_swapperB ) ; $ this -> _classes [ $ rnds [ 1 ] ] = $ proxy_cls ; $ this -> _sched = $ this -> map_class_to_hours ( $ this -> _classes ) ; }
|
| Hour Reselect
|
|       This function takes two scheduled hours in two different classrooms and swaps the courses within these hours.
| | Hour Reselect | | This function takes two scheduled hours in two different classrooms and swaps the courses within these hours .
//while the duration of both classes are not equal			 //Select the lectures within the two selected hours //We are getting duration,since same duration any lecture can be used //Swap the classes between the two selected times //Swap the classes between the two selected times //use array replace fxn to swap lectures at times in array