As stated above: I wish to compute the minimum (and/or maximum) of a continuous variable over time. Here is a minimal example to demonstrate:
model MinMaxTes
For your initial question, what seems to work correctly for me in OpenModelica is this:
u_min = min(u, pre(u_min));
u_max = max(u, pre(u_max));
For me that compiles, simulates, and gives the expected results, but also does say "Matrix singular!". On the other hand, if I change the initial declaration for u_max to this:
Real u_max(start = 0);
Then, the "Matrix singular!" goes away.
I don't know why, but that does seems to do the job, and I would suggest is more straightforward then the other options you have listed.