♻️🍱 config, cli, vanth, vanth_derive, varo: Reformatted code and added editor configuration files
- Added `.zed/settings.json` to configure rust-analyzer with `leptosfmt`. - Created `rustfmt.toml` with max width 120 and comment wrapping settings. - Applied consistent formatting across all modified crates using rustfmt. - Reorganized import statements and improved code style in multiple modules.
This commit is contained in:
parent
87957bfbf8
commit
9e7979931c
15 changed files with 141 additions and 161 deletions
|
@ -1,24 +1,24 @@
|
|||
use varo::{optimize, Rng, Score, Varo};
|
||||
use varo::{Rng, Score, Varo, optimize};
|
||||
|
||||
#[test]
|
||||
fn test_optimize() {
|
||||
struct Foo {
|
||||
x: f32,
|
||||
}
|
||||
|
||||
|
||||
impl Varo for Foo {
|
||||
fn next(digest: &mut varo::Rng) -> Self {
|
||||
let x = varo::rng_gen_f32(digest) * 10.0;
|
||||
Foo { x }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fn evaluate(foo: Foo) -> Score {
|
||||
let x = foo.x;
|
||||
let score = -0.9 * x.powi(3) + 2.6 * x.powi(2) - 4.0 * x;
|
||||
score.into()
|
||||
}
|
||||
|
||||
|
||||
let mut rng = varo::rng_new();
|
||||
let optimization_result = optimize(evaluate, &mut rng, 10);
|
||||
assert_eq!(optimization_result.values.len(), 10);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue