tunnels and train length added#10
Conversation
# Conflicts: # train.py
dkouzoup
left a comment
There was a problem hiding this comment.
Thanks for the great work! I think this is a good point in time to add a small unit testing framework in python to ensure that all functionality works as expected and that old functionality was not affected. I suggest you start with something small (add a 'tests' directory and some first unit tests to test results with train length) and we can work incrementally from there.
| # NOTE: good idea vel0 to be compatible with f0 (power-wise) to avoid nans at first iteration | ||
|
|
||
| vel0 = (60/3.6)**2 | ||
| vel_avg = (self.points.index[-1]-self.points.index[0])/(terminalTime-initialTime) |
There was a problem hiding this comment.
I understand that this may be a smarter initialization but we should make sure that we do not break any of the paper simulation scripts. I would suggest once this MR is ready to run all the simulations generating the paper figures once again locally (it's fine if the results change slightly)
|
|
||
| if not self.crossSectionsOk(): | ||
|
|
||
| raise ValueError("Issue with track cross sections!") |
There was a problem hiding this comment.
maybe "Issue with tunnel cross sections!"?
|
|
||
| self.tunnels.drop(columns=["Length [m]"], inplace=True) | ||
|
|
||
| self.crossSections = self.tunnels |
There was a problem hiding this comment.
this assignment and deletion seems unnecessary, why not calling it crossSections from the start?
| if not any(abs((p - e)) < 0.1 for p in positions) | ||
| ] | ||
|
|
||
| openTrack_df = pd.DataFrame({"Length [m]": 0.0, "CrossSection [m^2]": float("inf")}, index=endOfTunnelPositions) |
There was a problem hiding this comment.
I would use a different name because openTrack is a known software tool and might be misleading at first glance
| curvature = ca.MX.sym('curvature') | ||
| gradient = ca.MX.sym('gradient') # [-] -> values between [0,0.2] | ||
| gradientLinearTerm = ca.MX.sym('gradientLinearTerm') # [1/m] | ||
| curvature = ca.MX.sym('curvature') # [1/m] -> values between [0,0.004] |
There was a problem hiding this comment.
Is there maybe a typo in some of the units here? I see that 1/m for gradient linear term becomes 1 after multiplying with position, but I would expect that the curvatureLinearTerm to have a different unit in that case
|
|
||
| tApprox = model.states[0] | ||
|
|
||
| epsVelSq = 0.0001 |
There was a problem hiding this comment.
I see that structurally we need to change the code to compensate for the new state, but can you explain why we need this tolerance now?
There was a problem hiding this comment.
I had the problem, that without the max operator IPOPT ran into negative values during probing. We can have a closer look at it together
There was a problem hiding this comment.
Yes, let's please discuss this one. I just noticed that you introduced also fmax operator.
|
|
||
| def computeTunnelFactor(cross_section, train): | ||
|
|
||
| if cross_section == 0: |
There was a problem hiding this comment.
I thought before you were using the convention that inf means open track? I would say inf or None are more suitable than 0 for no tunnel.
There was a problem hiding this comment.
yes, you are right, should be inf
| num_of_remaining_points = numIntervals + 1 - len(requiredPoints) | ||
| m = 1 # number of points to oversample | ||
|
|
||
| while True: |
There was a problem hiding this comment.
interesting implementation, perhaps it could be extended to guarantee a minimum space interval?
| ], | ||
| [ | ||
| 2000.0, | ||
| Infinity, |
There was a problem hiding this comment.
Please use "infinity" (incl. the quotes) as defined in TTOBench
There was a problem hiding this comment.
(unless there is a strong reason against it, in that case we'd need to update TTOBench instead)
| @@ -0,0 +1,96 @@ | |||
| { | |||
| "metadata": { | |||
| "id": "CH_Stadler_FLIRT_TPF", | |||
There was a problem hiding this comment.
just a detail: please use CH_Stadler_FLIRT_TPF also in filename (capitals) to be consistent with TTOBench and with file metadata
|
|
||
| plt.show() | ||
|
|
||
| def testAllIntegratorTypesWork(self): |
There was a problem hiding this comment.
probably this should not be in the trainLengthDependentTrackAttributes directory?
|
|
||
| plt.show() | ||
|
|
||
| def testAllIntegratorTypesWork(self): |
| Track with 20 permil increase from 1000 m to 2000 m and 20 permil | ||
| decrease from 3000 m to 4000 m. | ||
|
|
||
| Energy consumption should be roughly equal if computed using piecewise |
There was a problem hiding this comment.
I think the patern "solve the same OCP, roughly same consumption" can be improved in tests like this. We can discuss it.
No description provided.