Skip to content

Commit

Permalink
Feature/Implement function of GenerateChargeSolutions for station_gra…
Browse files Browse the repository at this point in the history
…ph (#215)

* feat: implement GenerateChargeSolutions() function in station_graph
issue: #143
  • Loading branch information
CodeBear801 authored Mar 13, 2020
1 parent a95c22a commit 6a5433b
Show file tree
Hide file tree
Showing 8 changed files with 612 additions and 313 deletions.
1 change: 1 addition & 0 deletions integration/oasis/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
generateResponse4SingleChargeStation(w, oasisReq, overlap, h.osrmConnector)
return
}
pickChargeStationsWithEarlistArrival(oasisReq, route, h.osrmConnector, h.tnSearchConnector)

generateFakeOASISResponse(w, oasisReq)
}
Expand Down
10 changes: 6 additions & 4 deletions integration/oasis/reachable_by_multiple_charge.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ import (
)

func pickChargeStationsWithEarlistArrival(oasisReq *oasis.Request, routeResp *route.Response, oc *osrmconnector.OSRMConnector, sc *searchconnector.TNSearchConnector) {
// chargeLocations := chargeLocationSelection(oasisReq, routeResp)
// for _, locations := range chargeLocations {
// c := stationfinder.CalculateWeightBetweenNeighbors(locations, oc, sc)
// }
// chargeLocations := chargeLocationSelection(oasisReq, routeResp)
// for _, locations := range chargeLocations {
// c := stationfinder.CalculateWeightBetweenNeighbors(locations, oc, sc)
// sol := stationgraph.NewStationGraph(c, oasisReq.CurrRange, oasisReq.MaxRange,
// chargingstrategy.NewFakeChargingStrategyCreator(oasisReq.MaxRange)).GenerateChargeSolutions()
// }
}

// For each route response, will generate an array of *stationfinder.StationCoordinate
Expand Down
1 change: 1 addition & 0 deletions integration/oasis/reachable_by_single_charge.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func generateResponse4SingleChargeStation(w http.ResponseWriter, req *oasis.Requ

station := new(oasis.ChargeStation)
station.WaitTime = 0.0
// @todo ChargeTime and ChargeRange need to be adjusted according to chargingstrategy
station.ChargeTime = 7200.0
station.ChargeRange = req.MaxRange
station.DetailURL = "url"
Expand Down
5 changes: 3 additions & 2 deletions integration/oasis/stationgraph/graph.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package stationgraph

import (
"github.com/Telenav/osrm-backend/integration/oasis/chargingstrategy"
"github.com/golang/glog"
)

type graph struct {
nodes []*node
startNodeID nodeID
endNodeID nodeID
strategy chargingstrategy.ChargingStrategyCreator
}

func (g *graph) dijkstra() []nodeID {
Expand All @@ -32,8 +34,7 @@ func (g *graph) dijkstra() []nodeID {
node := g.nodes[n]
for _, neighbor := range node.neighbors {
if g.nodes[n].isLocationReachable(neighbor.distance) {
// chargeTime := g.nodes[neighbor.targetNodeID].calcChargeTime(node, neighbor.distance, g.strategy)
chargeTime := 0.0
chargeTime := g.nodes[neighbor.targetNodeID].calcChargeTime(node, neighbor.distance, g.strategy)
if m.add(neighbor.targetNodeID, n, neighbor.distance, neighbor.duration+chargeTime) {
g.nodes[neighbor.targetNodeID].updateArrivalEnergy(node, neighbor.distance)
g.nodes[neighbor.targetNodeID].updateChargingTime(chargeTime)
Expand Down
Loading

0 comments on commit 6a5433b

Please sign in to comment.