Optimization/Dynamic Programming to Find Least Sum from Elements of Two Arrays
Show older comments
Given the following optimization problem,
Find the least sum (globally optimized) from elements of two arrays A and B such that
- Only one element is selected from A or B at each index, i.e., when A(1) is selected, B(1) cannot be selected
- Total sum of elements selected from array B should be <= 57
- Atleast one element should be selected at each index
A = [10, 15, 17, 30, 45]
B= [7, 10, 15, 26, 31]
Basically, elements of B will always be less than elements of A at every index. However, there is a limit on the maximum sum of elements that can be used from B.
2 Comments
John D'Errico
on 15 May 2018
But now, having shown two simple vectors A and B, what would the solution be that you want to see? As far as I can see, the least sum there is gained by taking no elements at all.
Or perhaps, the least sum is gained from just B(1).
Must your solution have a total of 5 elements chosen? So the choice is simply whether you choose from vectors A or B for each index?
Neeraj Rama
on 16 May 2018
Accepted Answer
More Answers (0)
Categories
Find more on Solver Outputs and Iterative Display in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!