Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Highest total sum path problem

by LanX (Saint)
on Mar 08, 2020 at 18:26 UTC ( [id://11113980]=note: print w/replies, xml ) Need Help??


in reply to Highest total sum path problem

Your example has 36 cells with only 11 non positive ones. That means only one third of the cells need to be skipped.

After excluding start and stop it's obvious that the best theoretical result is to pass by all remaining 24=34-10 positive ones exactly one time, hence in minimal 25 moves.

tybalt89 has demonstrated that such a path exists, provided his "slides" were legal. (I already expressed my doubt. Please clarify!!! )

Now the following is based on the assumption these slides were correct.

If your 50000x50000 matrix has the same density of > 2/3 positive ones, than the likelihood to find a trivial but optimal solution is very high.

To achieve this I'd reshuffle the matrix by putting the start and end cell at opposing corners.

The rows and columns in between then need to be sorted ascending by number of positive cells.

The trivial solution is based on the fact that you can always reach all positive cells inside your actual row (or column in a dual approach).

What really matters is the jump to the next row with a positive cell in the same column.

(NB: That approach is symmetric by swapping rows and columns)

This is hardest with rows with low density and becomes easier afterwards, hence the pre-sorting.

If this trivial solution fails, you'll still be able to construct a nearly optimal solution by including some non positive cells.

That's a pragmatic approach to ignore the possibility of a slightly better solution, which is much harder to compute.

But this should finish in reasonable time.

HTH!

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11113980]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (9)
As of 2024-04-19 16:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found