-
-
Notifications
You must be signed in to change notification settings - Fork 80
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
Unable to compile Nelder-Mead example #115
Comments
Hi, if you are not using |
resulted in "error: linking with
resulted in the same errors I previously posted. |
The first one should be correct, the second one can't work. I have never compiled argmin on windows and I don't have a windows computer available, therefore I can't debug this unfortunately. But since it is a linking error it may be related to linking against a BLAS library or something. Can you compile your code without the argmin dependency/code, just with |
I successfully compiled and ran a minimal example:
without issue. Let me know if there is something else you would like me to try. |
I think you might be missing an external library, but I don't know which. Could you try to compile without the |
Using the following within
and adding |
Thanks a lot for reporting this and your fix! Rust removed the necessity to use |
I'm sorry if I was unclear. I did not find a fix. However, I did find that removing Cargo.toml
main.rs use argmin::prelude::*;
use argmin::solver::neldermead::NelderMead;
use argmin_testfunctions::rosenbrock;
use ndarray::{array, Array1, Array2};
/// First, create a struct for your problem
struct Rosenbrock {
a: f64,
b: f64,
}
/// Implement `ArgminOp` for `Rosenbrock`
impl ArgminOp for Rosenbrock {
type Param = Array1<f64>;
type Output = f64;
type Hessian = Array2<f64>;
type Jacobian = ();
type Float = f64;
fn apply(&self, p: &Self::Param) -> Result<Self::Output, Error> {
Ok(rosenbrock(&p.to_vec(), self.a, self.b))
}
}
fn run() -> Result<(), Error> {
// Define cost function
let cost = Rosenbrock { a: 1.0, b: 100.0 };
// Set up solver -- note that the proper choice of the vertices is very important!
let solver = NelderMead::new()
.with_initial_params(vec![
// array![-2.0, 3.0],
// array![-2.0, -1.0],
// array![2.0, -1.0],
array![-1.0, 3.0],
array![2.0, 1.5],
array![2.0, -1.0],
])
.sd_tolerance(0.0001);
// Run solver
let res = Executor::new(cost, solver, array![])
.add_observer(ArgminSlogLogger::term(), ObserverMode::Always)
.max_iters(100)
.run()?;
// Wait a second (lets the logger flush everything before printing again)
std::thread::sleep(std::time::Duration::from_secs(1));
// Print result
println!("{}", res);
Ok(())
}
fn main() {
if let Err(ref e) = run() {
println!("{}", e);
std::process::exit(1);
}
} Produces the following errors
|
You need the |
I'm sorry. I'm fairly new to Rust and am probably not conveying details in an efficient manner. I was simply stating that, while still having the After adding the If there is anything I can do to weed out the issue and convey the results more efficiently, I am certainly open to criticism. |
I apologize if I sounded rude, that was not my intention. ndarray-linalg = { version = "0.13", features = ["intel-mkl-static"] } # apparently downloads Intel MKL itself, links statically ndarray-linalg = { version = "0.13", features = ["intel-mkl-system"] } # Uses system Intel MKL, links dynamically The best way to check if |
Not at all. I just wanted to be clear about my inexperience so that you could factor that into your troubleshooting. I added to my
and that solved the linker issues, yielding a successful build. May I suggest adding something about this to the readme, under "Usage" for Windows users? Thank you so much for your help and patience. |
Glad that this solved the problem! Thanks for giving all the various ideas a try. I will expand the readme in the near future to avoid this problem in the future. Thanks! |
Note: I had to switch to building with the nightly toolchain because of issues with
ndalgebra v0.26.2
due to "featureresolver
isrequired"I attempted to compile and run the Nelder-Mead example using the following in my
Cargo.toml
:Adding
features = ["serde"]
was added to eliminateSerialize
andDeserialize
errors. Now I am getting the following errors:Let me know if there is any further information I can provide.
The text was updated successfully, but these errors were encountered: