Algorithm

Started by Nagendra, June 16, 2019, 05:51:02 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Nagendra

I want to divide a data set into four groups such that the sum of elements of each group is approximately same.
for eg: [10, 5, 1, 20, 5, 22, 4, 15]
For the above data set: sum of all the elements = 82
So, I want this data set to be divided into 4 groups such that, the sum of elements of each group is almost same.
One such possibility is
Set 1: 10, 5, 4,1
Set 2: 20
Set 3: 22
Set 4: 15,5
How do I set up this?

An algorithm, C or MATLAB program is highly appreciated

Volker Dirr

#1
What is the application for this in real life? (This also might anwser partly the following questions and or give some more limits)
What do you think how many items and sets will you have?
Do you need the "best" solution or can you set a limit for an acceptable solution?

I guess:
- the number of items and sets is fixed before calculation.
- all items must be used

You need to think about how to calculate "approximately same".
I suggest to calculate the "average" and "min/max span/value" before starting the algorithm. I guess that will simplify and speed up any algorithm. So don't calculate that "on the fly" because of "difficult" span calculation (like quadratic span from average or similar stuff).

The second step will be thinking about the algorithm itself.  If the number is low, you might just try brute force with something like alpha-beta-pruning.

Nagendra

Application is to decide the seating style of students during exams.
Suppose, if FET provides an exam timetable in such a way that there are 8 subjects scheduled in Day-1_Slot-1.

Now all the students of these subjects are to be alloted seats in rooms. Any subject is allowed to take any seating style from the below.
1) Odd rows odd columns
2) Even Rows వద్ద Columns
3) Odd  rows even columns
4) Even rows even columns

Consider I have Four rooms, with seating capacity of 25 each.
One solution is

OROC: 10, 5, 4,1 (subjects with these number of) students
EROC: 20
OREC: 22
EREC: 15,5

If I can generate this combination, then I simply feed it to my seating plan generator to generate seating plan. Otherwise, I have to manually identify a possible seating style for each subject  :(

Volker Dirr

hmm. ok. In my opinion in that case "approximately same" is not "good".

why:
because rooms can have different capacities
a max for each room is needed, while a min is not critical. Caring about students with the same subject is (maybe?!) much more needed then caring about a min value or "approximately same".
i even guess a greedy algorithm might work pretty fine here as long as you fill rooms up to the max  and most groups will be normally pretty large.