Jump to content

jyotisi

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Everything posted by jyotisi

  1. I'm getting Undefined variable:get_noofhoursperday on line 77 in action.php file
  2. this is the action.php file in which genetic algorithm is there which should generate the timetable but this code only generates days and subjects in the timetable is not generated.I have also attached the html file first run the tableform.htm and give inputs as no of hours of lecture:6,max lecture per week:8,max lec per day:3 and num of generation:2 <?php //Declaration $TotalRooms=2; $Generation=0; //$lec = array(); //$Rooms = array(); list() = $Rooms ; $LengthOfPool=$TotalRooms*4; $DaysInWeek=6; $count=0; $lec1=array(); list()=$lec1; $get_noofhoursperday=$_POST['noofhoursperday']; $get_maxlectperweek=$_POST['maxlectperweek']; $get_maxlectperday=$_POST['maxlectperday']; $get_genno=$_POST['genno']; echo "NO Of Hours Per Day : ".$get_noofhoursperday."<br>"; echo "Max Lec Per Week : ".$get_maxlectperweek."<br>"; echo "Max Lec PerDay : ".$get_maxlectperday."<br>"; echo " Number Of Gen : ".$get_genno."<br>"; //$p=preg_match('',''); //$p=re.compile(r'\n'); //$p=re.split(r'\n',''); //$p= eval('r',\n'); //file opening $subject = "subjects.txt"; $f = fopen($subject, 'r'); while (!feof($f)) { //echo "asdsd<br>"; //$sub=$p.preg_replace( '','',''); //$sub=$p.preg_replace('','',''); //$sub=p.sub('',a); $sub = fgets($f); $lec1[$count]=$sub; //$TotalLectures=count($lec1); $count=$count+1; //exit(); } /* echo "<pre>"; pr3int_r($lec1); echo "</pre>"; */ Prints(1,2); function Prints ($Room1,$Room2) { $R=array(); array_push($R,$Room1); //$R.($Room1); array_push($R,$Room2); // $R.($Room2); foreach( $R as $eachroom ) { echo (" "); echo (" "); $i= 9; echo " "; echo "<br>"; echo ("Div No : ".$eachroom)."<br>"; echo ("---------------------------------------------------------------------------------------------------------------------------------------"); echo ("<br />"); echo (" Time '\t\t\t\t\t\t\t\t\t' Mon '\t\t\t\t\t' Tue '\t\t\t\t\t' Wed '\t\t\t\t\t\t' Thu '\t\t\t\t\t' Fri '\t\t\t\t\t' Sat '\t\t\t\t\t' "); echo ("<br />"); echo ("--------------------------------------------------------------------------------------------------------------------------------------"); for($h=1;$h<=$get_noofhoursperday;$h++) { if ($i==12) { echo ("Lunch Break"); echo ("<br />"); echo(" "); $i=1; //echo ($i,$i+1); echo "$i $i+1 "; } $i=$i+1; for($d=1; $d<=$DaysInWeek;$d++) { if ($eachroom[$d][$h]==0) echo(" "); for($l=0;$l<=$lec1;$l++) { if ($l[1]==$eachroom[$d][$h]) echo ($l[0]); } } } } } function CreatePool($Rooms,$LengthOfPool) { for ($no=1;$no<=$LengthOfPool;$no++) { // Original $room=[[0]* $get_noofhoursperday for($i=1; $i<=$DaysInWeek;$i++)]; for($i=1; $i<=$DaysInWeek;$i++) $room[]= ($get_noofhoursperday*$i); $a=array(); foreach($a as $b) $room=$get_noofhoursperday*$b; $Rooms.append($room); foreach($room as $Rooms) { for($d=1;$d<=$DaysInweek;$d++) { for($h=1;$h<= $get_noofhoursperday;$h++) $room[$d][$h]=rand(1,$TotalLectures); } } } return $Rooms; } function BreedNew($Rooms) { // $room=[[0]*$HoursInDay for( $i=1;$i<=$DaysInWeek;$i++)]; for( $i=1;$i<=$DaysInWeek;$i++) $room[]= ($HoursInDay*$i); for($d=1;$d<=$DaysInWeek;$d++) { for( $h=1; $h<= $get_noofhoursperday;$h++) { $room[$d][$h]=rand(1,$TotalLectures); $Rooms.append($room); } } } function FitnessOfRoom($Rooms) { global $Generation; $Generation=$Generation+1; echo( "Generation no = " +strval($Generation)); foreach($room as $Rooms) { $RoomFit=100; for($d=1;$d<=$DaysInWeek;$d++) { for($h=1;$h<=$get_noofhoursperday;$h++) { if ($room[$d].count($room[$d][$h])>$get_maxlectperday) { $RoomFit=$RoomFit-5; break; } if($RoomFit!=100) { $Rooms.remove($room); BreedNew($Rooms); } } } } return $Rooms; } function CrossOver($Roooms) { global $Generation; $Generation=$Generation+1; //echo ("Generation no = " +str($Generation)); echo ("Generation no = " +strval($Generation)); $CRate=(int)(count($Rooms)/2); // in php count is used $CRate=(int)(count($Rooms)/2); $Cpoint=(int)($DaysInWeek/2 ); $MRate=10; for($i=0;$i<=$CRate;$i++) { $a=rand(0,count($Rooms)-1); $b=rand(0,count($Rooms)-1); while( $a==$b) { $b=rand(0,count($Rooms)-1); $father=$Rooms[$a]; $mother=$Rooms[$b]; $child=array(); $Rooms.remove($father); $Rooms.remove($mother); $child.extend($father[$Cpoint]); $child.extend($mother[$Cpoint]); $Rooms.append($child); while(count($Rooms<$LengthOfPool)) { BreedNew($Rooms); if(rand(1,200)>$MRate) Mutate(); } } } } function Mutate() { global $Rooms; $randroom=rand(0,count($Rooms)-1); $randday=rand(0,$DaysInWeek-1); $randhour=rand(0, $get_noofhoursperday-1); $Rooms[$randroom][$randday][$randhour]=rand(1,$TotalLectures); } function LecturesPerDayAndWeek($Room1,$Room2) { $R=array(); $R.append($Room1); $R.append($Room2); for($i=1;$i<=count($R);$i++) { for($val=1;$val<=$TotalLectures+1;$i++) { $WeekOccured=0; for($d=1;$d<=$DaysInWeek;$d++) { $occurred=0; for($h=1; $h<=$HoursInDay;$h++) { if ($Rooms[$i][$d][$h]==$val) { $occurred=$occurred+1; $WeekOccured=$WeekOccured+1; if( $occurred >$get_maxlectperday) return true; } if ($WeekOccured >$get_maxlectperweek) return true; } } } } return false; } function ClashOfRooms($Rooms) { for($i=1; $i<=count($Rooms)-1;$i++) { $p=$i+1; while ($p!=count($Rooms)) { $clash=false; for($d=1;$d<=$DaysInWeek;$i++) { for($h=1;$h<=$HoursInDay;$h++) { if ($Rooms[$i][$d][$h]==$Rooms[$p][$d][$h]) $clash=true; break; if ($clash==true) break; if ($clash==false) { if (LecturesPerDayAndWeek($Rooms[$i][$p])==0) echo $Rooms[$i],$Rooms[$p]; return false; } } $p=$p+1; CrossOver($Rooms); } } } return true; } function Fitness($Rooms) { $Rooms=FitnessOfRoom($Rooms); if(ClashOfRooms($Rooms)==0) return false; else return true; $Rooms=CreatePool($Rooms,$LengthOfPool); $RET=true; while($RET==true) { if(Fitness($Rooms)==0) $RET=false; echo(" "); echo(" "); } } ?> this is tableform.htm file save it as table.htm and run it put inputs:no of hours of lecture:6,max lecture per week:8,max lec per day:3 and num of generation:2 <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Teacher TimeTable</title> <style type="text/css"> legend { color:#0000E1 } </style> <script type="text/javascript"> function ValidateContactForm() { var nohpd=document.ContactForm.noofhoursperday; var mlpw=document.ContactForm.maxlectperweek; var mlpd=document.ContactForm.maxlectperday; var gno=document.ContactForm.genno; //alert(nohpd.value); //alert(mlpw.value); //alert(mlpd.value); //alert(gno.value); if(nohpd.value=="") { alert("Please enter no.of hours per day"); //document.forms[0].noofhoursperday.focus(); nohpd.focus(); return false; } if(mlpw.value=="") { alert("Please enter the maximum lecture per week"); //document.forms[0].focus(); mlpw.focus(); return false; } if(mlpd.value=="") { alert("Please enter Maximum lecure per day"); //document.forms[0].focus(); mlpd.focus(); return false; } if(gno.value=="") { alert("Please enter number of Generation"); //document.forms[0].focus(); gno.focus(); return false; } return true; } </script> </head> <body> <form method="post" name="ContactForm" onSubmit="return ValidateContactForm();" action = "actionform.php"> <table width="60%" border="0" align="center" style="background-color:#CCCCCC; border:none"> <tr> <td><fieldset> <legend>TimeTable</legend> <table width="461" height="200" border="0" align="center"> <tr> <td width="151">No. of Hours Per Day</td> <td width="10"> </td> <td width="278"><input name="noofhoursperday" type="text" size="30" value= "" /></td> </tr> <tr> <td>Maximum Lect Per Week</td> <td> </td> <td><input name="maxlectperweek" type="text" size="30" id="maxlectperweek" value= "" /> </td> </tr> <tr> <td>Max Lect per Day </td> <td> </td> <td><input name="maxlectperday" type="text" size="30" id="maxlectperday" value= "" /> </td> </tr> <tr> <td>No. Of Generation</td> <td> </td> <td><input name="genno" type="text" size="30" id="genno" value= "" /> </td> </tr> <tr> <td><div align="center"> <input name="submit" type="submit" value="TimeTable" /> </div> </td> <td><input name="reset" type="reset" value="Reset"></td> </tr> </table> </form> </body> </html>
  3. I'm in MSc IT and I'm doing project on timetable scheduling using genetic algorithm as my final year project. I have developed the code for it but the problem is timetable is not getting displayed. Please help. Urgent [attachment deleted by admin]
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.