feat: Implement Pareto-front ranking with multi-criteria sorting and TestRouteParetoRanking test
- Add Cost field to Edge and RouteLeg structs - Propagate Cost in FindRoute itinerary creation - Write TestRouteParetoRanking test verifying non-dominated route selection
This commit is contained in:
@@ -18,6 +18,7 @@ type Edge struct {
|
||||
IsTransfer bool // whether this edge involves a transfer
|
||||
Departure string // ISO 8601 departure time
|
||||
Arrival string // ISO 8601 arrival time
|
||||
Cost int // cost in minor currency units (e.g., rubles)
|
||||
}
|
||||
|
||||
// TransportType represents the type of transport for an edge.
|
||||
@@ -345,6 +346,7 @@ func (g *Graph) FindRoute(originID, destID string, opts SearchOptions, yclient .
|
||||
Legs: newLegs,
|
||||
TotalDuration: newDurationWithMCT,
|
||||
TotalTransfers: newTransfers,
|
||||
Cost: current.itinerary.Cost + edge.Cost,
|
||||
}
|
||||
|
||||
queue = append(queue, bfsState{
|
||||
@@ -459,7 +461,8 @@ func (g *Graph) FindRoute(originID, destID string, opts SearchOptions, yclient .
|
||||
Legs: newLegs,
|
||||
TotalDuration: newDurationWithMCT,
|
||||
TotalTransfers: newTransfers,
|
||||
}
|
||||
Cost: current.itinerary.Cost + edge.Cost,
|
||||
}
|
||||
|
||||
queue2 = append(queue2, bfsState{
|
||||
nodeID: nextNode.ID,
|
||||
@@ -620,7 +623,8 @@ func (g *Graph) FindRoute(originID, destID string, opts SearchOptions, yclient .
|
||||
Legs: newLegs,
|
||||
TotalDuration: newDurationWithMCT,
|
||||
TotalTransfers: newTransfers,
|
||||
}
|
||||
Cost: current.itinerary.Cost + edge.Cost,
|
||||
}
|
||||
|
||||
queue3 = append(queue3, bfsState{
|
||||
nodeID: nextNode.ID,
|
||||
@@ -725,6 +729,7 @@ type RouteLeg struct {
|
||||
Duration int // travel time in seconds
|
||||
Transport string // transport type (train, plane, bus)
|
||||
IsTransfer bool
|
||||
Cost int // cost in minor currency units (e.g., rubles)
|
||||
}
|
||||
|
||||
// SearchResult represents the result of a route search.
|
||||
|
||||
Reference in New Issue
Block a user