algo

package
v1.8.9 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// 	// 行人、车辆、公交速度
	// 	BUS_SPEED = 40 / 3.6
	// 数值常量
	FORWARD  = 1
	BACKWARD = 2

	BUS = 4
	// 道路头尾,与连接关系对应
	HEAD = int(mapv2.LaneConnectionType_LANE_CONNECTION_TYPE_HEAD)
	TAIL = int(mapv2.LaneConnectionType_LANE_CONNECTION_TYPE_TAIL)

	// 道路边权的分辨率/s
	TIME_SLICE_INTERVAl = 300
	// 道路边权时间片数
	TIME_SLICE_LENGTH = 288
)

Variables

View Source
var (
	// 错误:超出道路边权时间片数
	ErrOutOfTimeSlice = errors.New("out of time slice, should be less than 288")
	// 错误:对非时序图设置长度超过1的边权
	ErrNoTDGraph = errors.New("no time dependent graph, should set edge length with length 1")
)

Functions

func InServiceTime added in v1.8.0

func InServiceTime(cost TazCost, time float64) bool

func StationTimeDependentCosts added in v1.8.0

func StationTimeDependentCosts(cost float64, departureTimes []float64) []float64

func TazCenterPoint added in v1.8.0

func TazCenterPoint(taz TazPair, xStep float64, yStep float64, xMin float64, yMin float64) geometry.Point

func TazDistance added in v1.8.0

func TazDistance(taz1 TazPair, taz2 TazPair, xStep float64, yStep float64) float64

func TimeToIndex

func TimeToIndex(time float64) int

Types

type BusEdgeAttr added in v1.8.0

type BusEdgeAttr struct {
	FromID      int32 // 出发车站aoi id
	ToID        int32 // 到达车站aoi id
	SublineID   int32 // 线路 id
	SublineType int
}

type BusNodeAttr added in v1.8.0

type BusNodeAttr struct {
	ID              int32                 // 车站aoi id
	StationTAZCosts map[TazPair][]TazCost // 车站成指定线路到达指定TAZ的cost
	SublineTazCosts map[int32][]TazCost   // 经过此车站的所有线路到达指定TAZ的cost
	//StationTAZ      TazPair               // 车站所在TAZ
	CenterPoint geometry.Point
}

type DriveEdgeAttr added in v1.8.0

type DriveEdgeAttr struct {
	ID int32
}

type DriveNodeAttr added in v1.8.0

type DriveNodeAttr struct {
	ID    int32
	IsAoi bool
}

type IHeuristics added in v1.8.0

type IHeuristics[NT any, ET any] interface {
	HeuristicEuclidean(geometry.Point, geometry.Point) float64
	HeuristicBus(NT, []ET, geometry.Point, float64) float64
}

type Item

type Item struct {
	Value    int     // The value of the item; arbitrary.
	Priority float64 // The priority of the item in the queue.
	// The Index is needed by update and is maintained by the heap.Interface methods.
	Index int // The index of the item in the heap.
}

An Item is something we manage in a priority queue.

type PathItem

type PathItem[NT any, ET any] struct {
	NodeAttr NT
	EdgeAttr ET
}

type PriorityQueue

type PriorityQueue []*Item

A PriorityQueue implements heap.Interface and holds Items.

func (PriorityQueue) Len

func (pq PriorityQueue) Len() int

func (PriorityQueue) Less

func (pq PriorityQueue) Less(i, j int) bool

func (*PriorityQueue) Pop

func (pq *PriorityQueue) Pop() any

func (*PriorityQueue) Push

func (pq *PriorityQueue) Push(x any)

func (PriorityQueue) Swap

func (pq PriorityQueue) Swap(i, j int)

type SearchGraph

type SearchGraph[NT any, ET any] struct {
	// contains filtered or unexported fields
}

func NewSearchGraph

func NewSearchGraph[NT any, ET any](isTD bool, h IHeuristics[NT, ET]) *SearchGraph[NT, ET]

func (*SearchGraph[NT, ET]) GetEdgeLength

func (g *SearchGraph[NT, ET]) GetEdgeLength(from, to int, tIndex int) float64

func (*SearchGraph[NT, ET]) GetEdgeLengthAndAttr

func (g *SearchGraph[NT, ET]) GetEdgeLengthAndAttr(from, to int, tIndex int) (float64, ET)

func (*SearchGraph[NT, ET]) InitEdge

func (g *SearchGraph[NT, ET]) InitEdge(from, to int, lengths []float64, attr ET)

func (*SearchGraph[NT, ET]) InitNode

func (g *SearchGraph[NT, ET]) InitNode(p geometry.Point, attr NT, noOut bool) int

func (*SearchGraph[NT, ET]) SetEdgeLength

func (g *SearchGraph[NT, ET]) SetEdgeLength(from, to int, tIndex int, length float64) error

func (*SearchGraph[NT, ET]) SetEdgeLengths

func (g *SearchGraph[NT, ET]) SetEdgeLengths(from, to int, lengths []float64) error

func (*SearchGraph[NT, ET]) ShortestPath

func (g *SearchGraph[NT, ET]) ShortestPath(start, end int, curTime float64) ([]PathItem[NT, ET], float64)

func (*SearchGraph[NT, ET]) ShortestPathAStar

func (g *SearchGraph[NT, ET]) ShortestPathAStar(start, end int, curTime float64) ([]PathItem[NT, ET], float64)

A Star算法求最短路

func (*SearchGraph[NT, ET]) ShortestPathAStarToTaz added in v1.8.0

func (g *SearchGraph[NT, ET]) ShortestPathAStarToTaz(start int, endTaz TazPair, endP geometry.Point, sameTazDistance float64, curTime float64) ([]PathItem[NT, ET], float64)

非固定终点最短路 遍历到终点所在taz即停止

func (*SearchGraph[NT, ET]) ShortestTAZPath added in v1.8.0

func (g *SearchGraph[NT, ET]) ShortestTAZPath(start int, endTaz TazPair, endP geometry.Point, sameTazDistance, curTime float64) ([]PathItem[NT, ET], float64)

type TazCost added in v1.8.0

type TazCost struct {
	Cost             float64
	SublineID        int32
	SublineStartTime float64
	SublineEndTime   float64
	TazPair          TazPair
}

type TazPair added in v1.8.0

type TazPair struct {
	X int32
	Y int32
}

func PointToNearTAZs added in v1.8.6

func PointToNearTAZs(p geometry.Point, xStep float64, yStep float64, xMin float64, yMin float64) []TazPair

func PointToTaz added in v1.8.0

func PointToTaz(p geometry.Point, xStep float64, yStep float64, xMin float64, yMin float64) TazPair

type WalkLaneNode added in v1.8.0

type WalkLaneNode struct {
	S      float64 // 距离起点的距离
	NodeId int     // 在graph中的nodeId
}

type WalkNodeAttr added in v1.8.0

type WalkNodeAttr struct {
	ID    int32
	IsAoi bool
}

Jump to

Keyboard shortcuts

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