-
-
Notifications
You must be signed in to change notification settings - Fork 401
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
Add documentation on performance and work-around for sparse variable creation #2126
Changes from 2 commits
c2e84a5
f8ef6c9
61e87a5
ccb5f94
e3b0071
fcc93f6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -387,6 +387,12 @@ JuMP.Containers.SparseAxisArray{VariableRef,1,Tuple{Int64}} with 2 entries: | |
[2] = x[2] | ||
``` | ||
|
||
Note that with many indices and large amount of sparcity, variable construction may take more time than expected, as JuMP is effectively iterating over all indices and evaluating the conditional for each combination. The recommended work-around in such cases is to work directly with a list of tuples. For example: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please follow the 80-character limit used in the rest of the documentation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "is effectively iterating" is unnecessarily imprecise, just "iterates" |
||
|
||
```jldoctest; setup=:(model=Model()) | ||
mlubin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
S = [(1,1,1),(10,10,10)] | ||
@variable(model, x[S]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you make an example with both approach and then show that e.g. one has quadratic complexity and the other one has linear complexity? For instance with a condition i == j and n elements for i and j, it will be quadratic complexity vs linear complexity |
||
``` | ||
### [Forcing the container type](@id variable_forcing) | ||
|
||
When creating a container of JuMP variables, JuMP will attempt to choose the | ||
|
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.
sparcity -> sparsity