-
Notifications
You must be signed in to change notification settings - Fork 5
Packaging #9
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
base: main
Are you sure you want to change the base?
Packaging #9
Changes from all commits
5383fbe
9d901ee
e5ee6cb
64a94ed
0aefa93
8386a47
f1bd991
9176bde
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| from mseetc.train import Train | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please revert this change and place this code back in ocp.py, as this re-structuring is not relevant for the PR. |
||
| from mseetc.track import Track | ||
| from mseetc.ms.ocp import casadiSolver | ||
|
|
||
| if __name__ == '__main__': | ||
|
|
||
|
|
||
| # Example on how to solve an OCP | ||
|
|
||
| train = Train(config={'id':'NL_Intercity_VIRM6', 'max deceleration':None, 'max acceleration':{'unit':'m/s^2', 'value':0.45}}, pathJSON='../trains') | ||
|
|
||
| track = Track(config={'id':'00_var_speed_limit_100'}, pathJSON='../tracks') | ||
|
|
||
| opts = {'numIntervals':200, 'integrationMethod':'RK', 'integrationOptions':{'numApproxSteps':1}, 'energyOptimal':True} | ||
|
|
||
| solver = casadiSolver(train, track, opts) | ||
|
|
||
| df, stats = solver.solve(1541) | ||
|
|
||
| # print some info | ||
| if df is not None: | ||
|
|
||
| print("") | ||
| print("Objective value = {:.2f} {}".format(stats['Cost'], 'kWh' if solver.opts.energyOptimal else 's')) | ||
| print("") | ||
| print("Maximum acceleration: {:5.2f}, with bound {}".format(df.max()['Acceleration [m/s^2]'], train.accMax if train.accMax is not None else 'None')) | ||
| print("Maximum deceleration: {:5.2f}, with bound {}".format(df.min()['Acceleration [m/s^2]'], train.accMin if train.accMin is not None else 'None')) | ||
|
|
||
| else: | ||
|
|
||
| print("Solver failed!") | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,3 @@ | ||
|
|
||
| def dataLosses(): | ||
|
|
||
| configA = { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,11 +2,11 @@ | |
| import pandas as pd | ||
| import casadi as ca | ||
|
|
||
| from train import * | ||
| from ..train import * | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would - for now - undo the nested |
||
|
|
||
| from track import computeDiscretizationPoints | ||
| from ..track import computeDiscretizationPoints | ||
|
|
||
| from utils import Options, var, postProcessDataFrame, splitLosses | ||
| from ..utils import Options, var, postProcessDataFrame, splitLosses | ||
|
|
||
|
|
||
| class OptionsCasadiSolver(Options): | ||
|
|
@@ -407,34 +407,3 @@ def solve(self, terminalTime, initialTime=0, terminalVelocity=1, initialVelocity | |
| df = postProcessDataFrame(df, self.points, self.train) | ||
|
|
||
| return df, stats | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
|
|
||
| from train import Train | ||
| from track import Track | ||
|
|
||
| # Example on how to solve an OCP | ||
|
|
||
| train = Train(config={'id':'NL_intercity_VIRM6', 'max deceleration':None, 'max acceleration':{'unit':'m/s^2', 'value':0.45}}) | ||
|
|
||
| track = Track(config={'id':'00_var_speed_limit_100'}) | ||
|
|
||
| opts = {'numIntervals':200, 'integrationMethod':'RK', 'integrationOptions':{'numApproxSteps':1}, 'energyOptimal':True} | ||
|
|
||
| solver = casadiSolver(train, track, opts) | ||
|
|
||
| df, stats = solver.solve(1541) | ||
|
|
||
| # print some info | ||
| if df is not None: | ||
|
|
||
| print("") | ||
| print("Objective value = {:.2f} {}".format(stats['Cost'], 'kWh' if solver.opts.energyOptimal else 's')) | ||
| print("") | ||
| print("Maximum acceleration: {:5.2f}, with bound {}".format(df.max()['Acceleration [m/s^2]'], train.accMax if train.accMax is not None else 'None')) | ||
| print("Maximum deceleration: {:5.2f}, with bound {}".format(df.min()['Acceleration [m/s^2]'], train.accMin if train.accMin is not None else 'None')) | ||
|
|
||
| else: | ||
|
|
||
| print("Solver failed!") | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| from setuptools import setup, find_packages | ||
|
|
||
| setup( | ||
| name='mseetc', | ||
| version='0.0.1', | ||
| url='https://github.com/dkouzoup/ms-eetc.git', | ||
| author='Dimitris Kouzoupis', | ||
| description='Multiple shooting for computationally \ | ||
| efficient train trajectory optimization', | ||
| packages=find_packages(), | ||
| install_requires=['numpy == 1.22.2', 'pandas == 1.4.0', \ | ||
| 'casadi==3.6.3', 'matplotlib==3.5.1', 'progressbar2'], | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,12 @@ | ||
| import sys | ||
| sys.path.append('..') | ||
|
|
||
| import json | ||
|
|
||
| import matplotlib.pyplot as plt | ||
|
|
||
| from ocp import casadiSolver | ||
| from train import Train | ||
| from track import Track | ||
| from utils import latexify, show, saveFig, postProcessDataFrame | ||
| from efficiency import totalLossesFunction | ||
| from mseetc.ms.ocp import casadiSolver | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| from mseetc.train import Train | ||
| from mseetc.track import Track | ||
| from mseetc.utils import latexify, show, saveFig, postProcessDataFrame | ||
| from mseetc.efficiency import totalLossesFunction | ||
|
|
||
|
|
||
| def plot(df0b_list, df1b_list, df2b_list, tp, figSize=None, filename=None): | ||
|
|
||
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.
Not "dependencies" any more. I would say "Install package" (please also double-check that we indicate the right directory to run the command from).