argmin-rs / argmin

Numerical optimization in pure Rust
http://argmin-rs.org
Apache License 2.0
992 stars 78 forks source link

Is `ParticleSwarm` currently not functional ? #503

Closed avhz closed 2 months ago

avhz commented 2 months ago

I tried to use ParticleSwarm in a project but ran into some errors. I figured it was my fault so tried to run the repo's example, but got the same errors. For example:

error[E0277]: the trait bound `Vec<{float}>: argmin_math::ArgminSub<Vec<{float}>, Vec<{float}>>` is not satisfied
  --> examples/ps.rs:41:37
   |
41 |     let solver = ParticleSwarm::new((vec![-4.0, -4.0], vec![4.0, 4.0]), 40);
   |                  ------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `argmin_math::ArgminSub<Vec<{float}>, Vec<{float}>>` is not implemented for `Vec<{float}>`
   |                  |
   |                  required by a bound introduced by this call
   |
   = help: the following other types implement trait `argmin_math::ArgminSub<T, U>`:
             <f32 as argmin_math::ArgminSub<f32, f32>>
             <f64 as argmin_math::ArgminSub<f64, f64>>
             <i16 as argmin_math::ArgminSub<i16, i16>>
             <i32 as argmin_math::ArgminSub<i32, i32>>
             <i64 as argmin_math::ArgminSub<i64, i64>>
             <i8 as argmin_math::ArgminSub<i8, i8>>
             <num_complex::Complex<f32> as argmin_math::ArgminSub<num_complex::Complex<f32>, num_complex::Complex<f32>>>
             <num_complex::Complex<f64> as argmin_math::ArgminSub<num_complex::Complex<f64>, num_complex::Complex<f64>>>
           and 12 others
note: required by a bound in `ParticleSwarm::<P, F, rand::rngs::std::StdRng>::new`
stefan-k commented 2 months ago

Have you added argmin_math with the vec backend to your cargo.toml?

Here is some information about it: book and docs

avhz commented 2 months ago

Ah sorry I missed that in the docs, my bad. Thank you !