Skip to content
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

fix: Fix and upgrade highs_sys to v1.6.2 #142

Merged
merged 1 commit into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 4 additions & 5 deletions pywr-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 12 additions & 0 deletions pywr-core/src/solvers/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down
11 changes: 4 additions & 7 deletions pywr-core/src/solvers/highs/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
///
Expand Down Expand Up @@ -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);
}
}