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

chore: Update dependencies #90

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ exclude = [".github/*", ".vscode/*"]

[dependencies]
csv = "1.2.1"
ndarray = { version = "0.15.6", features = ["rayon"] }
ndarray = { version = "0.16.1", features = ["rayon"] }
serde = "1.0.188"
serde_json = "1.0.66"
sobol_burley = "0.5.0"
ndarray-stats = "0.5.1"
linfa-linalg = "0.1.0"
ndarray-stats = "0.6.0"
linfa-linalg = "0.2.0"
argmin = { version = "0.10.0", features = [] }
argmin-math = { version = "0.4.0", features = ["ndarray_v0_15-nolinalg"] }
tracing = "0.1.40"
Expand All @@ -31,8 +31,8 @@ tracing-subscriber = { version = "0.3.17", features = [
"time",
] }
config = { version = "0.15", features = ["preserve_order"] }
faer = "0.19.3"
faer-ext = { version = "0.2.0", features = ["nalgebra", "ndarray"] }
faer = "0.20.2"
faer-ext = { version = "0.4.1", features = ["nalgebra", "ndarray"] }
pharmsol = "0.7.6"
rand = "0.9.0"
anyhow = "1.0.86"
Expand Down
2 changes: 1 addition & 1 deletion src/routines/evaluation/ipm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ pub fn burke(
let uph = uph.t();
let smuyinv = smu * (&ecol / &y);
let rhsdw = &erow / &w - (psi.dot(&smuyinv));
let a = rhsdw.clone().into_shape((rhsdw.len(), 1))?;
let a = rhsdw.clone().into_shape_with_order((rhsdw.len(), 1))?;

let x = uph
.t()
Expand Down
14 changes: 8 additions & 6 deletions src/routines/evaluation/qr.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
// use faer::{FaerMat, IntoFaer, IntoNdarray};
use faer_ext::*;
use ndarray::parallel::prelude::*;
use ndarray::{Array2, Axis};

use faer::MatRef;

pub fn calculate_r(x: &Array2<f64>) -> (Array2<f64>, Vec<usize>) {
let mut n_x = x.clone();
n_x.axis_iter_mut(Axis(0))
.into_par_iter()
.for_each(|mut row| row /= row.sum());
let mat_x = n_x.view().into_faer();
let qr = mat_x.col_piv_qr();
let r_mat = qr.compute_r();
let mat_x: MatRef<'_, f64> = n_x.view().into_faer();
let qr: faer::sparse::solvers::ColPivQr<f64> = mat_x.col_piv_qr();
let r_mat: faer::Mat<f64> = qr.compute_r();
let (forward, _inverse) = qr.col_permutation().arrays();
let r = r_mat.as_ref().into_ndarray().to_owned();
let perm = Vec::from(forward);
let r: ndarray::ArrayBase<ndarray::OwnedRepr<f64>, ndarray::Dim<[usize; 2]>> =
r_mat.as_ref().into_ndarray().to_owned();
let perm: Vec<usize> = Vec::from(forward);
(r, perm)
}
12 changes: 6 additions & 6 deletions src/routines/optimization/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ pub struct SppOptimizer<'a, E: Equation> {
}

impl<'a, E: Equation> CostFunction for SppOptimizer<'a, E> {
type Param = Array1<f64>;
type Param = Vec<f64>;
type Output = f64;
fn cost(&self, spp: &Self::Param) -> Result<Self::Output, Error> {
let theta = spp.to_owned().insert_axis(Axis(0));
let theta = Array1::from(spp.clone()).insert_axis(Axis(0));

let psi = psi(self.equation, self.data, &theta, self.sig, false, false);

Expand Down Expand Up @@ -53,25 +53,25 @@ impl<'a, E: Equation> SppOptimizer<'a, E> {
}
}
pub fn optimize_point(self, spp: Array1<f64>) -> Result<Array1<f64>, Error> {
let simplex = create_initial_simplex(&spp);
let simplex = create_initial_simplex(&spp.to_vec());
let solver = NelderMead::new(simplex).with_sd_tolerance(1e-2)?;
let res = Executor::new(self, solver)
.configure(|state| state.max_iters(5))
// .add_observer(SlogLogger::term(), ObserverMode::Always)
.run()?;
Ok(res.state.best_param.unwrap())
Ok(Array1::from(res.state.best_param.unwrap()))
}
}

fn create_initial_simplex(initial_point: &Array1<f64>) -> Vec<Array1<f64>> {
fn create_initial_simplex(initial_point: &[f64]) -> Vec<Vec<f64>> {
let num_dimensions = initial_point.len();
let perturbation_percentage = 0.008;

// Initialize a Vec to store the vertices of the simplex
let mut vertices = Vec::new();

// Add the initial point to the vertices
vertices.push(initial_point.to_owned());
vertices.push(initial_point.to_vec());

// Calculate perturbation values for each component
for i in 0..num_dimensions {
Expand Down
Loading