-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Brief layout sketch of race class #124
Draft
e-wai
wants to merge
2
commits into
master
Choose a base branch
from
asc-predictive-opt
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Latitude,Longitude,Temperature,Wind Speed,Wind Direction,Energy Corrected | ||
38.941960,-92.684750 | ||
39.068140,-92.946070 | ||
39.186270,-94.193590 | ||
39.086830,-94.419420 | ||
39.008310,-94.466870 | ||
38.925354,-94.568639 | ||
38.788531,-94.991618 | ||
38.780561,-95.557203 | ||
38.665916,-96.493941 | ||
38.372787,-97.303086 | ||
38.34501,-98.201727 | ||
38.365832,-98.401643 | ||
38.34863,-98.766032 | ||
38.265291,-98.980929 | ||
38.188527,-99.087184 | ||
37.752798,-100.017079 | ||
37.576617,-101.355375 | ||
37.004007,-101.888395 | ||
36.736418,-102.512726 | ||
36.712246,-103.060209 | ||
36.361145,-104.595267 | ||
35.907481,-105.013186 | ||
35.820597,-104.997503 | ||
35.593625,-105.224615 | ||
35.548633,-105.685455 | ||
35.682273,-105.929828 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
""" | ||
do i want to update everything on "get" -> ie. when we run optimization, or before? | ||
if we're running multiple possibilities does this change anything | ||
|
||
let's initially approach this as a prediction _only_ thing | ||
""" | ||
import csv | ||
import pandas as pd | ||
|
||
import sys | ||
import os.path | ||
sys.path.append(os.path.dirname(__file__), '..') | ||
|
||
from dynamics.motor_efficiency.motor_efficiency import MotorEfficiency | ||
from dynamics.car_model import Car | ||
|
||
RACE_FILE = os.path.join(os.path.dirname(__file__), '../routemodel/data_retrieval/new_get_weather.csv') | ||
|
||
class ASC_Race: | ||
|
||
# Car information | ||
PASSENGERS = 4 | ||
BATTERY_CAPACITY_kWH = 20 | ||
|
||
distance_travelled_segments = [] | ||
# passengers = [] | ||
time_elapsed_mins = 0 | ||
|
||
def __init__(self, race_data_csv): | ||
# TODO: determine format of data passing and interacts | ||
# TODO: how to change route? update during race? | ||
self.route_df = pd.read_csv(race_data_csv, delimiter=',') | ||
|
||
# find distance -> hopefully a parameter; append to list | ||
# if passengers not flagged | ||
# self.passengers.append(4) | ||
|
||
@property | ||
def D(self): | ||
''' | ||
Person-Mile Distance | ||
''' | ||
d = 0 | ||
# for seg, passenger in zip(self.distance_travelled_segments, self.passengers): | ||
# d += seg * passenger | ||
|
||
for seg in self.distance_travelled_segments: | ||
d += seg | ||
|
||
return d | ||
|
||
@property | ||
def E(self): | ||
''' | ||
External Energy Usage | ||
(n + 1) * Q * M | ||
''' | ||
nights = 4 | ||
charging_per_night = 100 | ||
return nights * charging_per_night | ||
|
||
@property | ||
def C(self): | ||
''' | ||
Completion Factor | ||
''' | ||
return 1 | ||
|
||
@property | ||
def T(self): | ||
''' | ||
Target Speed Derate | ||
''' | ||
d = 0 | ||
for seg in self.distance_travelled_segments: | ||
d += seg | ||
|
||
return d / self.time_elapsed_mins / 60 | ||
|
||
@property | ||
def P(self): | ||
''' | ||
Practicality Score | ||
''' | ||
return 1 | ||
|
||
def update_variables(self, velocity_profile): | ||
pass | ||
|
||
def get_score(self, velocity_profile): | ||
self.update_variables(velocity_profile) | ||
return self.D / self.E * self.C * self.T * self.P | ||
|
||
def energy_needed(): | ||
# between two points, how much energy do we draw? | ||
# ok so | ||
# minus: | ||
# energy needed to travel this distance * -> energy_used, but only between two points? | ||
car_model = Car() # can add speed limit? | ||
energy_needed = car_model.energy_used() | ||
|
||
# efficiency of motors * (draw more energy than necessary) -> motor eff curves | ||
low_curve = MotorEfficiency("LO") | ||
high_curve = MotorEfficiency("HI") | ||
# TODO what the fuck is this | ||
# so we have speed, it will guess our torque based on test data | ||
power_needed = low_curve.power_draw_needed(energy_needed, speed, torque) | ||
|
||
# efficiency of soc (how much energy is actually taken from batteries) -> soc | ||
power_loss = power_needed * 0.5 | ||
|
||
# auxloss to consider | ||
power_loss += 0.5 | ||
|
||
# plus: energy gained from solar -> from solar | ||
|
||
power_loss -= 0.5 | ||
|
||
return power_loss | ||
|
||
# takeaway from this exercise is that carmodel, lowhigh, and our soc and solar objects can be fairly static? we will need to change the speed limit on the car as we go, which we can do hopefully | ||
# how do we want this to happen wiht df -> either make calls per row, or just change the methods so they accept dfs | ||
|
||
if __name__ == '__main__': | ||
race = ASC_Race(RACE_FILE) | ||
|
||
''' | ||
|
||
lat, lon, city name, city Id, time, temperature, efficiency correction, | ||
wind speed, wind direction, precipitation, energy solar, energy corrected | ||
+ mark stops (checkpoints) somehow | ||
|
||
routemodel | ||
speed limits, lat, lon, elevations | ||
wind | ||
weather?? | ||
|
||
solar | ||
|
||
|
||
soc | ||
?? | ||
auxloss | ||
|
||
motor torque | ||
|
||
dynamics | ||
|
||
''' | ||
|
||
|
||
''' | ||
also, comparison of fmin | ||
+ https://www.mathworks.com/help/optim/ug/fmincon.html | ||
+ https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.minimize.html | ||
|
||
|
||
Parameters | ||
fun(x, *args) -> float ==> get_score() | ||
initial guess ==> even within speed limits? | ||
bounds (for each in x) ==> speed limits | ||
|
||
''' |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
incredibly descriptive and imaginative function names