-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #116 from oxfordcontrol/develop
v0.9.0
- Loading branch information
Showing
36 changed files
with
1,110 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "clarabel" | ||
version = "0.8.1" | ||
version = "0.9.0" | ||
authors = ["Paul Goulart <[email protected]>"] | ||
edition = "2021" | ||
rust-version = "1.66" | ||
|
@@ -29,6 +29,10 @@ itertools = "0.11" | |
# ------------------------------- | ||
|
||
[features] | ||
default = ["serde"] | ||
|
||
# enable reading / writing of problems from json files | ||
serde = ["dep:serde", "dep:serde_json"] | ||
|
||
# enables blas/lapack for SDP support, with blas/lapack src unspecified | ||
# also enable packages required for chordal decomposition | ||
|
@@ -41,15 +45,20 @@ sdp-openblas = ["sdp", "blas-src/openblas", "lapack-src/openblas"] | |
sdp-mkl = ["sdp", "blas-src/intel-mkl", "lapack-src/intel-mkl"] | ||
sdp-r = ["sdp", "blas-src/r", "lapack-src/r"] | ||
|
||
|
||
# build as the julia interface | ||
julia = ["sdp", "dep:libc", "dep:num-derive", "dep:serde", "dep:serde_json"] | ||
julia = ["sdp", "dep:libc", "dep:num-derive", "serde", "faer-sparse"] | ||
|
||
# build as the python interface via maturin. | ||
# NB: python builds use scipy shared libraries | ||
# for blas/lapack, and should *not* explicitly | ||
# enable a blas/lapack source package | ||
python = ["sdp", "dep:libc", "dep:pyo3", "dep:num-derive"] | ||
python = ["sdp", "dep:libc", "dep:pyo3", "dep:num-derive", "serde", "faer-sparse"] | ||
|
||
wasm = ["dep:web-time"] | ||
|
||
#compile with faer supernodal solver option | ||
faer-sparse = ["dep:faer", "dep:faer-entity"] | ||
|
||
# ------------------------------- | ||
# SDP configuration | ||
|
@@ -75,6 +84,14 @@ optional = true | |
version = "2.2" | ||
optional = true | ||
|
||
[dependencies.faer] | ||
version = "0.19" | ||
optional = true | ||
|
||
[dependencies.faer-entity] | ||
version = "0.19" | ||
optional = true | ||
|
||
|
||
# ------------------------------- | ||
# examples | ||
|
@@ -109,6 +126,18 @@ name = "sdp" | |
path = "examples/rust/example_sdp.rs" | ||
required-features = ["sdp"] | ||
|
||
[[example]] | ||
name = "box_faer" | ||
path = "examples/rust/example_box_faer.rs" | ||
required-features = ["faer-sparse"] | ||
|
||
[[example]] | ||
name = "json" | ||
path = "examples/rust/example_json.rs" | ||
required-features = ["serde"] | ||
|
||
|
||
|
||
|
||
# ------------------------------- | ||
# custom build profiles | ||
|
@@ -162,3 +191,17 @@ crate-type = ["lib","cdylib"] | |
rustdoc-args = [ "--html-in-header", "./html/rustdocs-header.html" ] | ||
features = ["sdp","sdp-mkl"] | ||
|
||
# ------------------------------ | ||
# wasm compatibility | ||
# ------------------------------ | ||
|
||
[dependencies.web-time] | ||
optional = true | ||
version = "0.2.3" | ||
|
||
# ------------------------------ | ||
# testing, benchmarking etc | ||
# ------------------------------ | ||
[dev-dependencies] | ||
tempfile = "3" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"P":{"m":3,"n":3,"colptr":[0,1,3,5],"rowval":[0,0,1,0,2],"nzval":[4.000000000000001,2.0000000000000004,4.000000000000001,2.0,2.0]},"q":[-8.0,-6.0,-4.0],"A":{"m":4,"n":3,"colptr":[0,2,4,6],"rowval":[0,1,0,2,0,3],"nzval":[1.0,-1.0,1.0,-1.0,2.0,-1.0]},"b":[3.0,0.0,0.0,0.0],"cones":[{"NonnegativeConeT":4}],"settings":{"max_iter":200,"time_limit":1.7976931348623157e308,"verbose":true,"max_step_fraction":0.99,"tol_gap_abs":1e-8,"tol_gap_rel":1e-8,"tol_feas":1e-8,"tol_infeas_abs":1e-8,"tol_infeas_rel":1e-8,"tol_ktratio":1e-6,"reduced_tol_gap_abs":0.00005,"reduced_tol_gap_rel":0.00005,"reduced_tol_feas":0.0001,"reduced_tol_infeas_abs":0.00005,"reduced_tol_infeas_rel":0.00005,"reduced_tol_ktratio":0.0001,"equilibrate_enable":true,"equilibrate_max_iter":10,"equilibrate_min_scaling":0.0001,"equilibrate_max_scaling":10000.0,"linesearch_backtrack_step":0.8,"min_switch_step_length":0.1,"min_terminate_step_length":0.0001,"direct_kkt_solver":true,"direct_solve_method":"qdldl","static_regularization_enable":true,"static_regularization_constant":1e-8,"static_regularization_proportional":4.930380657631324e-32,"dynamic_regularization_enable":true,"dynamic_regularization_eps":1e-13,"dynamic_regularization_delta":2e-7,"iterative_refinement_enable":true,"iterative_refinement_reltol":1e-13,"iterative_refinement_abstol":1e-12,"iterative_refinement_max_iter":10,"iterative_refinement_stop_ratio":5.0,"presolve_enable":true,"chordal_decomposition_enable":true,"chordal_decomposition_merge_method":"clique_graph","chordal_decomposition_compact":true,"chordal_decomposition_complete_dual":true}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import clarabel | ||
import os | ||
|
||
thisdir = os.path.dirname(__file__) | ||
filename = os.path.join(thisdir, "../data/hs35.json") | ||
print(filename) | ||
|
||
# Load problem data from JSON file | ||
solver = clarabel.read_from_file(filename) | ||
solution = solver.solve() | ||
|
||
# export problem data to JSON file | ||
# filename = os.path.join(thisdir, "../data/out.json") | ||
# solver.write_to_file(filename) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#![allow(non_snake_case)] | ||
use clarabel::algebra::*; | ||
use clarabel::solver::*; | ||
|
||
fn problem_data() -> (CscMatrix<f64>, Vec<f64>, CscMatrix<f64>, Vec<f64>) { | ||
let n = 2000000; | ||
|
||
let P = CscMatrix::identity(n); | ||
|
||
// construct A = [I; -I] | ||
let I1 = CscMatrix::<f64>::identity(n); | ||
let mut I2 = CscMatrix::<f64>::identity(n); | ||
I2.negate(); | ||
|
||
let A = CscMatrix::vcat(&I1, &I2); | ||
|
||
let q = vec![1.; n]; | ||
let b = vec![1.; 2 * n]; | ||
|
||
(P, q, A, b) | ||
} | ||
|
||
fn main() { | ||
let (P, q, A, b) = problem_data(); | ||
|
||
let cones = [NonnegativeConeT(b.len())]; | ||
|
||
let settings = DefaultSettingsBuilder::default() | ||
.direct_solve_method("faer".to_owned()) | ||
.equilibrate_enable(true) | ||
.max_iter(50) | ||
.verbose(true) | ||
.build() | ||
.unwrap(); | ||
|
||
let mut solver = DefaultSolver::new(&P, &q, &A, &b, &cones, settings); | ||
|
||
solver.solve(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#![allow(non_snake_case)] | ||
use clarabel::solver::*; | ||
use std::fs::File; | ||
|
||
fn main() { | ||
// HS35 is a small problem QP problem | ||
// from the Maros-Meszaros test set | ||
|
||
let filename = "./examples/data/hs35.json"; | ||
let mut file = File::open(filename).unwrap(); | ||
let mut solver = DefaultSolver::<f64>::read_from_file(&mut file).unwrap(); | ||
solver.solve(); | ||
|
||
// to write the back to a new file | ||
|
||
// let outfile = "./examples/data/output.json"; | ||
// let mut file = File::create(outfile).unwrap(); | ||
// solver.write_to_file(&mut file).unwrap(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.