Page 1 of 1

sugestions to solve a problem

Posted: Sun Sep 12, 2010 4:23 pm
by jhuaraya
hello every body, sorry if a have mistakes with my english, definetly is not my home language, but i will try to explain the more simple as posible. Here is my problem:
I have thousand of students who meed to take an exam they are splited in groups (ie: A=300 students, B=100 students ,C=200 students ). Also i have some classrooms whith its capacity (ie: room1:60, room2:80, room3:40, room4:50, room5:100, room6:70....) the deal is that my php application have to order students in the classrooms.
I was making my code like this:

Code: Select all

$students = array();
$students[0]["Group"] ="A";
$students[0]["students"] =300;
$students[1]["Group"] ="B";
$students[1]["students"] =100;
$students[2]["Group"] ="C";
$students[2]["students"] =200;

$rooms = array();
$rooms[0]['Id']="room_1";
$rooms[0]['Capacity']=60;
$rooms[1]['Id']="room_2";
$rooms[1]['Capacity']=80;
$rooms[2]['Id']="room_3";
$rooms[2]['Capacity']=40;
$rooms[3]['Id']="room_4";
$rooms[3]['Capacity']=50;
$rooms[4]['Id']="room_5";
$rooms[4]['Capacity']=100;
$rooms[5]['Id']="room_6";
$rooms[5]['Capacity']=70;
$rooms[6]['Id']="room_7";
$rooms[6]['Capacity']=70;
$rooms[7]['Id']="room_8";
$rooms[7]['Capacity']=70;
$rooms[8]['Id']="room_9";
$rooms[8]['Capacity']=80;
but I don't know how to do it. I was searching on the internet and i found that i have to use some algorithms like genetic algorithms. is it true? and how can i solve this?.
thanks for your answers

Re: sugestions to solve a problem

Posted: Sun Sep 12, 2010 4:58 pm
by buckit
You need to be much more specific with this part:
my php application have to order students in the classrooms

Re: sugestions to solve a problem

Posted: Sun Sep 12, 2010 5:15 pm
by jhuaraya
buckit wrote:You need to be much more specific with this part:
my php application have to order students in the classrooms
my app has to order students in the classrooms considering the group that they are in, for example if i have:
Group A => 20 students
Group B=>10 Students
Group C=>5 Students
and i have:
classroom 1=> capacity 15 students
classroom 2 =>capacity 5 students
classroom 3 =>capacity 10 students
classroom 4 =>capacity 7 students

my app has to return the ways that i can put the students in the class i.e
Option 1:
Group A => classroom 1 and 2
Group B => classroom 3
Group C => classroom 4
Option 2:
Group A => classroom 1 and 4
Group B => classroom 3
Group C => classroom 2
...

Re: sugestions to solve a problem

Posted: Sun Sep 12, 2010 8:00 pm
by califdon
Hmm, that would be a good assignment or test for someone who is taking a programming class, wouldn't it?

Re: sugestions to solve a problem

Posted: Sun Sep 12, 2010 8:18 pm
by jhuaraya
califdon wrote:Hmm, that would be a good assignment or test for someone who is taking a programming class, wouldn't it?
Yes it would be.

Well i was searching in the internet about something like my problem, i found an important algorithm that is called backtracking, but i can't find some examples in php, can anyone help me with this topic