Can someone help me to optimize this matrix?

1 次查看(过去 30 天)
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 个评论
Walter Roberson
Walter Roberson 2017-11-28
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.
David Mueller
David Mueller 2017-11-28
编辑:David Mueller 2017-11-28
Ren, thanks for your response. Wall0 and wallR are both 10x10 matrices, the difference being that wallR has its rows randomly shuffled. And yes, I want to optimize wallR for the greatest number of absorptions as you said
The wave is composed of two 100x1 vectors (I just called it wave1 in the pseudocode for simplicity, although now I see that may have been less helpful than intended). One is called relHeight which is just the row numbers where each wave hits, and the other is relWidth which is the column numbers. Together they give the contact index on the wall for each wave. I am open to suggestions regarding changing the organization if it would help.
Walter, yes that is correct regarding the a's and b's. Although, it doesn't necessarily have to be completely random shuffling. If there is a way to look at all the permutations and find the optimal arrangement using other than rng, I would be willing to try.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Problem-Based Optimization Setup 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by