The best path to get the maximum sum

shaowu459

Well-known Member
Joined
Apr 26, 2018
Messages
732
Office Version
  1. 365
Platform
  1. Windows
(for language reasons, the content below is the result of automatic machine translation)

Hi All

Recently, I encountered a problem with finding the optimal path and have been unsuccessful despite numerous attempts. I am looking for a solution using spreadsheet function and formulas. Theoretically, using recursion combined with path recording should work, but for a 10*10 matrix, the computational load is too large to be practical. The specific details of the problem are as follows:

1)There is a 10x10 matrix, and all elements in the matrix are positive integers.
2)A person starts at the top-left corner of the matrix and must reach the bottom-right corner. Each move can be to an adjacent cell directly above, below, to the left, or to the right. However, the move is only allowed if the target cell has a number greater than or equal to that of the current cell.
3)It is not allowed to step outside the matrix or revisit any cell that has been previously walked on.
4)Please plan a route from the top-left to the bottom-right corner that maximizes the sum of the numbers on all cells along the path.
5)On the left are some example results, with the cells marked in brown indicating the optimal path.

Any help would be greatly appreciated.

Office version: 365+Beta channel with TRIMRANGE

Help.xlsx
ABCDEFGHIJKLMNOPQRSTUVWX
1Max
222456891113154311)There is a 10x10 matrix, and all elements in the matrix are positive integers.
33445899121315
44466710111314172)A person starts at the top-left corner of the matrix and must reach the bottom-right corner. Each move can be to an adjacent cell directly above, below, to the left, or to the right. However, the move is only allowed if the target cell has a number greater than or equal to that of the current cell.
5567891113131616
66789111114151618
777910111315161819
88101113131516191922
9101112141417182020233)It is not allowed to step outside the matrix or revisit any cell that has been previously walked on.
1012131416161819202424
1113141617181922242527
124)Please plan a route from the top-left to the bottom-right corner that maximizes the sum of the numbers on all cells along the path.
13Max
141234678101213380
1513556891212155)On the left are some example results, with the cells marked in brown indicating the optimal path.
1643567911121516
17566781012141618
186788101213151719
1979811121314161719
20991012121517171921
2110101213151717192122
2212121315171819222225
2313151518182021242426
24
25Max
262234689111314451
271446889111415
2833559910121415
29557891012131517
307789111214161719
3188910131414161719
32991113141416181922
3310121313161517202222
3413131516161820222224
3513141617172121222426
36
Sheet1
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Interested to see if anyone can come up with formulas for this, it sounds horribly complex. My first thoughts:
- start with a smaller grid (e.g. 4x4)
- start only going right & down (so leave up&left out)
Even with these two simple rules I can use VBA to solve it, but formulas are much, much harder to use.
 
Upvote 0
Interested to see if anyone can come up with formulas for this, it sounds horribly complex. My first thoughts:
- start with a smaller grid (e.g. 4x4)
- start only going right & down (so leave up&left out)
Even with these two simple rules I can use VBA to solve it, but formulas are much, much harder to use.
Thank you for taking the time to look at my post. If only moving right and down were allowed, dynamic programming would be very convenient for solving this problem(using formulas). Now, since it's possible to move in four directions, it does not meet the requirement of "without aftereffect" in dynamic programming, making it more complex.
 
Upvote 0

Forum statistics

Threads
1,224,745
Messages
6,180,699
Members
452,994
Latest member
Janick

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top