Skip to content

tunnels and train length added#10

Open
Roli15 wants to merge 20 commits into
dkouzoup:mainfrom
Roli15:main
Open

tunnels and train length added#10
Roli15 wants to merge 20 commits into
dkouzoup:mainfrom
Roli15:main

Conversation

@Roli15
Copy link
Copy Markdown

@Roli15 Roli15 commented May 25, 2026

No description provided.

Copy link
Copy Markdown
Owner

@dkouzoup dkouzoup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread ocp.py Outdated
# 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)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Comment thread track.py
Comment thread track.py Outdated

if not self.crossSectionsOk():

raise ValueError("Issue with track cross sections!")
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe "Issue with tunnel cross sections!"?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

Comment thread track.py Outdated

self.tunnels.drop(columns=["Length [m]"], inplace=True)

self.crossSections = self.tunnels
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this assignment and deletion seems unnecessary, why not calling it crossSections from the start?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed reassignment

Comment thread track.py Outdated
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)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use a different name because openTrack is a known software tool and might be misleading at first glance

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

called it nonTunnelSections_df

Comment thread train.py Outdated
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]
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I corrected the units

Comment thread train.py

tApprox = model.states[0]

epsVelSq = 0.0001
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, let's please discuss this one. I just noticed that you introduced also fmax operator.

Comment thread train.py
Comment thread utils.py Outdated

def computeTunnelFactor(cross_section, train):

if cross_section == 0:
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, you are right, should be inf

Comment thread utils.py
num_of_remaining_points = numIntervals + 1 - len(requiredPoints)
m = 1 # number of points to oversample

while True:
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting implementation, perhaps it could be extended to guarantee a minimum space interval?

],
[
2000.0,
Infinity,
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use "infinity" (incl. the quotes) as defined in TTOBench

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(unless there is a strong reason against it, in that case we'd need to update TTOBench instead)

Comment thread trains/Flirt_Tpf.json
@@ -0,0 +1,96 @@
{
"metadata": {
"id": "CH_Stadler_FLIRT_TPF",
Copy link
Copy Markdown
Owner

@dkouzoup dkouzoup May 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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):
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably this should not be in the trainLengthDependentTrackAttributes directory?


plt.show()

def testAllIntegratorTypesWork(self):
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need this twice?

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
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the patern "solve the same OCP, roughly same consumption" can be improved in tests like this. We can discuss it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants