-
Notifications
You must be signed in to change notification settings - Fork 87
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
Array input arguments in nonlinear expressions #2402
Comments
For vector-outputs, we could potentially do something like this: A = [1 2; 3 4]
x = [MOI.VariableIndex(1), MOI.VariableIndex(2)]
f(x) = sum(A * x)
| i | node_type | parent | value |
| 1 | SCALAR_CALL | -1 | OP_SUM |
| 2 | RESULT_ARRAY | 1 | (2, 0) |
| 3 | RESULT | 2 | NaN |
| 4 | RESULT | 2 | NaN |
| 5 | VECTOR_CALL | 2 | OP_MUL |
| 6 | ARRAY | 5 | (2, 2) |
| 7 | CONSTANT | 6 | 1 |
| 8 | CONSTANT | 6 | 2 |
| 9 | CONSTANT | 6 | 3 |
| 10 | CONSTANT | 6 | 4 |
| 11 | ARRAY | 5 | (2, 0) |
| 12 | VARIABLE | 11 | 1 |
| 13 | VARIABLE | 11 | 2 |
[1.0, 3.0, 2.0, 4.0] @rluce, we could have dropped the That'd simplify things to: | i | node_type | parent | value |
| 1 | CALL | -1 | OP_SUM |
| 2 | RESULT_ARRAY | 1 | (2, 0) |
| 3 | RESULT | 2 | NaN |
| 4 | RESULT | 2 | NaN |
| 5 | CALL | 2 | OP_MUL |
| 6 | ARRAY | 5 | (2, 2) |
| 7 | CONSTANT | 6 | 1.0 |
| 8 | CONSTANT | 6 | 2.0 |
| 9 | CONSTANT | 6 | 3.0 |
| 10 | CONSTANT | 6 | 4.0 |
| 11 | ARRAY | 5 | (2, 0) |
| 12 | VARIABLE | 11 | 1 |
| 13 | VARIABLE | 11 | 2 | |
Gurobi will support array-valued nonlinear expressions and also needs JuMP to compute derivatives? Not sure I understand what the interface is. |
No. They're going to do their own thing, and won't support arrays to start with. But their interface is going to look very similar to the MOI data structure so we were just riffing on some ideas. It'll look something like
|
Correct, no vector in- our output planned for Gurobi, but the concept is very tempting 😄 .
Another option could be to put dimensionality information in the value array, viz.
with the understanding that an |
I guess there are multiple options for the size. It probably doesn't really matter which one you go with, so long as it is consistent. The other option, instead of directly coding
The benefit of this is that you don't need all the |
Context: Yesterday I had a chat to @rluce about nonlinear expressions, particularly as they relate to Gurobi's upcoming nonlinear interface. We broadly agree on scalar nonlinear functions, and he had some preliminary ideas for vector-inputs.
cc @ccoffrin and @chriscoey for thoughts.
Our ultimate goal is to support examples like the following:
Another key consumer of this would be https://github.com/jump-dev/MiniZinc.jl.
Changes required in JuMP
Array
inGenericNonlinearExpr
and their mapping tomoi_function
. This seems pretty easy.Changes required in MOI
Array
inMOI.(Scalar,Vector)NonlinearFunction
. This seems pretty easy.Array
inMOI.Nonlinear
and be able to compute derivatives, etc.The tricky part is all in 2.
We'd likely need some sort of
Node(NODE_VECTOR, parent, n)
.But matrices are a bit more complicated. We'd need to encode
(rows, cols)
. One option would be to store the size as a packedvalue::Int64
. That'd mean that we couldn't have matrices with side dimension greater thantypemax(Int32)
... but that seems okay.norm(x)
would look something like:log_det(X)
would then look something like:Once you have the data structure, it seems to me that the AD should follow fairly well.
Output arguments
Still absolutely no idea.
The text was updated successfully, but these errors were encountered: