Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: Highest total sum path problem

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


in reply to Re: Highest total sum path problem
in thread Highest total sum path problem

> "real matrix is 50000*50000" HaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHa

It's not that impossible if the approach was mathematical.

Of course this would require cleanly defined rules and not these "oh good point I forgot to mention that ..." dialogs.°

How this?

  • I could imagine proving that a path covering n-x points is maximal possible and exists.
  • One would identify the x minimal points to be excluded.
  • I expect x to be just the non positive weight cells in most cases anyway.
  • There are most likely many equally short paths possible, which could be proven, too.
  • Now picking one minimal path should be sufficient.

In short, no need to brute force all possible paths if there are plenty optimal ones and picking one is sufficient.

Of course I might have misunderstood the "rules", but why should I risk to invest more efforts for vain ? ;)

For instance:

  • is it really allowed to slide back a way you just slid forward? (Like your first two moves a0-up9-down3)
  • is it allowed to slide over positive weights? (Like your third move -left1 ignoring 3 positive cells in between)

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

°) read "I have no real clue what I need"

update

Your solution demonstrates my approach pretty well:

  • you are visiting all positive cells
  • the only non positive one is your starting point
  • the shortest path must have the same amount of moves when you avoid revisiting a cell.
  • There are certainly many paths meeting that criterion
  • most probably automatically constructed from smaller segments like: "finish a column/line before switching to the next one"

Replies are listed 'Best First'.
Re^3: Highest total sum path problem
by LanX (Saint) on Mar 08, 2020 at 01:36 UTC
    > There are certainly many paths meeting that criterion most probably automatically constructed from smaller segments like

    OK not trivial, but well studied and becoming easier with growing number of possible moves (i.e. low number of non-positive cells here)

    see Hamiltonian Path

    But the general case is NP complete ... hmm ...

    ... well ... HaHaHaHaHaHaHaHaHaHa .... HaHaHaHaHaHaHaHaHaHa

    ;)

    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://11113955]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (8)
As of 2024-04-19 07:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found