# 2. Maximum Weight Stable Set — MIPLearn<br/><small>0.2.0</small>

# 2. Maximum Weight Stable Set

## 2.1. Problem definition

Given a simple undirected graph \(G=(V,E)\) and weights \(w \in \mathbb{R}^V\), the problem is to find a stable set \(S \subseteq V\) that maximizes $ \sum_{v \in `V} w_v$. We recall that a subset :math:`S \subseteq V is a stable set if no two vertices of \(S\) are adjacent. This is one of Karp’s 21 NP-complete problems.

## 2.2. Random instance generator

The class `MaxWeightStableSetGenerator` can be used to generate random instances of this problem, with user-specified probability distributions. When the constructor parameter `fix_graph=True` is provided, one random Erdős-Rényi graph \(G_{n,p}\) is generated during the constructor, where \(n\) and \(p\) are sampled from user-provided probability distributions `n` and `p`. To generate each instance, the generator independently samples each \(w_v\) from the user-provided probability distribution `w`. When `fix_graph=False`, a new random graph is generated for each instance, while the remaining parameters are sampled in the same way.

## 2.3. Challenge A

- Fixed random Erdős-Rényi graph \(G_{n,p}\) with \(n=200\) and \(p=5\%\)

- Random vertex weights \(w_v \sim U(100, 150)\)

- 500 training instances, 50 test instances

    [ ]:

    MaxWeightStableSetGenerator(
        w=uniform(loc=100., scale=50.),
        n=randint(low=200, high=201),
        p=uniform(loc=0.05, scale=0.0),
        fix_graph=True,
    )

1. Preliminaries 3. Multidimensional Knapsack