473,378 Members | 1,571 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Searching

93
I've asked this Q couple of times before but didn't get an answer (Or I didn't get it.). Here goes again. Glad if anyone can help me out.

Well, there are these bunch of school children who want to go to school. They are in different groups, in different places, in different numbers. (i.e one place has 3 children, another 2, another 5, etc.). There is this school bus, which has to drop each and every one of these children at the school. The only trouble is that the fuel consumption of the bus is proportional to the number of children onboard. Come up with the most fuel-efficient way of doing this. For ease we can assume that the bus can only drop children at the school and not anywhere else. Can anyone tell me a way to solve this? Thank you.
Jun 10 '07 #1
10 1704
weaknessforcats
9,208 Expert Mod 8TB
I can provide help with a specific problem but I do not provide solutions.

Read the posting guildelines before making a post.

This forum for C/C++ questions only.

I will move this to the Games and Puzzles forum.
Jun 10 '07 #2
DumRat
93
Yep, I understand that. But I don't want solutions, I only want to find out how to approach the problem so I can make the algorithm myself. A few keywords may even help - I can google them. I'd be really glad if anyone can help. Thanks.
Jun 11 '07 #3
bartonc
6,596 Expert 4TB
Yep, I understand that. But I don't want solutions, I only want to find out how to approach the problem so I can make the algorithm myself. A few keywords may even help - I can google them. I'd be really glad if anyone can help. Thanks.
How 'bout "Genetic Algorithm Tutorial" or some such search keywords?
Jun 11 '07 #4
JosAH
11,448 Expert 8TB
I've asked this Q couple of times before but didn't get an answer (Or I didn't get it.). Here goes again. Glad if anyone can help me out.

Well, there are these bunch of school children who want to go to school. They are in different groups, in different places, in different numbers. (i.e one place has 3 children, another 2, another 5, etc.). There is this school bus, which has to drop each and every one of these children at the school. The only trouble is that the fuel consumption of the bus is proportional to the number of children onboard. Come up with the most fuel-efficient way of doing this. For ease we can assume that the bus can only drop children at the school and not anywhere else. Can anyone tell me a way to solve this? Thank you.
This is a VRP (Vehicle Routing Problem) which is more difficult that a TSP
(Traveling Saleman Problem). If there are not many pick-up locations and not
may delivery locations (schools) the problem boils down to:

1) let p_ij be the pick-up locations for i in [1, n]
2) let d_j be the delivery locations for j in [1,m]

Select the cheapest permutation of of the two sets above such that p_ij < d_j,
i.e. kids are picked up from location p_ij before destination location d_j is
reached. A complete enumeration over all the permutations will find the cheapest
route. Especially the constraint mentioned above will cut deeply into the problem
size. A recursive backtracking algorithm will do if n and m are quite small.

If the capacity of the bus is also limited (which it probably is), that constraint
will even cut more into the size of the problem. If you pick up all or none of the
kids for a certain delivery location you have another cut point.

kind regards,

Jos
Jun 13 '07 #5
Motoma
3,237 Expert 2GB
Great analysis Jos, but with a couple of assumptions (based on how the problem was posed in this thread) it can be greatly simplified.

If we assume that the bus only makes one trip to pick up all students, and that there is ample room on the bus, we can turn the problem into a variation on the Dijkstra's Shortest Path. By running the problem in reverse (starting out with a full bus), and determining the weight of each node by considering the number of students on the bus, you can come to a quicker (albeit less general) solution.
Jun 13 '07 #6
JosAH
11,448 Expert 8TB
Great analysis Jos, but with a couple of assumptions (based on how the problem was posed in this thread) it can be greatly simplified.

If we assume that the bus only makes one trip to pick up all students, and that there is ample room on the bus, we can turn the problem into a variation on the Dijkstra's Shortest Path. By running the problem in reverse (starting out with a full bus), and determining the weight of each node by considering the number of students on the bus, you can come to a quicker (albeit less general) solution.
No you can never reduce it to a simple Dijkstra algorithm with a cost function
that is both depending on the distance traveled plus the number of students on
the bus. (fuel consumption depends on the 'pay' load). And would it be reasonbable
to pick up all the payload first and then deliver everything? I guess not (depending
on the loations of the delivery points).

kind regards,

Jos
Jun 13 '07 #7
Motoma
3,237 Expert 2GB
No you can never reduce it to a simple Dijkstra algorithm with a cost function
that is both depending on the distance traveled plus the number of students on
the bus. (fuel consumption depends on the 'pay' load). And would it be reasonbable
to pick up all the payload first and then deliver everything? I guess not (depending
on the loations of the delivery points).

kind regards,

