Best algorithm for an object that moves across an area

  • Context: Undergrad 
  • Thread starter Thread starter cashflow
  • Start date Start date
  • Tags Tags
    Algorithm Area
Click For Summary

Discussion Overview

The discussion revolves around finding an optimal algorithm for a car moving across a rectangular plane, aiming to cover the entire area in the fastest possible time. Participants explore various movement strategies, including row-by-row traversal, spiraling, and potential diagonal paths, while considering the time taken for turns and the impact of obstacles.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant suggests minimizing the number of 90-degree turns to optimize the car's movement across the area.
  • Another participant presents a proof that any optimal algorithm requires at least 2m-1 moves, where m is the shorter dimension of the area, indicating multiple ways to achieve this minimum.
  • There is a proposal to consider moving around the perimeter of the area, which may reduce the number of 180-degree turns compared to a row-by-row approach.
  • Some participants discuss the implications of making 90-degree turns versus 180-degree U-turns, with one arguing that the back-and-forth algorithm effectively results in the same number of turns and distance traveled.
  • A later reply introduces the idea of a curving path that allows for continuous movement while turning, suggesting a prolate cycloid path as a potential model.
  • Participants explore the possibility of moving outside the designated area to optimize coverage, with one mentioning the analogy to crop dusting.
  • Clarifications are made regarding the car's turning capabilities and the time taken for different angles of turns, with one participant noting that turning 45 degrees would take half the time of a 90-degree turn.
  • There is a discussion about the potential impact of obstacles on the chosen algorithm, with one participant suggesting that the same strategies could still apply with minor adjustments.

Areas of Agreement / Disagreement

Participants express differing views on the optimal movement strategy, with no consensus reached on whether row-by-row, spiraling, or another method is definitively the best approach. The discussion remains unresolved regarding the most efficient algorithm in the presence of obstacles.

Contextual Notes

Limitations include assumptions about the car's turning capabilities and the effects of obstacles on movement strategies. The discussion also highlights the dependence on the definitions of movement and turning rates.

cashflow
Messages
36
Reaction score
1
Imagine a rectangular plane with dimensions X and Y. On that plane is a car. The car is about Z meters wide (the front bumper width, or up-down width in the image below). The car travels at a velocity v and moves across the entire surface as shown below:



The car in the image above can move left-right or up-down or diagonal or whatever. The car takes T seconds to make a 90 degree turn. The car will need to move across every square inch of the area in the fastest possible time.

