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

[Nonlinear] add support for univariate sign #2444

Merged
merged 3 commits into from
Feb 27, 2024
Merged

[Nonlinear] add support for univariate sign #2444

merged 3 commits into from
Feb 27, 2024

Conversation

odow
Copy link
Member

@odow odow commented Feb 25, 2024

Closes #2448

I don't know about this one. We might be better off documenting people to write a signpower function at the JuMP level because this still has the problem that sign(x) * abs(x)^p is not defined when x=0 and p < 1.

Thoughts @ccoffrin?

test/Nonlinear/Nonlinear.jl Outdated Show resolved Hide resolved
test/Nonlinear/Nonlinear.jl Outdated Show resolved Hide resolved
@ccoffrin
Copy link

My hot take.

There may be other uses of sign we cannot anticipate, which don't have such an obvious work around.
If the following conditions are met,

  1. Adding support for a new function does not add a major burden (e.g., in maintenance)
  2. It is a very common built-in Julia function (ideally also part of C standard functions)
  3. there have been multiple request for support (i.e., users want it)

Then I think it is good to add support for it.

I hear your point that this will likely lead to a bunch of non-ideal modeling choices by non-experts. However, that issue is not limited to this specific new feature. I don't think there is an easy work around for helping typical users model better. Current state of the art is basically to get a PhD in NLP to understand how to write better models.

@odow
Copy link
Member Author

odow commented Feb 26, 2024

sign meets your criteria for 1, 2, and 3.

It's probably the currently unsupported operator that I see most often.

And we already support min, max, ifelse, and abs, so non-differentiatbility isn't an argument against adding.

@mlubin should weigh in before we decide to merge.

Copy link
Member

@blegat blegat left a comment

Choose a reason for hiding this comment

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

I agree with @ccoffrin 's comment

@odow odow merged commit 4be42b4 into master Feb 27, 2024
16 checks passed
@odow odow deleted the od/sign branch February 27, 2024 02:53
@odow odow mentioned this pull request Feb 27, 2024
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Add support for nonlinear sign(x)
4 participants