minorg.minweight_sc module
Implementation of the weight-based set cover algorithm presented in Ajami, Z. and Cohen, S. (2019) Enumerating Minimal Weight Set Covers. Proceedings - International Conference on Data Engineering, 518-529
- class minorg.minweight_sc.Q(set_of_sets_class=None)[source]
Bases:
list
- property top: minorg.minweight_sc.e[source]
- class minorg.minweight_sc.Set(name, weight, elements)[source]
Bases:
set
- class minorg.minweight_sc.SetOfSets(*Sets)[source]
Bases:
set
- property redundancy: int[source]
Returns sum of the number of times each element is present in more than one set.
- minorg.minweight_sc.approx_min_SC(U, S, seed=None, low_coverage_penalty=0) minorg.minweight_sc.SetOfSets [source]
Approximate minimum set cover algorithm.
- Parameters
- Returns
Set cover solution. May also be child class of SetOfSets.
- Return type
- minorg.minweight_sc.argmin(set_of_sets) minorg.minweight_sc.Set [source]
Returns Set with smallest weight.
- class minorg.minweight_sc.e1(a, b, c)[source]
Bases:
minorg.minweight_sc.e
- class minorg.minweight_sc.e2(a, b, c)[source]
Bases:
minorg.minweight_sc.e
- minorg.minweight_sc.enum_approx_order_SC(U, S, num_iter=100, seed=None, low_coverage_penalty=0) list [source]
Minimum weight set cover algorithm, adapted to allow seeding and setting of enumeration limit.
Algorithm described in: Ajami, Z. and Cohen, S. (2019). Enumerating Minimal Weight Set Covers. In Proceedings - International Conference on Data Engineering, 518-529
- Parameters
- Returns
list of SetOfSets object where each is a set cover solution
- Return type
list of
SetOfSets
- minorg.minweight_sc.wc_ratio(s1, s2, low_coverage_penalty=0) float [source]
Calculates ratio of weight of s1 to number of elements in s2 that can be covered by s1. (wc is shorthand for weight-cover, a name I came up with because the authors did not)
Low coverage penalty was added to allow disincentivisation of ultra large set covers full of small, non-overlapping, ultra low coverage sets.
- Parameters
s1 (set) – first set
s2 (set) – second set
low_coverage_penalty (float) – if 0, no penalty for uncovered elements. Modifies output value into ‘<wc ratio> + (<low_coverage_penalty> * <wc ratio> * <uncovered>/<covered>)’