Skip to content

Latest commit

 

History

History
41 lines (28 loc) · 1 KB

usage.md

File metadata and controls

41 lines (28 loc) · 1 KB

Diversity module

Installation

In order to use this module in other project it is sufficient to copy the diversity folder in your project import path.

Example

import diversity as d

elements = range(42)

# greedy algorithm
greedy_most_diverse = d.greedy(elements, 10)

# interchange algorithm
interchange_most_diverse = d.interchange(elements, 10)

# neighborhood algorithm
neighborhood_most_diverse = d.neighborhood(elements, 20)

Example with custom diversity function

import diversity as d

def custom_elm_set_diversity(element, sett):
  return sum([abs(element * e) for e in sett])

elements = range(42)

# greedy algorithm
greedy_most_diverse = d.greedy(elements, 10, diversity_element_set=custom_elm_set_diversity)

Please refer to the reference for further details.