matching

package
v0.0.0-...-8f783ef Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package matching score design doc: https://bit.ly/2OTuBhM

Package matching matches request from planner for a particular day

Index

Constants

View Source
const (
	PriceZeroMean    = 0.0
	PriceOneMean     = 10.0
	PriceTwoMean     = 30.0
	PriceThreeMean   = 50.0
	PriceFourMean    = 100.0
	PriceDefaultMean = PriceTwoMean
)
View Source
const (
	MaxPlaceRating = 5.0
)
View Source
const SelectionThreshold = -1

Variables

This section is empty.

Functions

func AveragePricing

func AveragePricing(priceLevel POI.PriceLevel) float64

AveragePricing returns expected price of the price level

func KnapsackMatrixCopy

func KnapsackMatrixCopy(dst [][]knapsackNode, src [][]knapsackNode)

func MatchClusterCenters

func MatchClusterCenters(eClusterCenters [][]float64, vClusterCenters [][]float64) (pairs []clusterCenterPair, err error)

func PlaceScore

func PlaceScore(place Place) float64

func Score

func Score(places []Place, distNorm int) float64

Score uses constant distance normalisation factor

func ScoreOld

func ScoreOld(places []Place) float64

OLD plan scoring method, use maxDist as the normalisation factor TODO, RW: remove in the future

Types

type FilterCriteria

type FilterCriteria string

FilterCriteria is an enum for various points of interest filtering criteria

const (
	MinResultsForTimePeriodMatching                = 20
	FilterByTimePeriod              FilterCriteria = "filterByTimePeriod"
	FilterByPriceRange              FilterCriteria = "filterByPriceRange"
	FilterByUserRating              FilterCriteria = "filterByUserRating"
)

type FilterRequest

type FilterRequest struct {
	Places []Place
	Params map[FilterCriteria]interface{}
}

type Matcher

type Matcher interface {
	Match(req *FilterRequest) (places []Place, err error)
	MatcherName() string
}

type MatcherForPriceRange

type MatcherForPriceRange struct {
}

func (MatcherForPriceRange) Match

func (matcher MatcherForPriceRange) Match(req *FilterRequest) ([]Place, error)

func (MatcherForPriceRange) MatcherName

func (matcher MatcherForPriceRange) MatcherName() string

type MatcherForTime

type MatcherForTime struct {
}

func (MatcherForTime) Match

func (m MatcherForTime) Match(req *FilterRequest) ([]Place, error)

func (MatcherForTime) MatcherName

func (m MatcherForTime) MatcherName() string

type MatcherForUserRatings

type MatcherForUserRatings struct {
}

func (MatcherForUserRatings) Match

func (m MatcherForUserRatings) Match(req *FilterRequest) ([]Place, error)

func (MatcherForUserRatings) MatcherName

func (m MatcherForUserRatings) MatcherName() string

type Place

type Place struct {
	Place    *POI.Place
	Category POI.PlaceCategory `json:"category"`
	Address  string            `json:"address"`
	Price    float64           `json:"price"`
}

func CreatePlace

func CreatePlace(place POI.Place, category POI.PlaceCategory) Place

func Knapsack

func Knapsack(places []Place, interval TimeInterval, budget uint) (results []Place, totalCost uint, totalTimeSpent uint8)

KnapsackV1 v2 uses sparse matrix like storage for step values and saves memory KnapsackV1 v1 is migrated to knapsack_old_test_only.go

func KnapsackV1

func KnapsackV1(places []Place, interval TimeInterval, budget uint) (results []Place)

func NearbySearchForCategory

func NearbySearchForCategory(ctx context.Context, searcher iowrappers.SearchClient, req *Request) ([]Place, error)

func (*Place) Hours

func (place *Place) Hours() [7]string

func (*Place) Id

func (place *Place) Id() string

func (*Place) IsOpenBetween

func (place *Place) IsOpenBetween(interval TimeInterval, stayingDurationInHour uint8) bool

func (*Place) Location

func (place *Place) Location() POI.Location

func (*Place) Name

func (place *Place) Name() string

func (*Place) PlaceAddress

func (place *Place) PlaceAddress() string

func (*Place) PlaceCategory

func (place *Place) PlaceCategory() POI.PlaceCategory

func (*Place) PlacePrice

func (place *Place) PlacePrice() float64

func (*Place) Rating

func (place *Place) Rating() float32

func (*Place) SetCategory

func (place *Place) SetCategory(category POI.PlaceCategory)

func (*Place) SetURL

func (place *Place) SetURL(url string)

func (*Place) Type

func (place *Place) Type() POI.LocationType

func (*Place) Url

func (place *Place) Url() string

func (*Place) UserRatingsCount

func (place *Place) UserRatingsCount() int

type PlacesClusterForTime

type PlacesClusterForTime struct {
	Places []Place  `json:"places"`
	Slot   TimeSlot `json:"time slot"`
}

type PriceRangeFilterParams

type PriceRangeFilterParams struct {
	Category   POI.PlaceCategory
	PriceLevel POI.PriceLevel
}

type Request

type Request struct {
	Radius             uint
	Location           POI.Location
	Category           POI.PlaceCategory
	UsePreciseLocation bool
	PriceLevel         POI.PriceLevel
}

type TimeFilterParams

type TimeFilterParams struct {
	Day          POI.Weekday
	TimeInterval POI.TimeInterval
}

type TimeInterval

type TimeInterval struct {
	Day       POI.Weekday
	StartHour uint8
	EndHour   uint8
}

func (*TimeInterval) AddOffsetHours

func (interval *TimeInterval) AddOffsetHours(offsetHour uint8) (intervalOut TimeInterval, valid bool)

type TimeSlot

type TimeSlot struct {
	Slot POI.TimeInterval `json:"slot"`
}

func (*TimeSlot) ToString

func (t *TimeSlot) ToString() string

type UserRatingFilterParams

type UserRatingFilterParams struct {
	MinUserRatings int
}

Jump to

Keyboard shortcuts

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