I'm trying to come up with an algorithm (perhaps a regression model) to prove the fastest possible time for this car to transverse the entire surface area. I thought that going left-right will be fastest, since the car will take t*2 seconds to make the 180 degree rotation once per row. Going up-down just adds more turns, and I'm not even sure about diagonal movements or moving around the perimeter etc. How would I tackle this problem (ignoring friction, internal resistance, etc, but I'll need to come back to that later)?

(This is not a homework question, I'm working on a project where I need to move an object across the area in the fastest possible time.)
 
Last edited by a moderator:
Physics news on Phys.org
From that description: looks like you need to minimize the number of 90deg turns.
 
Your method is minimal, though not uniquely so.

(Almost) proof:

Without loss of generality you can view the board as a rectangular m-by-n chessboard (m ≤ n) and the car as a rook that has to cover every square in the minimum number of moves (I am making some very minor simplifying assumptions here). The algorithm you suggested covers every square in 2m-1 moves; assume for purposes of contradiction that there is a shorter optimal algorithm. Clearly horizontal and vertical moves must alternate in any optimal solution, so there are at most m-1 vertical moves in the shorter optimal solution. (If there were m vertical moves then there would be m-1 horizontal moves in between them, which totals to 2m-1, contradicting the assumption that the optimal algorithm is faster than 2m-1 moves.)

Each vertical move visits at most one square in each row, and therefore the vertical moves can't eliminate all the squares from any row, since there are n > m-1 squares in each row. This means there is at least one square left in each row that requires a horizontal move along that row to eliminate. There are m rows, so this is m horizontal moves. There must therefore be at least m-1 vertical moves and m horizontal moves, for a total of 2m-1. This contradicts the assumption that there was a shorter optimal algorithm.


So basically you can do it in no fewer than 2m-1 moves (2m-2 turns), where m is the shorter dimension of the region as measured in car-widths. But there is more than one way to achieve that minimum.
 
eigenperson said:
There must therefore be at least m-1 vertical moves and m horizontal moves, for a total of 2m-1.

Oh I see. This helps a lot, thank you!

Just a thought... Let's say you go around the perimeter, from the outside to the inside. You will end up with the same number of moves, but each time you are making a 90 degree rotation instead of a 180 degree U-turn. This seems to be faster than going row by row, since making a 180 degree U-turn is t*2.
 
Last edited:
You thinking of going in a spiral?
t*2=2t ... i.e. the time it takes to make two 90deg turns. The "180deg turn" is a 90deg turn followed by a move 1 space followed by another 90 deg turn.

Spiraling in from the outside, you still get two 90deg turns on each row except the top one.

IRL: a hairpin 180 like that would probably take longer than two 90deg turns separated by a straight... bootlegging it would be possible but that involves coming to a dead stop. Acceleration/decelleration has not been included in the model though.
 
Just a thought... Let's say you go around the perimeter, from the outside to the inside. You will end up with the same number of moves, but each time you are making a 90 degree rotation instead of a 180 degree U-turn. This seems to be faster than going row by row, since making a 180 degree U-turn is t*2.
I don't think you're counting the turns right.

If you make a genuine 180-degree turn, you end up retracing your steps. So this is always a poor strategy.

What you actually do in the "back and forth" algorithm is to go forth across the entire area, turn 90 degrees, go a very short distance (1 car width), turn 90 degrees, and go back across the whole area.

So you end up making the same number of turns either way, and all of them are 90°. You also travel the same distance either way. So they take the same time.
 
cashflow said:
The car in the image above can move left-right or up-down or diagonal or whatever. The car takes T seconds to make a 90 degree turn. The car will need to move across every square inch of the area in the fastest possible time.

So, in particular, the car need not do a "rook's tour". It could, for instance, turn while moving,
following a curving path without slowing down as long as the instantaneous turning radius is always less than r = 4Tv/pi

One could imagine a tour that follows a prolate cycloid path with excursions outside the intended coverage area.

This sounds a lot like crop dusting.
 
Yes, the object can move in any direction. It moves very slowly in the Z direction however (where Z is up). How did you end up with the "r = 4Tv/pi"?
 
You never said how long it took to turn to angles other than 90deg.
Note: the original statement has the car only able to turn 90 deg but apparently capable of moving diagonally without changing direction. technically you don't state that the car needs to turn to go up and down either ... but that seemed like a safe assumption.

It could make matters clearer if you state the car motion in car terms rather than ground terms.
i.e. the car can go forwards and backwards, and it can turn. The turn rate is...

If traveling outside the designated area is possible, then you may get solutions similar to the old "join the dots" puzzle. Then there are weird-topology variations... i.e. if the plane in question is on a cylindrical surface, then you could cover all the space without turning (by running over them diagonally).
 
  • #10
Thanks everyone for your help thus far.

Traveling outside the designated area is indeed possible. The plane is rectangular. The turning is linear-- every 90 degrees takes t seconds. So turning 45 degrees would take t / 2 seconds etc. The turning is already relative to the car-- the car turns 90/t degrees per sec.

So right now, either going by rows or going around in a spiral seems to be the fastest approach (both take the same number of turns). Now, what if we add obstacles, like so? The rectangle inside has lengths k by l, and the circle is of radius r. I still think that the same algorithm could be used, the car could just go around it without losing too much time. Not sure if there's a better way.

 
Last edited by a moderator:

Similar threads

  • · Replies 40 ·
2
Replies
40
Views
5K
  • · Replies 16 ·
Replies
16
Views
2K
  • · Replies 19 ·
Replies
19
Views
2K
  • · Replies 17 ·
Replies
17
Views
3K
  • · Replies 14 ·
Replies
14
Views
2K
  • · Replies 23 ·
Replies
23
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 11 ·
Replies
11
Views
3K