matching

package
v0.0.0-...-5f5806c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2020 License: BSD-2-Clause, GPL-3.0, MIT Imports: 9 Imported by: 0

Documentation

Overview

data types and algorithms

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllEmpty

func AllEmpty(groups []*Group) bool

func FromJSON

func FromJSON(encoded []byte) (groups []*Group, persons []*Person, err error)

func InsertPersonIntoFullGroup

func InsertPersonIntoFullGroup(p *Person, g *Group) bool

insert person into a full group while kicking out others and still keeping the score as high as possible

func PersonInNoGroup

func PersonInNoGroup(person *Person, groups []*Group) bool

func Shuffle

func Shuffle(a []*Person)

func Sort

func Sort(s []*Person)

func ToJSON

func ToJSON(groups []*Group, persons []*Person) ([]byte, error)

Types

type Combination

type Combination struct {
	Quantity      int
	Configuration []Part
}

type Group

type Group struct {
	Members  []*Person
	MinSize  int
	Capacity int
	Name     string
}

func FindGroup

func FindGroup(name string, groups []*Group) *Group

func NewGroup

func NewGroup(name string, capacity, minSize int) *Group

func (*Group) IndexIn

func (value *Group) IndexIn(slice []*Group) int

func (*Group) String

func (g *Group) String() string

func (*Group) StringWithSize

func (g *Group) StringWithSize() string

type Matcher

type Matcher struct {
	Persons []*Person
	Groups  []*Group
}

func NewMatcher

func NewMatcher(persons []*Person, groups []*Group) *Matcher

func (*Matcher) CalcQuote

func (m *Matcher) CalcQuote() (quote, percentage float64)

calculate the average preference number every person got and the wish fulfilling quote in percent

func (*Matcher) CheckMatcher

func (m *Matcher) CheckMatcher() (error, string)

checks the matcher for correctness in matter of total, but also group specific person amount

func (*Matcher) MatchManyAndTakeBest

func (m *Matcher) MatchManyAndTakeBest(n int, hardTimeout time.Duration, softTimeout time.Duration) error

Simple helper function to try out many solutions and get the best

func (*Matcher) SmartMatch

func (m *Matcher) SmartMatch() bool

type Part

type Part struct {
	Group           *Group
	CandidateAmount int
}

type Person

type Person struct {
	Name        string
	Preferences []*Group
}

func FindPerson

func FindPerson(name string, persons []*Person) *Person

func GetGrouplessPersons

func GetGrouplessPersons(persons []*Person, groups []*Group) []*Person

func GetPersonsInGroup

func GetPersonsInGroup(persons []*Person, groups []*Group) []*Person

func NewPerson

func NewPerson(name string, preferences []*Group) *Person

func (*Person) GetGroup

func (p *Person) GetGroup(groups []*Group) *Group

func (*Person) IndexIn

func (value *Person) IndexIn(slice []*Person) int

func (*Person) String

func (p *Person) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL