首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我有10个节点。每个节点都有已知数量的收发器。我想知道如何在节点之间获得所有可能的连接?使用MATLAB

我有10个节点。每个节点都有已知数量的收发器。我想知道如何在节点之间获得所有可能的连接?使用MATLAB
EN

Stack Overflow用户
提问于 2017-06-03 11:53:07
回答 1查看 66关注 0票数 0

我有10个节点。如本矢量所示,每个节点都有已知数量的收发器:

代码语言:javascript
复制
[8 3 3 3 3 3 2 1 1 1]

其中:8是第1节点的收发器数,3是第2节点的收发器数,等等。

每个收发信机一次只能从一个源接收。要求所有收发器必须同时使用。允许同一节点使用多个收发信机向有足够多收发器接收的另一个节点发送。一个收发器不可能被认为是在向多个收发器发送。

我想知道如何获得节点之间的所有可能的连接,以及每个获得的连接矩阵,识别连接节点之间使用的收发器的数量?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-06-03 17:25:35

我不知道如何在Matlab中做到这一点。

使用米尼辛,我找到了以下解决方案(使用Microsoft Word稍微按摩一下):

注意,我使用节点号0..9而不是1..10来压缩矩阵文本。有大量可能的解决办法。这只是其中之一。

米尼辛 脚本:

代码语言:javascript
复制
include "globals.mzn"; 

set of int: Transceivers = 1..28;
set of int: Nodes = 1..10;

array[Transceivers] of Nodes: node = [1,1,1,1,1,1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,8,9,10];
array[Transceivers] of Nodes: seq  = [1,2,3,4,5,6,7,8,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,1,1,1];

array[Transceivers] of var Transceivers: aTo;

array[Nodes, Nodes] of var Transceivers: connections;

% Each transceiver can only receive from one source at a time
constraint all_different([aTo[t] | t in Transceivers]);

% transceivers have to connect to other nodes rather than to their own node
constraint 
  forall(t in Transceivers) 
    (node[aTo[t]] != node[t]);

% no more than 1 connection between any pair of nodes
constraint
  forall(i in Nodes, j in Nodes where j > i)
    (sum([bool2int((node[t] == i) /\ (node[aTo[t]] == j)) | t in Transceivers]) < 2);    

solve satisfy;

output ["     "] ++ [ show(node[i]-1) ++ "." ++ show(seq[i]) ++ " | " | i in Transceivers] ++
       [ if j == 1 then ("\n" ++ show(node[i]-1) ++ "." ++ show(seq[i]) ++ ": ") else "" endif ++ 
         if fix(aTo[i]) == j then " x  | " else "    | " endif 
        | i in Transceivers, j in Transceivers ];
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44343631

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档