meetupmatcher.matcher#

Module Contents#

Classes#

ProblemStatement

All information required to determine the number of groups

SolutionNumbers

Number of groups and similar information

PairUpResult

Concrete solution that matched people to groups

PairUpStatistics

Statistics about the sampling process that optimizes the objective function

Functions#

_solve_numeric(→ SolutionNumbers)

solve_numeric(→ SolutionNumbers)

lexicographic_greater(→ bool)

Return True if a is lexicographically greater than b

sample(→ tuple[numpy.ndarray, int])

Put people in a group of fixed size in a way that helps to maximize the number

_pair_up(→ PairUpResult | None)

Single trial of pairing up people.

pair_up(→ tuple[PairUpResult, PairUpStatistics])

Pair up people by optimizing the objective function over multiple trials.

exception meetupmatcher.matcher.NoSolution#

Bases: Exception

Common base class for all non-exit exceptions.

exception meetupmatcher.matcher.TooFewPeople#

Bases: NoSolution

Common base class for all non-exit exceptions.

exception meetupmatcher.matcher.IncompatibleAvailabilities#

Bases: NoSolution

Common base class for all non-exit exceptions.

class meetupmatcher.matcher.ProblemStatement#

All information required to determine the number of groups

n_people: int#
n_notwo: int#
__post_init__()#
class meetupmatcher.matcher.SolutionNumbers#

Number of groups and similar information

property n_people: int#

Total number of people

partitions: tuple[int, int, int]#
removed: int = 0#
meetupmatcher.matcher._solve_numeric(ps: ProblemStatement) SolutionNumbers#
meetupmatcher.matcher.solve_numeric(ps: ProblemStatement) SolutionNumbers#
meetupmatcher.matcher.lexicographic_greater(a: numpy.ndarray, b: numpy.ndarray) bool#

Return True if a is lexicographically greater than b

meetupmatcher.matcher.sample(mask: numpy.ndarray, n: int, availabilities: numpy.ndarray | None = None, *, rng: numpy.random.Generator | None = None, max_joint_av_boon=5, wasted_resource_offset=3) tuple[numpy.ndarray, int]#

Put people in a group of fixed size in a way that helps to maximize the number of joint availabilities of each group in the ent.

Parameters:
  • mask

  • n – Sample/group size

  • availabilities

  • rng

  • max_joint_av_boon – This limits the probability boost for joint availabilities.

  • wasted_resource_offset – The lower this parameter, the more we punish people with many availabilities being assigned to a group where the joint availability does not “profit from it”

Returns:

Set of indices of people belonging into group, joint availabilities

class meetupmatcher.matcher.PairUpResult#

Concrete solution that matched people to groups

property av_sums: numpy.ndarray#
property n_removed: int#
property min_av_sum: int#
property mean_av_sum: float#
segmentation: list[set[int]]#
removed: set[int]#
cost: numpy.ndarray#
joint_availabilities: numpy.ndarray#
__post_init__()#
meetupmatcher.matcher._pair_up(sn: SolutionNumbers, idx: numpy.ndarray, notwo: numpy.ndarray, best_cost: numpy.ndarray, availabilities: numpy.ndarray | None = None, *, rng: numpy.random.Generator | None = None) PairUpResult | None#

Single trial of pairing up people.

Parameters:
  • sn – SolutionNumbers, specifying the number of groups of each size

  • idx

  • notwo – Boolean array: Who vetoes to be in a group of only two-people

  • best_cost – Minimal objective function so far

  • availabilities – Boolean array of n_people x n_timeslots

  • rng – Random number generator

Returns:

None if we abort early because the current solution is worse than the best

class meetupmatcher.matcher.PairUpStatistics#

Statistics about the sampling process that optimizes the objective function

df: pandas.DataFrame#
best: numpy.ndarray#
solution_pair_avs: numpy.ndarray#
meetupmatcher.matcher.pair_up(sn: SolutionNumbers, idx: numpy.ndarray, notwo: numpy.ndarray | None = None, availabilities: numpy.ndarray | None = None, *, max_tries=1000000, abort_after_stable=100000, rng: numpy.random.Generator | None = None) tuple[PairUpResult, PairUpStatistics]#

Pair up people by optimizing the objective function over multiple trials.

Parameters:
  • sn – SolutionNumbers, specifying the number of groups of each size

  • idx – Indices of people to be paired up

  • notwo – Boolean array: Who vetoes to be in a group of only two-people

  • availabilities – Boolean array of n_people x n_timeslots

  • max_tries – Maximum number of trials

  • abort_after_stable – Abort after this many trials without improvement

  • rng – Random number generator

Returns:

PairUpResult, PairUpStatistics