Optimizing a Parking Lot Problem. What algorithms should I use to fit the most amount of cars in the lot?
up vote
6
down vote
favorite
What algorithms (brute force or not) would I use to put in as many cars (assume all cars are the same size) in a parking lot so that there is at least one exit (from the container) and a car cannot be blocked. Or can someone show me an example of this problem solved programmatically.
The parking lot varies in shape would be nice but if you want to assume it's some invariant shape that is fine.
Another Edit:
Assume that driving distance in the parking lot is not a factor (although it would be totally awesome if it was weighted factor to number of cars in lot).
Another Edit:
Assume 2 Dimensional (no cranes or driving over cars).
Another Edit:
You cannot move cars around once they are parked (it's not a valet parking lot).
algorithm machine-learning np-complete
|
show 15 more comments
up vote
6
down vote
favorite
What algorithms (brute force or not) would I use to put in as many cars (assume all cars are the same size) in a parking lot so that there is at least one exit (from the container) and a car cannot be blocked. Or can someone show me an example of this problem solved programmatically.
The parking lot varies in shape would be nice but if you want to assume it's some invariant shape that is fine.
Another Edit:
Assume that driving distance in the parking lot is not a factor (although it would be totally awesome if it was weighted factor to number of cars in lot).
Another Edit:
Assume 2 Dimensional (no cranes or driving over cars).
Another Edit:
You cannot move cars around once they are parked (it's not a valet parking lot).
algorithm machine-learning np-complete
1
What do you mean "organize a parking lot"? Optimize the choice of space each car parks in? Optimize the physical layout of the parking lot? What are your constraints--are all cars the same size? What geometry are we working with? I think you're getting ahead of yourself; you didn't give much detail about the problem you're trying to solve!
– John Kugelman
May 13 '10 at 17:43
1
I have voted to close. Reason: too vague. Please edit to add more specifics.
– Aryabhatta
May 13 '10 at 17:43
1
I didn't vote to close, but to be honest I'm not sure I understand what the OP wants. What exactly is a parking lot and what exactly is a car in a programming context? What is an exit? Can you post an example? Also, much clearer questions have been closed before. Just saying.
– IVlad
May 13 '10 at 19:03
1
@Shaggy Frog: Consider a parking lot that looks like this, only longer:_ | | _
, where cars can only be placed on a_
facing a|
. It's pretty obvious what the solution is in this case, so I'm honestly not sure what the OP is after as long as he says "the shape can change, but only if you want it to". Well, I want it to always be that shape so the problem is trivial. I just don't really see what his question is. When you say "parking lot", I think of real life parking lots, for which a greedy algorithm will find the optimal solution easily. Use programming terms to make this less vague.
– IVlad
May 13 '10 at 19:44
1
Talking about NP-Completeness for an open-ended question like this is complete nonsense. For instance, I will have a parking lot with a crane attached. It will just pick up the cars and put them out. Completely full. Or use a tunnel as a queue, and if we need the 10th car, drive the first 9 out, and put them back in by driving on the roof of the tunnel. Again completely full. 'Polynomial' time algorithms to put and take out the cars. I guess I will take ShaggyFrog's suggestion and move on.
– Aryabhatta
May 13 '10 at 20:28
|
show 15 more comments
up vote
6
down vote
favorite
up vote
6
down vote
favorite
What algorithms (brute force or not) would I use to put in as many cars (assume all cars are the same size) in a parking lot so that there is at least one exit (from the container) and a car cannot be blocked. Or can someone show me an example of this problem solved programmatically.
The parking lot varies in shape would be nice but if you want to assume it's some invariant shape that is fine.
Another Edit:
Assume that driving distance in the parking lot is not a factor (although it would be totally awesome if it was weighted factor to number of cars in lot).
Another Edit:
Assume 2 Dimensional (no cranes or driving over cars).
Another Edit:
You cannot move cars around once they are parked (it's not a valet parking lot).
algorithm machine-learning np-complete
What algorithms (brute force or not) would I use to put in as many cars (assume all cars are the same size) in a parking lot so that there is at least one exit (from the container) and a car cannot be blocked. Or can someone show me an example of this problem solved programmatically.
The parking lot varies in shape would be nice but if you want to assume it's some invariant shape that is fine.
Another Edit:
Assume that driving distance in the parking lot is not a factor (although it would be totally awesome if it was weighted factor to number of cars in lot).
Another Edit:
Assume 2 Dimensional (no cranes or driving over cars).
Another Edit:
You cannot move cars around once they are parked (it's not a valet parking lot).
algorithm machine-learning np-complete
algorithm machine-learning np-complete
edited Nov 9 at 16:14
Cœur
17k9102140
17k9102140
asked May 13 '10 at 17:38
Adam Gent
33.8k19122165
33.8k19122165
1
What do you mean "organize a parking lot"? Optimize the choice of space each car parks in? Optimize the physical layout of the parking lot? What are your constraints--are all cars the same size? What geometry are we working with? I think you're getting ahead of yourself; you didn't give much detail about the problem you're trying to solve!
– John Kugelman
May 13 '10 at 17:43
1
I have voted to close. Reason: too vague. Please edit to add more specifics.
– Aryabhatta
May 13 '10 at 17:43
1
I didn't vote to close, but to be honest I'm not sure I understand what the OP wants. What exactly is a parking lot and what exactly is a car in a programming context? What is an exit? Can you post an example? Also, much clearer questions have been closed before. Just saying.
– IVlad
May 13 '10 at 19:03
1
@Shaggy Frog: Consider a parking lot that looks like this, only longer:_ | | _
, where cars can only be placed on a_
facing a|
. It's pretty obvious what the solution is in this case, so I'm honestly not sure what the OP is after as long as he says "the shape can change, but only if you want it to". Well, I want it to always be that shape so the problem is trivial. I just don't really see what his question is. When you say "parking lot", I think of real life parking lots, for which a greedy algorithm will find the optimal solution easily. Use programming terms to make this less vague.
– IVlad
May 13 '10 at 19:44
1
Talking about NP-Completeness for an open-ended question like this is complete nonsense. For instance, I will have a parking lot with a crane attached. It will just pick up the cars and put them out. Completely full. Or use a tunnel as a queue, and if we need the 10th car, drive the first 9 out, and put them back in by driving on the roof of the tunnel. Again completely full. 'Polynomial' time algorithms to put and take out the cars. I guess I will take ShaggyFrog's suggestion and move on.
– Aryabhatta
May 13 '10 at 20:28
|
show 15 more comments
1
What do you mean "organize a parking lot"? Optimize the choice of space each car parks in? Optimize the physical layout of the parking lot? What are your constraints--are all cars the same size? What geometry are we working with? I think you're getting ahead of yourself; you didn't give much detail about the problem you're trying to solve!
– John Kugelman
May 13 '10 at 17:43
1
I have voted to close. Reason: too vague. Please edit to add more specifics.
– Aryabhatta
May 13 '10 at 17:43
1
I didn't vote to close, but to be honest I'm not sure I understand what the OP wants. What exactly is a parking lot and what exactly is a car in a programming context? What is an exit? Can you post an example? Also, much clearer questions have been closed before. Just saying.
– IVlad
May 13 '10 at 19:03
1
@Shaggy Frog: Consider a parking lot that looks like this, only longer:_ | | _
, where cars can only be placed on a_
facing a|
. It's pretty obvious what the solution is in this case, so I'm honestly not sure what the OP is after as long as he says "the shape can change, but only if you want it to". Well, I want it to always be that shape so the problem is trivial. I just don't really see what his question is. When you say "parking lot", I think of real life parking lots, for which a greedy algorithm will find the optimal solution easily. Use programming terms to make this less vague.
– IVlad
May 13 '10 at 19:44
1
Talking about NP-Completeness for an open-ended question like this is complete nonsense. For instance, I will have a parking lot with a crane attached. It will just pick up the cars and put them out. Completely full. Or use a tunnel as a queue, and if we need the 10th car, drive the first 9 out, and put them back in by driving on the roof of the tunnel. Again completely full. 'Polynomial' time algorithms to put and take out the cars. I guess I will take ShaggyFrog's suggestion and move on.
– Aryabhatta
May 13 '10 at 20:28
1
1
What do you mean "organize a parking lot"? Optimize the choice of space each car parks in? Optimize the physical layout of the parking lot? What are your constraints--are all cars the same size? What geometry are we working with? I think you're getting ahead of yourself; you didn't give much detail about the problem you're trying to solve!
– John Kugelman
May 13 '10 at 17:43
What do you mean "organize a parking lot"? Optimize the choice of space each car parks in? Optimize the physical layout of the parking lot? What are your constraints--are all cars the same size? What geometry are we working with? I think you're getting ahead of yourself; you didn't give much detail about the problem you're trying to solve!
– John Kugelman
May 13 '10 at 17:43
1
1
I have voted to close. Reason: too vague. Please edit to add more specifics.
– Aryabhatta
May 13 '10 at 17:43
I have voted to close. Reason: too vague. Please edit to add more specifics.
– Aryabhatta
May 13 '10 at 17:43
1
1
I didn't vote to close, but to be honest I'm not sure I understand what the OP wants. What exactly is a parking lot and what exactly is a car in a programming context? What is an exit? Can you post an example? Also, much clearer questions have been closed before. Just saying.
– IVlad
May 13 '10 at 19:03
I didn't vote to close, but to be honest I'm not sure I understand what the OP wants. What exactly is a parking lot and what exactly is a car in a programming context? What is an exit? Can you post an example? Also, much clearer questions have been closed before. Just saying.
– IVlad
May 13 '10 at 19:03
1
1
@Shaggy Frog: Consider a parking lot that looks like this, only longer:
_ | | _
, where cars can only be placed on a _
facing a |
. It's pretty obvious what the solution is in this case, so I'm honestly not sure what the OP is after as long as he says "the shape can change, but only if you want it to". Well, I want it to always be that shape so the problem is trivial. I just don't really see what his question is. When you say "parking lot", I think of real life parking lots, for which a greedy algorithm will find the optimal solution easily. Use programming terms to make this less vague.– IVlad
May 13 '10 at 19:44
@Shaggy Frog: Consider a parking lot that looks like this, only longer:
_ | | _
, where cars can only be placed on a _
facing a |
. It's pretty obvious what the solution is in this case, so I'm honestly not sure what the OP is after as long as he says "the shape can change, but only if you want it to". Well, I want it to always be that shape so the problem is trivial. I just don't really see what his question is. When you say "parking lot", I think of real life parking lots, for which a greedy algorithm will find the optimal solution easily. Use programming terms to make this less vague.– IVlad
May 13 '10 at 19:44
1
1
Talking about NP-Completeness for an open-ended question like this is complete nonsense. For instance, I will have a parking lot with a crane attached. It will just pick up the cars and put them out. Completely full. Or use a tunnel as a queue, and if we need the 10th car, drive the first 9 out, and put them back in by driving on the roof of the tunnel. Again completely full. 'Polynomial' time algorithms to put and take out the cars. I guess I will take ShaggyFrog's suggestion and move on.
– Aryabhatta
May 13 '10 at 20:28
Talking about NP-Completeness for an open-ended question like this is complete nonsense. For instance, I will have a parking lot with a crane attached. It will just pick up the cars and put them out. Completely full. Or use a tunnel as a queue, and if we need the 10th car, drive the first 9 out, and put them back in by driving on the roof of the tunnel. Again completely full. 'Polynomial' time algorithms to put and take out the cars. I guess I will take ShaggyFrog's suggestion and move on.
– Aryabhatta
May 13 '10 at 20:28
|
show 15 more comments
4 Answers
4
active
oldest
votes
up vote
5
down vote
accepted
Well, let's simplify/concreteify a bit. Assume that our cars are unit squares, the parking lot is N x N, and we need to enter/exit from the lower left corner. A simple pattern gets the lot almost 2/3 full with cars (shown for N=12):
+------------+
|C CC CC CC C|
|C CC CC CC C|
|C CC CC CC C|
|C CC CC CC C|
|C CC CC CC C|
|C CC CC CC C|
|C CC CC CC C|
|C CC CC CC C|
|C CC CC CC C|
|C CC CC CC C|
|C CC CC CC C|
|
-----------+
I can prove that the best you can possibly do is to get the lot 2/3 full. Imagine that you build up the empty spaces by starting with a completely full garage and driving out a (currently reachable) car one at a time. Each time you remove a car, you produce up to 3 newly reachable cars, and remove one once-reachable car (now an empty space). So for every space you make, you create at most 2 more reachable cars. To make 2/3 N^2 reachable cars, you need to make at least 1/3 N^2 spaces, and that's all the squares you have. So you can fill the garage at most 2/3 full.
The simple pattern above is asymptotically optimal, as its density approaches 2/3 as N -> infinity. (Kinda boring, I was hoping some tree-looking pattern would do better.)
Excellent solution. Thanks!
– Divye Kapoor
May 8 '17 at 0:48
add a comment |
up vote
1
down vote
This is basically equivalent to bin-packing, with the added requirement that an exit be in a particular place and all the cars can exit -- which is itself a hard problem!
So your problem is at least NP-hard.
Exactly. It was the point I was trying to make in the question is that while it may be NP-Hard to pack him in its also hard to figure out how there exit path.
– Adam Gent
May 13 '10 at 18:24
Figuring out the sequence of moves to get all the cars out is the basis behind the game Rush Hour. I wrote a program to "solve" Rush Hour puzzles back in university for a course. It's actually a more complex version of a sliding-tile game, and those (I believe) are NP-Complete.
– Shaggy Frog
May 13 '10 at 18:56
add a comment |
up vote
0
down vote
Is your definition of efficiency the greatest number of parking spots in a lot of a given size and shape (assuming that each car can be driven away without moving any other car)? If so, it is a packing problem, not a knapsack problem, and it sounds NP to me, but the range of solutions for any real-world lot being so small it could be solved with an practical exhaustive search.
Yes and No because you also have to figure out the exit strategy of each car. And as bonus keeping the distance down would be nice also but you would have to weight that in some how.
– Adam Gent
May 13 '10 at 18:31
An "exhaustive search" of either a bin packing problem OR the "Rush Hour" type puzzle is not practically done with an "exhaustive search". They are difficult problems to solve.
– Shaggy Frog
May 13 '10 at 19:54
add a comment |
up vote
0
down vote
I think it may be technically NP complete. But I think that you could develop an intelligent set of solutions, each one building off of the experience with the last, and algorithmically choose a best solution from the calculated set. You may not be able to prove it is the best possible solution. But from a practical standpoint, you have an optimized parking lot, so does it really matter that given an infinite amount of time you would have squeezed 3 more cars in there?
+1 NP complete doesn't mean impossible. For small parking lots, you could search the entire space. For large lots, "good enough" is often so close to optimal in practice that it doesn't matter.
– Yann Ramin
May 13 '10 at 18:01
It is indeed possible to come up with a provably optimal solution for both the bin-packing component, as well as the get-the-cars-out component.
– Shaggy Frog
May 13 '10 at 19:56
add a comment |
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
5
down vote
accepted
Well, let's simplify/concreteify a bit. Assume that our cars are unit squares, the parking lot is N x N, and we need to enter/exit from the lower left corner. A simple pattern gets the lot almost 2/3 full with cars (shown for N=12):
+------------+
|C CC CC CC C|
|C CC CC CC C|
|C CC CC CC C|
|C CC CC CC C|
|C CC CC CC C|
|C CC CC CC C|
|C CC CC CC C|
|C CC CC CC C|
|C CC CC CC C|
|C CC CC CC C|
|C CC CC CC C|
|
-----------+
I can prove that the best you can possibly do is to get the lot 2/3 full. Imagine that you build up the empty spaces by starting with a completely full garage and driving out a (currently reachable) car one at a time. Each time you remove a car, you produce up to 3 newly reachable cars, and remove one once-reachable car (now an empty space). So for every space you make, you create at most 2 more reachable cars. To make 2/3 N^2 reachable cars, you need to make at least 1/3 N^2 spaces, and that's all the squares you have. So you can fill the garage at most 2/3 full.
The simple pattern above is asymptotically optimal, as its density approaches 2/3 as N -> infinity. (Kinda boring, I was hoping some tree-looking pattern would do better.)
Excellent solution. Thanks!
– Divye Kapoor
May 8 '17 at 0:48
add a comment |
up vote
5
down vote
accepted
Well, let's simplify/concreteify a bit. Assume that our cars are unit squares, the parking lot is N x N, and we need to enter/exit from the lower left corner. A simple pattern gets the lot almost 2/3 full with cars (shown for N=12):
+------------+
|C CC CC CC C|
|C CC CC CC C|
|C CC CC CC C|
|C CC CC CC C|
|C CC CC CC C|
|C CC CC CC C|
|C CC CC CC C|
|C CC CC CC C|
|C CC CC CC C|
|C CC CC CC C|
|C CC CC CC C|
|
-----------+
I can prove that the best you can possibly do is to get the lot 2/3 full. Imagine that you build up the empty spaces by starting with a completely full garage and driving out a (currently reachable) car one at a time. Each time you remove a car, you produce up to 3 newly reachable cars, and remove one once-reachable car (now an empty space). So for every space you make, you create at most 2 more reachable cars. To make 2/3 N^2 reachable cars, you need to make at least 1/3 N^2 spaces, and that's all the squares you have. So you can fill the garage at most 2/3 full.
The simple pattern above is asymptotically optimal, as its density approaches 2/3 as N -> infinity. (Kinda boring, I was hoping some tree-looking pattern would do better.)
Excellent solution. Thanks!
– Divye Kapoor
May 8 '17 at 0:48
add a comment |
up vote
5
down vote
accepted
up vote
5
down vote
accepted
Well, let's simplify/concreteify a bit. Assume that our cars are unit squares, the parking lot is N x N, and we need to enter/exit from the lower left corner. A simple pattern gets the lot almost 2/3 full with cars (shown for N=12):
+------------+
|C CC CC CC C|
|C CC CC CC C|
|C CC CC CC C|
|C CC CC CC C|
|C CC CC CC C|
|C CC CC CC C|
|C CC CC CC C|
|C CC CC CC C|
|C CC CC CC C|
|C CC CC CC C|
|C CC CC CC C|
|
-----------+
I can prove that the best you can possibly do is to get the lot 2/3 full. Imagine that you build up the empty spaces by starting with a completely full garage and driving out a (currently reachable) car one at a time. Each time you remove a car, you produce up to 3 newly reachable cars, and remove one once-reachable car (now an empty space). So for every space you make, you create at most 2 more reachable cars. To make 2/3 N^2 reachable cars, you need to make at least 1/3 N^2 spaces, and that's all the squares you have. So you can fill the garage at most 2/3 full.
The simple pattern above is asymptotically optimal, as its density approaches 2/3 as N -> infinity. (Kinda boring, I was hoping some tree-looking pattern would do better.)
Well, let's simplify/concreteify a bit. Assume that our cars are unit squares, the parking lot is N x N, and we need to enter/exit from the lower left corner. A simple pattern gets the lot almost 2/3 full with cars (shown for N=12):
+------------+
|C CC CC CC C|
|C CC CC CC C|
|C CC CC CC C|
|C CC CC CC C|
|C CC CC CC C|
|C CC CC CC C|
|C CC CC CC C|
|C CC CC CC C|
|C CC CC CC C|
|C CC CC CC C|
|C CC CC CC C|
|
-----------+
I can prove that the best you can possibly do is to get the lot 2/3 full. Imagine that you build up the empty spaces by starting with a completely full garage and driving out a (currently reachable) car one at a time. Each time you remove a car, you produce up to 3 newly reachable cars, and remove one once-reachable car (now an empty space). So for every space you make, you create at most 2 more reachable cars. To make 2/3 N^2 reachable cars, you need to make at least 1/3 N^2 spaces, and that's all the squares you have. So you can fill the garage at most 2/3 full.
The simple pattern above is asymptotically optimal, as its density approaches 2/3 as N -> infinity. (Kinda boring, I was hoping some tree-looking pattern would do better.)
answered May 15 '10 at 5:46
Keith Randall
21.2k12747
21.2k12747
Excellent solution. Thanks!
– Divye Kapoor
May 8 '17 at 0:48
add a comment |
Excellent solution. Thanks!
– Divye Kapoor
May 8 '17 at 0:48
Excellent solution. Thanks!
– Divye Kapoor
May 8 '17 at 0:48
Excellent solution. Thanks!
– Divye Kapoor
May 8 '17 at 0:48
add a comment |
up vote
1
down vote
This is basically equivalent to bin-packing, with the added requirement that an exit be in a particular place and all the cars can exit -- which is itself a hard problem!
So your problem is at least NP-hard.
Exactly. It was the point I was trying to make in the question is that while it may be NP-Hard to pack him in its also hard to figure out how there exit path.
– Adam Gent
May 13 '10 at 18:24
Figuring out the sequence of moves to get all the cars out is the basis behind the game Rush Hour. I wrote a program to "solve" Rush Hour puzzles back in university for a course. It's actually a more complex version of a sliding-tile game, and those (I believe) are NP-Complete.
– Shaggy Frog
May 13 '10 at 18:56
add a comment |
up vote
1
down vote
This is basically equivalent to bin-packing, with the added requirement that an exit be in a particular place and all the cars can exit -- which is itself a hard problem!
So your problem is at least NP-hard.
Exactly. It was the point I was trying to make in the question is that while it may be NP-Hard to pack him in its also hard to figure out how there exit path.
– Adam Gent
May 13 '10 at 18:24
Figuring out the sequence of moves to get all the cars out is the basis behind the game Rush Hour. I wrote a program to "solve" Rush Hour puzzles back in university for a course. It's actually a more complex version of a sliding-tile game, and those (I believe) are NP-Complete.
– Shaggy Frog
May 13 '10 at 18:56
add a comment |
up vote
1
down vote
up vote
1
down vote
This is basically equivalent to bin-packing, with the added requirement that an exit be in a particular place and all the cars can exit -- which is itself a hard problem!
So your problem is at least NP-hard.
This is basically equivalent to bin-packing, with the added requirement that an exit be in a particular place and all the cars can exit -- which is itself a hard problem!
So your problem is at least NP-hard.
answered May 13 '10 at 18:17
Shaggy Frog
24.3k1576126
24.3k1576126
Exactly. It was the point I was trying to make in the question is that while it may be NP-Hard to pack him in its also hard to figure out how there exit path.
– Adam Gent
May 13 '10 at 18:24
Figuring out the sequence of moves to get all the cars out is the basis behind the game Rush Hour. I wrote a program to "solve" Rush Hour puzzles back in university for a course. It's actually a more complex version of a sliding-tile game, and those (I believe) are NP-Complete.
– Shaggy Frog
May 13 '10 at 18:56
add a comment |
Exactly. It was the point I was trying to make in the question is that while it may be NP-Hard to pack him in its also hard to figure out how there exit path.
– Adam Gent
May 13 '10 at 18:24
Figuring out the sequence of moves to get all the cars out is the basis behind the game Rush Hour. I wrote a program to "solve" Rush Hour puzzles back in university for a course. It's actually a more complex version of a sliding-tile game, and those (I believe) are NP-Complete.
– Shaggy Frog
May 13 '10 at 18:56
Exactly. It was the point I was trying to make in the question is that while it may be NP-Hard to pack him in its also hard to figure out how there exit path.
– Adam Gent
May 13 '10 at 18:24
Exactly. It was the point I was trying to make in the question is that while it may be NP-Hard to pack him in its also hard to figure out how there exit path.
– Adam Gent
May 13 '10 at 18:24
Figuring out the sequence of moves to get all the cars out is the basis behind the game Rush Hour. I wrote a program to "solve" Rush Hour puzzles back in university for a course. It's actually a more complex version of a sliding-tile game, and those (I believe) are NP-Complete.
– Shaggy Frog
May 13 '10 at 18:56
Figuring out the sequence of moves to get all the cars out is the basis behind the game Rush Hour. I wrote a program to "solve" Rush Hour puzzles back in university for a course. It's actually a more complex version of a sliding-tile game, and those (I believe) are NP-Complete.
– Shaggy Frog
May 13 '10 at 18:56
add a comment |
up vote
0
down vote
Is your definition of efficiency the greatest number of parking spots in a lot of a given size and shape (assuming that each car can be driven away without moving any other car)? If so, it is a packing problem, not a knapsack problem, and it sounds NP to me, but the range of solutions for any real-world lot being so small it could be solved with an practical exhaustive search.
Yes and No because you also have to figure out the exit strategy of each car. And as bonus keeping the distance down would be nice also but you would have to weight that in some how.
– Adam Gent
May 13 '10 at 18:31
An "exhaustive search" of either a bin packing problem OR the "Rush Hour" type puzzle is not practically done with an "exhaustive search". They are difficult problems to solve.
– Shaggy Frog
May 13 '10 at 19:54
add a comment |
up vote
0
down vote
Is your definition of efficiency the greatest number of parking spots in a lot of a given size and shape (assuming that each car can be driven away without moving any other car)? If so, it is a packing problem, not a knapsack problem, and it sounds NP to me, but the range of solutions for any real-world lot being so small it could be solved with an practical exhaustive search.
Yes and No because you also have to figure out the exit strategy of each car. And as bonus keeping the distance down would be nice also but you would have to weight that in some how.
– Adam Gent
May 13 '10 at 18:31
An "exhaustive search" of either a bin packing problem OR the "Rush Hour" type puzzle is not practically done with an "exhaustive search". They are difficult problems to solve.
– Shaggy Frog
May 13 '10 at 19:54
add a comment |
up vote
0
down vote
up vote
0
down vote
Is your definition of efficiency the greatest number of parking spots in a lot of a given size and shape (assuming that each car can be driven away without moving any other car)? If so, it is a packing problem, not a knapsack problem, and it sounds NP to me, but the range of solutions for any real-world lot being so small it could be solved with an practical exhaustive search.
Is your definition of efficiency the greatest number of parking spots in a lot of a given size and shape (assuming that each car can be driven away without moving any other car)? If so, it is a packing problem, not a knapsack problem, and it sounds NP to me, but the range of solutions for any real-world lot being so small it could be solved with an practical exhaustive search.
answered May 13 '10 at 17:46
Malvolio
24.1k2179107
24.1k2179107
Yes and No because you also have to figure out the exit strategy of each car. And as bonus keeping the distance down would be nice also but you would have to weight that in some how.
– Adam Gent
May 13 '10 at 18:31
An "exhaustive search" of either a bin packing problem OR the "Rush Hour" type puzzle is not practically done with an "exhaustive search". They are difficult problems to solve.
– Shaggy Frog
May 13 '10 at 19:54
add a comment |
Yes and No because you also have to figure out the exit strategy of each car. And as bonus keeping the distance down would be nice also but you would have to weight that in some how.
– Adam Gent
May 13 '10 at 18:31
An "exhaustive search" of either a bin packing problem OR the "Rush Hour" type puzzle is not practically done with an "exhaustive search". They are difficult problems to solve.
– Shaggy Frog
May 13 '10 at 19:54
Yes and No because you also have to figure out the exit strategy of each car. And as bonus keeping the distance down would be nice also but you would have to weight that in some how.
– Adam Gent
May 13 '10 at 18:31
Yes and No because you also have to figure out the exit strategy of each car. And as bonus keeping the distance down would be nice also but you would have to weight that in some how.
– Adam Gent
May 13 '10 at 18:31
An "exhaustive search" of either a bin packing problem OR the "Rush Hour" type puzzle is not practically done with an "exhaustive search". They are difficult problems to solve.
– Shaggy Frog
May 13 '10 at 19:54
An "exhaustive search" of either a bin packing problem OR the "Rush Hour" type puzzle is not practically done with an "exhaustive search". They are difficult problems to solve.
– Shaggy Frog
May 13 '10 at 19:54
add a comment |
up vote
0
down vote
I think it may be technically NP complete. But I think that you could develop an intelligent set of solutions, each one building off of the experience with the last, and algorithmically choose a best solution from the calculated set. You may not be able to prove it is the best possible solution. But from a practical standpoint, you have an optimized parking lot, so does it really matter that given an infinite amount of time you would have squeezed 3 more cars in there?
+1 NP complete doesn't mean impossible. For small parking lots, you could search the entire space. For large lots, "good enough" is often so close to optimal in practice that it doesn't matter.
– Yann Ramin
May 13 '10 at 18:01
It is indeed possible to come up with a provably optimal solution for both the bin-packing component, as well as the get-the-cars-out component.
– Shaggy Frog
May 13 '10 at 19:56
add a comment |
up vote
0
down vote
I think it may be technically NP complete. But I think that you could develop an intelligent set of solutions, each one building off of the experience with the last, and algorithmically choose a best solution from the calculated set. You may not be able to prove it is the best possible solution. But from a practical standpoint, you have an optimized parking lot, so does it really matter that given an infinite amount of time you would have squeezed 3 more cars in there?
+1 NP complete doesn't mean impossible. For small parking lots, you could search the entire space. For large lots, "good enough" is often so close to optimal in practice that it doesn't matter.
– Yann Ramin
May 13 '10 at 18:01
It is indeed possible to come up with a provably optimal solution for both the bin-packing component, as well as the get-the-cars-out component.
– Shaggy Frog
May 13 '10 at 19:56
add a comment |
up vote
0
down vote
up vote
0
down vote
I think it may be technically NP complete. But I think that you could develop an intelligent set of solutions, each one building off of the experience with the last, and algorithmically choose a best solution from the calculated set. You may not be able to prove it is the best possible solution. But from a practical standpoint, you have an optimized parking lot, so does it really matter that given an infinite amount of time you would have squeezed 3 more cars in there?
I think it may be technically NP complete. But I think that you could develop an intelligent set of solutions, each one building off of the experience with the last, and algorithmically choose a best solution from the calculated set. You may not be able to prove it is the best possible solution. But from a practical standpoint, you have an optimized parking lot, so does it really matter that given an infinite amount of time you would have squeezed 3 more cars in there?
answered May 13 '10 at 17:57
Matthew Vines
21.4k76692
21.4k76692
+1 NP complete doesn't mean impossible. For small parking lots, you could search the entire space. For large lots, "good enough" is often so close to optimal in practice that it doesn't matter.
– Yann Ramin
May 13 '10 at 18:01
It is indeed possible to come up with a provably optimal solution for both the bin-packing component, as well as the get-the-cars-out component.
– Shaggy Frog
May 13 '10 at 19:56
add a comment |
+1 NP complete doesn't mean impossible. For small parking lots, you could search the entire space. For large lots, "good enough" is often so close to optimal in practice that it doesn't matter.
– Yann Ramin
May 13 '10 at 18:01
It is indeed possible to come up with a provably optimal solution for both the bin-packing component, as well as the get-the-cars-out component.
– Shaggy Frog
May 13 '10 at 19:56
+1 NP complete doesn't mean impossible. For small parking lots, you could search the entire space. For large lots, "good enough" is often so close to optimal in practice that it doesn't matter.
– Yann Ramin
May 13 '10 at 18:01
+1 NP complete doesn't mean impossible. For small parking lots, you could search the entire space. For large lots, "good enough" is often so close to optimal in practice that it doesn't matter.
– Yann Ramin
May 13 '10 at 18:01
It is indeed possible to come up with a provably optimal solution for both the bin-packing component, as well as the get-the-cars-out component.
– Shaggy Frog
May 13 '10 at 19:56
It is indeed possible to come up with a provably optimal solution for both the bin-packing component, as well as the get-the-cars-out component.
– Shaggy Frog
May 13 '10 at 19:56
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f2828954%2foptimizing-a-parking-lot-problem-what-algorithms-should-i-use-to-fit-the-most-a%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
What do you mean "organize a parking lot"? Optimize the choice of space each car parks in? Optimize the physical layout of the parking lot? What are your constraints--are all cars the same size? What geometry are we working with? I think you're getting ahead of yourself; you didn't give much detail about the problem you're trying to solve!
– John Kugelman
May 13 '10 at 17:43
1
I have voted to close. Reason: too vague. Please edit to add more specifics.
– Aryabhatta
May 13 '10 at 17:43
1
I didn't vote to close, but to be honest I'm not sure I understand what the OP wants. What exactly is a parking lot and what exactly is a car in a programming context? What is an exit? Can you post an example? Also, much clearer questions have been closed before. Just saying.
– IVlad
May 13 '10 at 19:03
1
@Shaggy Frog: Consider a parking lot that looks like this, only longer:
_ | | _
, where cars can only be placed on a_
facing a|
. It's pretty obvious what the solution is in this case, so I'm honestly not sure what the OP is after as long as he says "the shape can change, but only if you want it to". Well, I want it to always be that shape so the problem is trivial. I just don't really see what his question is. When you say "parking lot", I think of real life parking lots, for which a greedy algorithm will find the optimal solution easily. Use programming terms to make this less vague.– IVlad
May 13 '10 at 19:44
1
Talking about NP-Completeness for an open-ended question like this is complete nonsense. For instance, I will have a parking lot with a crane attached. It will just pick up the cars and put them out. Completely full. Or use a tunnel as a queue, and if we need the 10th car, drive the first 9 out, and put them back in by driving on the roof of the tunnel. Again completely full. 'Polynomial' time algorithms to put and take out the cars. I guess I will take ShaggyFrog's suggestion and move on.
– Aryabhatta
May 13 '10 at 20:28