I am formulating constraints for a network as shown in Figure
.
Blue circles represent a set of nodes, $N = \{1, 2, \ldots, 5\}$. Three different types of devices are connected to different nodes in the network. Some of the devices are shared among multiple nodes, e.g., device 2 (in sun shape) is connected with nodes 1, 2, and 4. I want to select the minimum number of nodes where the following constraint should meet.
- A node $T$ must be selected. This $T$ can be any node from blue circles in the network.
- At least $k$ nodes from blue circles should be selected that are connected to rectangle-shaped $G$ device. In the above figure, $k$ can be node 2 or node 4 or both if $k$ is 2.
- There should be a path between any two pairs of selected nodes. It means that the selected graph should not be disconnected.
I have written the following MILP formulation.
$$\min \sum_{i\in N} x_{i}$$
The constraints are as follows:
$$x_{T} = 1$$ $$\sum_{i\in N} G_{i} \cdot x_{i} \ge k$$ $$\sum_{i\in N, i \ne j} \text{ConnectedNodes}_{i, j} \cdot x_{i} \ge x_{j} \quad \forall j \in N$$
The connectivity constraint is not working correctly and I am not sure how can I enforce constraint 3. I have seen some examples of subgraph generation to ensure connectivity. However, in my case, the selected number of nodes is dynamic. For example, if we fix the value of $k$ to 1, then only node 2 will be selected if node $T$ is node 2. Only nodes 1 and 2 will be selected if node $T$ is node 1. Similarly, nodes 2, 3, and 5 will be selected if node $T$ is node 5. Any help or suggestion in this regard is highly appreciated.