Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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
24 changes: 0 additions & 24 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[workspace]
members = ["ezpz-cli", 'ezpz-wasm', 'fuzz', 'kcl-ezpz', 'newtonls-faer']
members = ["ezpz-cli", 'ezpz-wasm', 'fuzz', 'kcl-ezpz']
resolver = "3"

[profile.dev.package]
faer = { opt-level = 3 }

[profile.bench]
debug = true
debug = "full"
3 changes: 2 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ gen := "test_cases/massive_parallel_system/gen_big_problem.py"

lint:
cargo clippy {{clippy-flags}} -- -D warnings
cargo clippy {{clippy-flags}} --features dbg-jac -- -D warnings

# Fix some lints automatically.
lint-fix:
Expand All @@ -30,7 +31,7 @@ test-with-coverage:

# Flamegraph our benchmarks
flamegraph:
cargo flamegraph -p --root --bench solver_bench
cargo flamegraph -p kcl-ezpz --bench solver_bench

# Run benchmarks
bench:
Expand Down
2 changes: 1 addition & 1 deletion kcl-ezpz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ license = "MIT"

[features]
fuzz = ["dep:arbitrary"]
dbg-jac = []

[dependencies]
arbitrary = { version = "1.4.2", features = ["derive"], optional = true }
faer = { version = "0.23.2", default-features = false, features = ["std", "sparse-linalg"] }
getrandom = { version = "0.2.16", features = ["js"] }
indexmap = "2.11.0"
libm = "0.2.15"
newtonls_faer = { version = "0.1.3", path = "../newtonls-faer" }
thiserror = "2.0.14"
winnow = { version = "0.7.13" }

Expand Down
2 changes: 0 additions & 2 deletions kcl-ezpz/benches/solver_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use kcl_ezpz::{
solve_with_priority,
textual::Problem,
};
use newton_faer::init_global_parallelism;

/// General benchmark template.
/// Opens a given test case from the test_cases/ dir,
Expand Down Expand Up @@ -59,7 +58,6 @@ fn solve_perpendicular(c: &mut Criterion) {
/// depend on each other.
fn solve_two_rectangles_dependent(c: &mut Criterion) {
let mut id_generator = IdGenerator::default();
init_global_parallelism(1);
let p0 = DatumPoint::new(&mut id_generator);
let p1 = DatumPoint::new(&mut id_generator);
let p2 = DatumPoint::new(&mut id_generator);
Expand Down
25 changes: 18 additions & 7 deletions kcl-ezpz/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ pub use crate::solver::Config;
// or find a different way to structure modules.
pub use crate::id::{Id, IdGenerator};
use crate::solver::Model;
use faer::sparse::CreationError;
use faer::sparse::linalg::LuError;
use faer::sparse::{CreationError, FaerError};
pub use warnings::{Warning, WarningContent};

mod constraint_request;
Expand Down Expand Up @@ -67,6 +68,20 @@ pub enum NonLinearSystemError {
#[from]
error: CreationError,
},
#[error("Something went wrong in faer: {error}")]
Faer {
#[from]
error: FaerError,
},
#[error("Something went wrong doing matrix solves in faer: {error}")]
FaerSolve {
#[from]
error: LuError,
},
#[error("Could not find a solution in the allowed number of iterations")]
DidNotConverge,
#[error("Cannot solve an empty system")]
EmptySystemNotAllowed,
}

#[derive(Debug)]
Expand Down Expand Up @@ -240,18 +255,14 @@ fn solve_inner(
}
};

let mut newton_faer_config = newton_faer::NewtonCfg::sparse().with_adaptive(true);
newton_faer_config.max_iter = config.max_iterations;

let mut unsatisfied: Vec<usize> = Vec::new();
let outcome = newton_faer::solve(&mut model, &mut values, newton_faer_config)
.map_err(|errs| Error::Solver(Box::new(errs.into_error())));
let outcome = model.run_newtons_method(&mut values, config);
warnings.extend(model.warnings.lock().unwrap().drain(..));
let iterations = match outcome {
Ok(o) => o,
Err(e) => {
return Err(FailureOutcome {
error: e,
error: e.into(),
warnings,
num_vars,
num_eqs,
Expand Down
Loading