Skip to content

Commit

Permalink
Indexed arrays for performance and safety (#17)
Browse files Browse the repository at this point in the history
* Fix varnames (no extra tuple)
Remove test Manifest

* Update Readme

* Testing with typed dictionaries for cache

* * Fix performance issue
* Started working on storing legal values

* Convenience constructors and safe_insert!

* Formatting

* Add exports, consistent return from safe_insertvar

* Add tests for IndexedVarArray

* Compatibility fix for julia < 1.8

* Update JuliaFormatter

* Formatting fixes (not using VS Code)

* Formatting

* Improve test coverage

* Fix clear_cache!

* Drop slices compiletime for performance

* Cleanup, delete unused functions + formatting

* Fix corner case for tuple concatenation.
Delete unused function _has_index

* Formatting fix

* Fix indexing on string with slicing

* Switch names of inservar! for IndexedVarArrays
Default to safe insertion

* Cleanup, more informative function name

* Updated benchmarks from talk

* Formatting fixes

* Prep for release

Co-authored-by: Lars Hellemo <[email protected]>
  • Loading branch information
hellemo and hellemo authored Sep 19, 2022
1 parent d2eb9e4 commit 21cf913
Show file tree
Hide file tree
Showing 13 changed files with 3,760 additions and 236 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/format_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
run: |
using Pkg
# If you update the version, also update the style guide docs.
Pkg.add(PackageSpec(name="JuliaFormatter", version="0.22.7"))
Pkg.add(PackageSpec(name="JuliaFormatter", version="1.0.8"))
using JuliaFormatter
format("."; verbose = true)
out = String(read(Cmd(`git diff`)))
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
TimeStructures release notes
===================================

Version 0.6.2 (2022-09-19)
--------------------------
* Add IndexedVarArray that checks for valid indices on insert and has improved performance

Version 0.6.1 (2022-06-29)
--------------------------
* Release under MIT License
Expand Down
5 changes: 3 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
name = "SparseVariables"
uuid = "2749762c-80ed-4b14-8f33-f0736679b02b"
authors = ["Truls Flatberg <[email protected]>", "Lars Hellemo <[email protected]>"]
version = "0.6.1"
version = "0.6.2"

[deps]
Dictionaries = "85a47980-9c8c-11e8-2b9f-f7ca1fa99fb4"
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"

Expand All @@ -14,4 +15,4 @@ Dictionaries = "0.3"
JuMP = "1"
Requires = "1.3"
Tables = "1.7"
julia = "1.6"
julia = "1.6"
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ Watch the JuliaCon/JuMP-dev 2022 lightning talk and check out the [notebook with

[![SparseVariables - Efficient sparse modelling with JuMP](https://img.youtube.com/vi/YuDvfZo9W5A/3.jpg)](https://youtu.be/YuDvfZo9W5A)

2022-09: Updated benchmarks of time spent on model construction with different number of variables (see [benchmark notebook for details](benchmark/benchmark.jl)) with additional types `IndexedVarArray` (model_indexed) and `SparseAxisArray` (model_sparse_aa) on current julia master:

![](benchmark/res.svg)

Benchmarks with time spent on model construction with different level of sparsity:

![](benchmark/sparsity.svg)

## Usage

Expand Down Expand Up @@ -57,6 +64,22 @@ end
@constraint(m, sum(z[endswith("a"), iseven]) >= 1)
```

## IndexedVarArray

Use IndexedVarArrays to check for valid indices and to warn against duplicate
indices, as well as improved performance:

```julia
w = IndexedVarArray(m, "w", (car=cars, year=years))
m[:w] = w

for c in cars, y in years
insertvar!(m, c, y)
end
```



## Solution information

SparseVariables.jl provides `SolutionTable` that supports the [Tables.jl](https://github.com/JuliaData/Tables.jl) interface, allowing
Expand Down
Loading

0 comments on commit 21cf913

Please sign in to comment.