Jos
I'm going to whip up some code tonight and see if I can work something out :)
Been great discussing this with you Jos, hopefully I will be able to back up my assertions tomorrow :P
Jun 13 '07 #8
JosAH
11,448 Expert 8TB
I'm going to whip up some code tonight and see if I can work something out :)
That's the spirit; I'll keep on nitpicking then just to preserve the 'balance' ok? ;-)

Been great discussing this with you Jos, hopefully I will be able to back up my assertions tomorrow :P
Nice and complicated problems always induce nice and more complicated
discussions. Especially when I'm involved ;-) I wish there were more of those
discussions around.

kind regards,

Jos
Jun 13 '07 #9
Motoma
3,237 Expert 2GB
That's the spirit; I'll keep on nitpicking then just to preserve the 'balance' ok? ;-)



Nice and complicated problems always induce nice and more complicated
discussions. Especially when I'm involved ;-) I wish there were more of those
discussions around.

kind regards,

Jos
Sorry to have questioned you Jos, the restrictions I have placed on this reduce the problem to a Traveling Salesman problem with a weight function. I guess I wasn't thinking it through earlier today.

For some reason I was thinking that by starting at the end of the trip, we could devise a greedy algorithm to assess the depth of the node. I neglected to acknowledge that simply touching each node was not enough; you need to travel through each one to reach the end.
Jun 14 '07 #10
JosAH
11,448 Expert 8TB
Sorry to have questioned you Jos, the restrictions I have placed on this reduce the problem to a Traveling Salesman problem with a weight function. I guess I wasn't thinking it through earlier today.

For some reason I was thinking that by starting at the end of the trip, we could devise a greedy algorithm to assess the depth of the node. I neglected to acknowledge that simply touching each node was not enough; you need to travel through each one to reach the end.
No need to apologize; those VRPs are nasty and tricky. They're indeed similar
to TSPs with a lot of irregular, incoherent constraints. In case of school buses
(or UPS parcel services etc.) there are capacity constraints w.r.t. to the bus or
truck itself (1000 students in a bus?), the order of the p_ij and d_j (a bus won't
drive (in)directly to school d_j when not at least one student p_ij is on the bus).

Additional constraints could be road capacity constraints (a 40 tons truck won't
go well on a dusty or wet dirtroad etc.) My bet for this particular problem would
be to apply a "3-Opt". Start with the following route:

G p_11 p_21 ... p_nm d_1 d_2 ... d_m G

i.e. pick up all the students p_ij and deliver them to the schools d_j. G is the
garage where the bus starts and ends it (circular) trip. Given this circle with
all the nodes; select three edges in the trip and name the trip parts A, B and C.

The entire current trip is ABC, now rearrange it as ACB, (note that the other
four permutations are circular identical to one of the permutations ABC or ACB).

If ACB is a better route, and it is feasible, keep it and try again for all possible
triples of edges. If no better route can be found, stop. Usually this produces
fairly nice routes (read: near optimal) and it's quite fast.

kind regards,

Jos
Jun 14 '07 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: John | last post by:
Hi everyone ! This is a first time I post a message here. If I post my message in a wrong group. Please ignore it. I am trying to build a website which allows users (can be thousands of...
18
by: jblazi | last post by:
I should like to search certain characters in a string and when they are found, I want to replace other characters in other strings that are at the same position (for a very simply mastermind game)...
4
by: tgiles | last post by:
Hi, all. Another bewildered newbie struggling with Python goodness. This time it's searching strings. The goal is to search a string for a value. The string is a variable I assigned the name...
2
by: Kakarot | last post by:
I'm gona be very honest here, I suck at programming, *especially* at C++. It's funny because I actually like the idea of programming ... normally what I like I'm atleast decent at. But C++ is a...
8
by: Gordon Knote | last post by:
Hi can anyone tell me what's the best way to search in binary content? Best if someone could post or link me to some source code (in C/C++). The search should be as fast as possible and it would...
33
by: Geoff Jones | last post by:
Hiya I have a DataTable containing thousands of records. Each record has a primary key field called "ID" and another field called "PRODUCT" I want to retrieve the rows that satisy the following...
5
by: justobservant | last post by:
When more than one keyword is typed into a search-query, most of the search-results displayed indicate specified keywords scattered throughout an entire website of content i.e., this is shown as...
7
by: pbd22 | last post by:
Hi. I am somewhat new to this and would like some advice. I want to search my xml file using "keyword" search and return results based on "proximity matching" - in other words, since the search...
5
by: lemlimlee | last post by:
hello, this is the task i need to do: For this task, you are to develop a Java program that allows a user to search or sort an array of numbers using an algorithm that the user chooses. The...
2
by: Bart Kastermans | last post by:
I have a file in which I am searching for the letter "i" (actually a bit more general than that, arbitrary regular expressions could occur) as long as it does not occur inside an expression that...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.