algo

package
v2.0.8 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 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

func InServiceTime(cost TazCost, time float64) bool

func StationTimeDependentCosts

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

func TazCenterPoint

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

func TazDistance

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

func TimeToIndex

func TimeToIndex(time float64) int

Types

type BusEdgeAttr

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

type BusNodeAttr

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

type DriveEdgeAttr struct {
	ID int32
}

type DriveNodeAttr

type DriveNodeAttr struct {
	ID    int32
	IsAoi bool
}

type IEdgeWeight added in v2.0.3

type IEdgeWeight[ET any] interface {
	GetRuntimeEdgeWeight(ET, []float64, int, []mapv2.SublineType) float64
}

type IHeuristics

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], w IEdgeWeight[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

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

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

func (*SearchGraph[NT, ET]) ShortestTAZPath

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

type TazCost

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

type TazPair

type TazPair struct {
	X int32
	Y int32
}

func PointToNearTAZs

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

func PointToTaz

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

type WalkLaneNode

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

type WalkNodeAttr

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