Can someone help me to optimize this matrix?
1 view (last 30 days)
Show older comments
I have the following matrix
wall0 = [0 0 0 0 0 0 0 0 0 0;...
0 0 0 0 0 0 0 0 0 0;...
0 a 0 b 0 a 0 0 0 0;...
0 0 a 0 b 0 a 0 0 0;...
0 0 0 a 0 a 0 0 0 0;...
0 a 0 b 0 a 0 0 0 0;...
0 0 a 0 b 0 a 0 0 0;...
0 0 0 a 0 a 0 0 0 0;...
0 0 b 0 b 0 b 0 0 0;...
0 0 0 0 0 0 0 0 0 0];
Where
a = 0.3;
b = 0.5;
The numbers in the matrix represent probabilities that a 'sound wave' would be absorbed, where 0 is a zero probability.
All this means is that a cell is chosen randomly in my code, and an 'if' statement determines whether or not the 'wave' is absorbed based on another random number between 0 and 1 that is attached to it.
An algorithm that randomizes the rows, as follows:
[rows,cols] = size(wall0) ;
for i=1:rows
idx = randperm(cols) ;
wallR(i,idx) = wall0(i,:);
end
An example of what I mean is:
wave1 hits wall0 (randomly) at [4,3] -> wall0(4,3) = a
if (different) random number for wave1 < a, wave1 is absorbed
number of absorptions += 1
repeat x number of times
The only constraints are that the matrix dimensions are fixed; and the number of a's and b's (and zeros) are fixed and can only move within the rows.
Basically, I would like to optimize this matrix such that the number of absorptions is maximized. I am hoping that someone may be able to help as I am a beginner in regards to optimization.
12 Comments
Walter Roberson
on 28 Nov 2017
The a and b are fixed as to their rows and the number of each in a given row, but may move within the row. The matrix therefore cannot be taken fully randomly.
You could take a random matrix within those constraints, but the problem is doing meaningful optimization against that, short of just trying all of the possibilities.
Answers (0)
See Also
Categories
Find more on Problem-Based Optimization Setup 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!