-
-
Notifications
You must be signed in to change notification settings - Fork 398
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
DNMY: allow array in nonlinear expressions #3451
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #3451 +/- ##
==========================================
- Coverage 98.09% 97.87% -0.22%
==========================================
Files 37 37
Lines 5501 5418 -83
==========================================
- Hits 5396 5303 -93
- Misses 105 115 +10
☔ View full report in Codecov by Sentry. |
Some things need to be worked through:
One thing to keep in mind is that we no longer parse One option that @chriscoey and I discussed is that something like |
Why would they need to do that ? The function we overload are going to fail anyway so we might as well add them in the expression tree and we'll let the solver throw an error if it does not support what it is getting.
DCP would be in MOI so we can do like:
What do you mean by "traced" ?
Yes, we would need to define functions. When they get numbers they return a number but if they get JuMP expressions, they return an
But then if someone calls |
I just worry that we're going to end in a situation where it's not obvious what functions can be used with which solver. I'd view DCP as a exploratory research project. It's not obvious that the first approach will be the right one. |
Still not sure what you mean. Could you give an example ? Is this a concern for a function that could be written in a more elementary form ? For example, |
How does the user find out what functions they can call for DCP?
I did not assume this. To begin with, it should be a JuMP extension or an MOI solver.
Evaluating the function returns the symbolic expression. If
I think it's easier to keep all the DCP atoms in a strict namespace, rather than playing the game of overloading various methods from different places. |
My takeaway is that this is a research question. Not a solved problem requiring an implementation. |
They read the doc or get an error. That's the current status of JuMP's AD as well.
Then type piracy to begin with
I guess
This can start as a separate repo if we want to start having something easier to play around than an pair of open PRs in JuMP and MOI. |
Yes please. |
087674b
to
1788385
Compare
src/nlp_expr.jl
Outdated
@@ -506,6 +510,8 @@ function moi_function(f::GenericNonlinearExpr{V}) where {V} | |||
for i in length(f.args):-1:1 | |||
if f.args[i] isa GenericNonlinearExpr{V} | |||
push!(stack, (ret, i, f.args[i])) | |||
elseif arg.args[i] isa AbstractArray | |||
child.args[i] = moi_function.(arg.args[i]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
child.args[i] = moi_function.(arg.args[i]) | |
ret.args[i] = moi_function.(arg.args[i]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we instead just define
moi_function(x::AbstractArray) = moi_function.(x)
jump_function(x::AbstractArray) = jump_function.(x)
You could implement this as a pirated method in DCP.jl to begin with.
I updated the PR. The scope is not to overload |
I'm not in favor of merging this until we have DCP.jl mocked up end-to-end. I'd like to know what the alternatives are. One option is for DCP.jl to use a separate type entirely to begin with. They don't need to (mis)use Supporting vectors in nonlinear expressions is not something we should rush into, even if it's something we eventually want to support. The only thing that might need implementing in JuMP is |
This requires changing how the |
Closing in favor of #3489 |
This PR is a proof of concept to show the possibility of storing arrays in the JuMP nonlinear expression and MOI nonlinear function.
Of course, it won't work with the AD but it can be supported by a solver or by a Disciplined Convex Programming transformation.