Skip to content
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

Avoid values of baseY less than 0.001 #67

Merged
merged 2 commits into from
Sep 15, 2024

Conversation

casella
Copy link
Collaborator

@casella casella commented Aug 9, 2024

This change considers a minimum range of Y reference values of 0.001, to avoid false negatives when handling near-zero values that are the result of balance equations affected by small numerical errors. 0.001 is a reasonable compromise, since the nominal attribute (which would be better) is not available in CSV result files.

@maltelenz
Copy link

This seems to indicate that the SetFormerBaseAndRatio choice actually means something very specific. Maybe it shouldn't be modified, and a new type of ratio should be added instead? Alternatively, modify the name and description of what this one means.

/// <param name="formerBaseAndRatio">Base and Ratio are calculated like in the former CSV-Compare, if true;<para>

@casella
Copy link
Collaborator Author

casella commented Sep 10, 2024

@maltelenz I'm not sure I understand the point of your last comment. According to the analysis by @beutlich, this is the function that is actually called to compute the parameters of the tolerance tubes. If we don't change that function, the tubes will remain too tight for near-zero variables.

As I said during the meeting, our current goal is not to restructure or refactor the CSV-compare source code, that would just take forever. Our immediate goal is just to avoid too narrow tubes when the variables are very close to zero when doing the current regression testing. Nothing more, nothing less. To my understanding, PR #66 just does that. Do you agree?

@maltelenz
Copy link

As I said during the meeting, our current goal is not to restructure or refactor the CSV-compare source code, that would just take forever.

One can try to make clean updates in the code that keeps the code understandable, or pay the ever increasing price of getting an increasingly unreadable code mess, making future understanding and fixes harder.

Of course, sometimes it may be worth it to make a quick hack, and ignore future work and cost.

Our immediate goal is just to avoid too narrow tubes when the variables are very close to zero. To my understanding, PR #66 just does that. Do you agree?

I don't know, I haven't spent the time to understand and test the change.

@casella
Copy link
Collaborator Author

casella commented Sep 10, 2024

One can try to make clean updates in the code that keeps the code understandable, or pay the ever increasing price of getting an increasingly unreadable code mess, making future understanding and fixes harder.

Of course, sometimes it may be worth it to make a quick hack, and ignore future work and cost.

This update simply swaps an epsilon of 1e-12 with an epsilon of 1e-3, which is more appropriate. I can't see how this could cause any future extra work or cost. Conversely, if we don't do this, we're stuck forever with regressions of the MSL 4.1.0. We need to move on with that.

@maltelenz
Copy link

maltelenz commented Sep 10, 2024

I can't see how this could cause any future extra work or cost.

The line of code I quoted in my first comment, says what the FormerBaseAndRatio is intended to do.
This PR changes that behavior, but doesn't change the description. That means that the behavior of the code will deviate from the described behavior of the code. To me, this sounds like the next person that comes and reads the code will get the wrong impression of what is going on.

Conversely, if we don't do this, we're stuck forever with regressions of the MSL 4.1.0. We need to move on with that.

I'm not against changing things, I just thought I could share what I found about the FormerBaseAndRatio while quickly browsing the code. There seems to be some confusion about what it means already in this PR and the linked issue.

@casella
Copy link
Collaborator Author

casella commented Sep 10, 2024

I did some more analysis. The functions which calls either SetFormerBaseAndRatio() or SetStandardBaseAndRatio() are the constructors of TubeSize:

public TubeSize(Curve reference)
{
this.reference = reference;
SetStandardBaseAndRatio();
successful = false;
}

public TubeSize(Curve reference, bool formerBaseAndRatio)
{
this.reference = reference;
if (formerBaseAndRatio)
SetFormerBaseAndRatio();
else
SetStandardBaseAndRatio();
successful = false;
}

I searched the entire code base for calls to such constructors, and I only found two of them, one here:

TubeSize size = new TubeSize(refCurve);

and one here

size = new TubeSize(reference, true);

The first constructor calls SetStandardBaseAndRatio(), the second constructor is only called with formerBaseAndRatio=true, so it only calls SetFormerBaseAndRatio(). To play safe, we can tweak both functions, just in case. I've updated the PR accordingly

@casella
Copy link
Collaborator Author

casella commented Sep 10, 2024

@sjoelund, @beutlich during today's MAP-LIB meeting there was agreement to go on with this change, so that @GallLeo can run the regression testing without false negative.

Unfortunately, nobody in the (virtual) room had write access to the repo. Can you please merge this PR onto master?

Thanks!

Copy link
Collaborator

@beutlich beutlich left a comment

Choose a reason for hiding this comment

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

@casella Thanks for the PR. Let me know if you are happy with my refactoring applied on top of your initial commit.

@beutlich
Copy link
Collaborator

The first constructor calls SetStandardBaseAndRatio(), the second constructor is only called with formerBaseAndRatio=true, so it only calls SetFormerBaseAndRatio().

CurveCompare/CurveCompare.cs itself seems nowhere referenced. See #69.

@casella
Copy link
Collaborator Author

casella commented Sep 11, 2024

@casella Thanks for the PR. Let me know if you are happy with my refactoring applied on top of your initial commit.

LGTM. Please merge it onto master

@beutlich beutlich merged commit 7251f4c into modelica-tools:master Sep 15, 2024
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.

Set a reasonable absolute tolerance to avoid spurious negatives for close-to-zero signals
4 participants