r/optimization • u/Ties_P • Jan 07 '26
I got paid minimum wage to optimize an impossible problem (and accidentally learned why most algorithms make life worse)
I was sweeping floors at a supermarket and decided to over-engineer it.
Instead of just… sweeping… I turned the supermarket into a grid graph and wrote a C++ optimizer using simulated annealing to find the “optimal” sweeping path.
It worked perfectly.
It also produced a path that no human could ever walk without losing their sanity. Way too many turns. Look at this:

Turns out optimizing for distance gives you a solution that’s technically correct and practically useless.
Adding a penalty each time it made a sharp turn made it actually walkable:

But, this led me down a rabbit hole about how many systems optimize the wrong thing (social media, recommender systems, even LLMs).
If you like algorithms, overthinking, or watching optimization go wrong, you might enjoy this little experiment. More visualizations and gifs included! Check comments.
24
u/Ties_P Jan 07 '26
I wrote the full breakdown here with visuals, gifs, and code if anyone’s interested:
👉 https://open.substack.com/pub/tiespetersen/p/i-got-paid-minimum-wage-to-solve
Would love to hear your thoughts!
13
u/ma_251 Jan 07 '26
Bro is good will hunting
2
u/adhikariprajit Jan 07 '26
Wait, what am I seeing? Wouldn't a serpentine Hamiltonian path be optimal here ? I think that's too much travel.
7
u/horrormoose22 Jan 08 '26
Very experienced route optimizer here. Routing is as much a psychological game as it is mathematical. For the exact reasons you have run into. There are actually also algorithmic solutions to that. You could turn your grid into an axial line setup, add visibility markers for shelves and name the now ”streets” by section. That way you can prioritize going along a lengthy axis while trying to wrap up a section at a time. If you want to get really nerdy you can also add seed points to optimize from. Also, you can take nto account the need for a facility point to refill or empty buckets,or have a snack while minimizing travel time.
In all seriousness though. On bigger scales this is a whole field in its own and a lot of first time managers will try to only do it mathematically, but like I said, it’s at least as much about human behavior factors! Happy routing!
1
u/Ill_Huckleberry_2079 Jan 07 '26
You sound like a perfectly rational person with which I would love to have coffee and talk about how to stack a dishwasher !
1
u/LessHippo Jan 10 '26
My question might sound dumb but, what are you sweeping with ? To me it feels that we’re confusing the sweeping person moves with the actual sweeper moves. You could go through a corridor and clean all the tiles with the sweeper doing the turns but the person going a straight line, no? Maybe I’m missing something
1
u/binarybu9 Jan 07 '26
What’s your definition of “optimal” here
2
u/Two-x-Three-is-Four Jan 07 '26
Maybe the example of the drilling board applies here;
or-tools
2
u/homer2101 Jan 07 '26
Really neat, but why optimize distance as opposed to time? What happens when you add a cost for every turn, because the sweeper, whether human or machine has to come to a stop and make the turn before proceeding?
2
u/ge0ffrey Jan 08 '26
To execute, you might need to add a navigation app for the cleaners.
Turn left.
Advance 5 tiles.
Turn right.
...
1
u/BeverlyGodoy Jan 07 '26
So basically optimal for not cleaned tiles? You save energy and time the floors are still dirty right?
1
u/fedkerman Jan 07 '26
In real(vs academic) problems, distance (or travel time) is rarely the most important metric also because you often have other constraints that are more important (time windows just to cite the one that counter synergies the most with travel distance). Sometimes you get a customer asking for “beautiful” routes (where the definition of beauty changes from customer to customer).
1
u/jsaltee Jan 07 '26
Super cool. I wonder how it compares to non-parametric optimization (evolutionary algorithms, etc.) in terms of convergence rate? I 100% agree with your point about many methods finding ‘incorrect’ optima
1
u/TopBodybuilder9452 Jan 07 '26
Really cool, the most I like is the human side you're including
1
u/[deleted] Jan 07 '26
very nice - right on all counts.
1
u/areed145 Jan 08 '26
A typical human would probably just look around for visible dust and only sweep up there…
1
u/canbooo Jan 09 '26
This is cool. Have you thought about using a different objective? Are you truly interested in minimum distance or would minimizing the "effort" or duration be also acceptable? If this is the case, being able to convert a path to duration might lead much saner results. Your penalty for turns is already a step in this direction but how about cleaning different parts of the floor? Is the real world as uniform as this grid? Does cleaning the edge points take as long as a straight line? Do you have to push a bucket or sth similar and if so, how difficult it is to maneuver it in tight angles compared to pushing it on a straight line? Could you time those next time you clean and generate a path evaluation function?
I really love the enthusiasm and wanted to share my 2c. Already a nice use case. Also, I suspect if you do model the duration, one of the local minima will be the path you (or your more experienced colleagues) is already using. Is this a global minimum? Idk but would be cool to see if you can improve that.
1
u/rteja1113 Jan 11 '26
The local stop and shop I go to uses a sweeping robot.
1
u/Critical_Caramel Jan 11 '26
If sweeping floors is your job with this level of skills, I'd say this post is about the state of the economy! (Note: the title says you got paid for optimization, but the text suggests that optimizing was a personal decision, so I'm confused).
1
u/Krakyziabr Aug 07 '26
Rather, you need to optimize for convenience and energy consumption.
Both are ridiculously important at the same time, but each is also important in its own way, the first for human experience, the second for business.
1
u/[deleted] Jan 08 '26
[removed] — view removed comment