diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 1d5bc7d9..963748d1 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -14,21 +14,21 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - with: - submodules: true + - uses: actions/checkout@v4 + with: + submodules: true - - name: Install latest mdbook - run: | - tag=$(curl 'https://api.github.com/repos/rust-lang/mdbook/releases/latest' | jq -r '.tag_name') - url="https://github.com/rust-lang/mdbook/releases/download/${tag}/mdbook-${tag}-x86_64-unknown-linux-gnu.tar.gz" - mkdir bin - curl -sSL $url | tar -xz --directory=bin - echo "$(pwd)/bin" >> $GITHUB_PATH + - name: Install latest mdbook + run: | + tag=$(curl 'https://api.github.com/repos/rust-lang/mdbook/releases/latest' | jq -r '.tag_name') + url="https://github.com/rust-lang/mdbook/releases/download/${tag}/mdbook-${tag}-x86_64-unknown-linux-gnu.tar.gz" + mkdir bin + curl -sSL $url | tar -xz --directory=bin + echo "$(pwd)/bin" >> $GITHUB_PATH - - name: Build - run: cargo build --verbose --no-default-features - - name: Run tests - run: cargo test --no-default-features - - name: Run mdbook tests - run: mdbook test ./pywr-book + - name: Build + run: cargo build --verbose --no-default-features --features highs + - name: Run tests + run: cargo test --no-default-features --features highs + - name: Run mdbook tests + run: mdbook test ./pywr-book diff --git a/pywr-core/Cargo.toml b/pywr-core/Cargo.toml index 5bd95f1c..0fdc225f 100644 --- a/pywr-core/Cargo.toml +++ b/pywr-core/Cargo.toml @@ -18,20 +18,19 @@ libc = "0.2.97" thiserror = { workspace = true } ndarray = { workspace = true } num = { workspace = true } -float-cmp = { workspace = true } +float-cmp = { workspace = true } hdf5 = { workspace = true } csv = { workspace = true } clp-sys = { path = "../clp-sys", version = "0.1.0" } ipm-ocl = { path = "../ipm-ocl", optional = true } ipm-simd = { path = "../ipm-simd", optional = true } -tracing = { workspace = true } -highs-sys = { git = "https://github.com/jetuk/highs-sys", branch="fix-build-libz-linking", optional = true } -# highs-sys = { path = "../../highs-sys" } +tracing = { workspace = true } +highs-sys = { version = "1.6.2", optional = true } nalgebra = "0.32.3" chrono = { workspace = true } polars = { workspace = true } -pyo3 = { workspace = true, features = ["chrono"] } +pyo3 = { workspace = true, features = ["chrono"] } rayon = "1.6.1" diff --git a/pywr-core/src/solvers/builder.rs b/pywr-core/src/solvers/builder.rs index e644076e..2bdc2715 100644 --- a/pywr-core/src/solvers/builder.rs +++ b/pywr-core/src/solvers/builder.rs @@ -293,6 +293,14 @@ where I::from(self.builder.col_upper.len()).unwrap() } + pub fn num_rows(&self) -> I { + I::from(self.builder.row_upper.len()).unwrap() + } + + pub fn num_non_zero(&self) -> I { + I::from(self.builder.elements.len()).unwrap() + } + pub fn col_lower(&self) -> &[f64] { &self.builder.col_lower } @@ -313,6 +321,10 @@ where &self.builder.row_upper } + pub fn row_mask(&self) -> &[I] { + &self.builder.row_mask + } + pub fn row_starts(&self) -> &[I] { &self.builder.row_starts } diff --git a/pywr-core/src/solvers/highs/settings.rs b/pywr-core/src/solvers/highs/settings.rs index 939bc26f..6f3e01aa 100644 --- a/pywr-core/src/solvers/highs/settings.rs +++ b/pywr-core/src/solvers/highs/settings.rs @@ -39,14 +39,11 @@ impl HighsSolverSettings { /// /// ``` /// use std::num::NonZeroUsize; -/// use pywr::solvers::ClpSolverSettingsBuilder; +/// use pywr_core::solvers::HighsSolverSettingsBuilder; /// // Settings with parallel enabled and 4 threads. -/// let settings = ClpSolverSettingsBuilder::default().parallel().threads(4).build(); -/// -/// let mut builder = ClpSolverSettingsBuilder::default(); -/// builder.chunk_size(NonZeroUsize::new(1024).unwrap()); -/// let settings = builder.build(); +/// let settings = HighsSolverSettingsBuilder::default().parallel().threads(4).build(); /// +/// let mut builder = HighsSolverSettingsBuilder::default(); /// builder.parallel(); /// let settings = builder.build(); /// @@ -97,6 +94,6 @@ mod tests { }; let settings_from_builder = HighsSolverSettingsBuilder::default().parallel().build(); - assert_eq!(settings_from_builder, settings_from_builder); + assert_eq!(settings_from_builder, settings); } }