How to construct (0,1)-matrices with prescribed row and column sum vectors
古いコメントを表示
- All matrix elements are either 1 or 0.
- Both row sum vector and column sum vector are given.
- Return a 3-dimensional result that stacks all possible solutions along the third dimension. (exhaustive, all possible solutions need to be included.)
- Avoid looping at best due to performance, use matrix operations whenever possible.
- Thank you so much for your assistance :)
6 件のコメント
John D'Errico
2020 年 9 月 15 日
編集済み: John D'Errico
2020 年 9 月 15 日
You do understand the total number of solutions will likely be immense? And therefore, the result of this operation will be highly memory intensive? The computation of all such solutions will likely take more work than solving whatever it is that you want to solve in the first place.
The thing is, almost always when someone asks for a brute force solution like this, where ALL possible solutions are listed, this is the wrong approach. Instead, you should learn to use optimization tools to solve what you want to use this to solve.
Yingao Zhang
2020 年 9 月 15 日
編集済み: Yingao Zhang
2020 年 9 月 15 日
Ameer Hamza
2020 年 9 月 15 日
What are the sizes of the row sum and column sum vectors? Is brute-force even feasible considering all the possible combination will be 2^(numel(row_sum)*numel(col_sum)). Unless there is a pattern with the selection matrix, I guess you will have to be contented with a sub-optimal solution using some heuristic-based algorithm.
Yingao Zhang
2020 年 9 月 15 日
編集済み: Yingao Zhang
2020 年 9 月 15 日
Ameer Hamza
2020 年 9 月 16 日
編集済み: Ameer Hamza
2020 年 9 月 16 日
If rows represent objects, then does that mean that row sum for all values is 1? And the column sum should add up to the number of objects. For example, if there are 200 objects and 20 destinations, then do you have
row_sum = ones(200, 1);
col_sum = % [1x20] matrix where sum(col_sum)=200
Is this correct?
Yingao Zhang
2020 年 9 月 16 日
編集済み: Yingao Zhang
2020 年 9 月 16 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Function Creation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!