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

Issue #961, solve_for outputting wrong answers when function is nonlinear. #1101

Closed
wants to merge 5 commits into from

Conversation

n0rbed
Copy link
Member

@n0rbed n0rbed commented Mar 23, 2024

The linear_expansion() function sees x*y ~ 0 as linear due to looping over the lhs variable by variable, while observing the other variables as a constant. For example, when observing the x variable it sees its coefficient as a constant y, not as another variable. As such, it outputs a wrong bool (true). This hinders with the accuracy of the solve_for function as seen in issue #961.

In order to mitigate this, isaffine can be used since it provides more accurate results, and an error message is thrown when the equation given is nonlinear since solve_for does not currently have the capabilities to solve the equations given in issue #961.

@codecov-commenter
Copy link

codecov-commenter commented Mar 24, 2024

Codecov Report

Attention: Patch coverage is 90.00000% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 76.60%. Comparing base (79c4e92) to head (4514152).
Report is 136 commits behind head on master.

Files Patch % Lines
src/linear_algebra.jl 90.00% 1 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1101      +/-   ##
==========================================
- Coverage   77.07%   76.60%   -0.47%     
==========================================
  Files          32       35       +3     
  Lines        3533     3693     +160     
==========================================
+ Hits         2723     2829     +106     
- Misses        810      864      +54     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ChrisRackauckas
Copy link
Member

Tests fail

@n0rbed
Copy link
Member Author

n0rbed commented Mar 24, 2024

Tests fail

I'll take a look at it asap.

Comment on lines +103 to +107
for eqᵢ in eq
try
islinear &= Symbolics.isaffine(eqᵢ.lhs-eqᵢ.rhs, var)
catch e
end
Copy link
Member

Choose a reason for hiding this comment

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

Instead of try/catch, the root issue should be handled.

Copy link
Member Author

Choose a reason for hiding this comment

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

agreed. this is just a temporary fix. Want me to open an issue on the failed tests for isaffine?

Copy link
Member

Choose a reason for hiding this comment

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

yes please

Copy link
Member Author

Choose a reason for hiding this comment

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

done, the current PR temporarily solves issue #961 and passes all the CI tests (i think the integration tests will fail nontheless, correct me if i'm wrong)

@n0rbed n0rbed closed this Aug 30, 2024
@n0rbed n0rbed deleted the solve_for_issue branch August 30, 2024 12:02
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.

3 participants