fcmaes-rust 0.2.0__tar.gz → 0.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {fcmaes_rust-0.2.0 → fcmaes_rust-0.2.1}/Cargo.lock +9 -9
- {fcmaes_rust-0.2.0 → fcmaes_rust-0.2.1}/Cargo.toml +3 -3
- {fcmaes_rust-0.2.0 → fcmaes_rust-0.2.1}/PKG-INFO +1 -1
- {fcmaes_rust-0.2.0 → fcmaes_rust-0.2.1}/crates/fcmaes-core/src/biteopt.rs +1 -1
- {fcmaes_rust-0.2.0 → fcmaes_rust-0.2.1}/crates/fcmaes-core/src/cmaes.rs +4 -2
- {fcmaes_rust-0.2.0 → fcmaes_rust-0.2.1}/crates/fcmaes-core/src/crfmnes.rs +4 -2
- {fcmaes_rust-0.2.0 → fcmaes_rust-0.2.1}/crates/fcmaes-core/src/da.rs +98 -10
- {fcmaes_rust-0.2.0 → fcmaes_rust-0.2.1}/crates/fcmaes-core/src/de.rs +12 -2
- {fcmaes_rust-0.2.0 → fcmaes_rust-0.2.1}/crates/fcmaes-core/src/pgpe.rs +4 -2
- fcmaes_rust-0.2.1/crates/fcmaes-py/python_tests/test_binding_contract.py +427 -0
- {fcmaes_rust-0.2.0 → fcmaes_rust-0.2.1}/crates/fcmaes-py/src/acma.rs +57 -24
- {fcmaes_rust-0.2.0 → fcmaes_rust-0.2.1}/crates/fcmaes-py/src/biteopt.rs +24 -16
- fcmaes_rust-0.2.1/crates/fcmaes-py/src/common.rs +285 -0
- {fcmaes_rust-0.2.0 → fcmaes_rust-0.2.1}/crates/fcmaes-py/src/crfmnes.rs +66 -27
- fcmaes_rust-0.2.1/crates/fcmaes-py/src/da.rs +78 -0
- {fcmaes_rust-0.2.0 → fcmaes_rust-0.2.1}/crates/fcmaes-py/src/de.rs +61 -25
- {fcmaes_rust-0.2.0 → fcmaes_rust-0.2.1}/crates/fcmaes-py/src/gtop.rs +5 -6
- {fcmaes_rust-0.2.0 → fcmaes_rust-0.2.1}/crates/fcmaes-py/src/mapelites.rs +38 -15
- {fcmaes_rust-0.2.0 → fcmaes_rust-0.2.1}/crates/fcmaes-py/src/mode.rs +8 -12
- {fcmaes_rust-0.2.0 → fcmaes_rust-0.2.1}/crates/fcmaes-py/src/moretry.rs +50 -25
- {fcmaes_rust-0.2.0 → fcmaes_rust-0.2.1}/crates/fcmaes-py/src/pgpe.rs +70 -29
- {fcmaes_rust-0.2.0 → fcmaes_rust-0.2.1}/crates/fcmaes-py/src/retry.rs +5 -5
- {fcmaes_rust-0.2.0 → fcmaes_rust-0.2.1}/python/fcmaes_rust/_fcmaes_ext.pyi +32 -9
- fcmaes_rust-0.2.0/crates/fcmaes-py/src/common.rs +0 -91
- fcmaes_rust-0.2.0/crates/fcmaes-py/src/da.rs +0 -64
- {fcmaes_rust-0.2.0 → fcmaes_rust-0.2.1}/LICENSE +0 -0
- {fcmaes_rust-0.2.0 → fcmaes_rust-0.2.1}/crates/fcmaes-core/Cargo.toml +0 -0
- {fcmaes_rust-0.2.0 → fcmaes_rust-0.2.1}/crates/fcmaes-core/LICENSE +0 -0
- {fcmaes_rust-0.2.0 → fcmaes_rust-0.2.1}/crates/fcmaes-core/NOTICE.pareto +0 -0
- {fcmaes_rust-0.2.0 → fcmaes_rust-0.2.1}/crates/fcmaes-core/PARETO_ARCHIVE.md +0 -0
- {fcmaes_rust-0.2.0 → fcmaes_rust-0.2.1}/crates/fcmaes-core/README.md +0 -0
- {fcmaes_rust-0.2.0 → fcmaes_rust-0.2.1}/crates/fcmaes-core/examples/pareto_bench.rs +0 -0
- {fcmaes_rust-0.2.0 → fcmaes_rust-0.2.1}/crates/fcmaes-core/examples/pareto_mode.rs +0 -0
- {fcmaes_rust-0.2.0 → fcmaes_rust-0.2.1}/crates/fcmaes-core/src/fitness.rs +0 -0
- {fcmaes_rust-0.2.0 → fcmaes_rust-0.2.1}/crates/fcmaes-core/src/indicators.rs +0 -0
- {fcmaes_rust-0.2.0 → fcmaes_rust-0.2.1}/crates/fcmaes-core/src/lib.rs +0 -0
- {fcmaes_rust-0.2.0 → fcmaes_rust-0.2.1}/crates/fcmaes-core/src/mapelites.rs +0 -0
- {fcmaes_rust-0.2.0 → fcmaes_rust-0.2.1}/crates/fcmaes-core/src/mode.rs +0 -0
- {fcmaes_rust-0.2.0 → fcmaes_rust-0.2.1}/crates/fcmaes-core/src/moretry.rs +0 -0
- {fcmaes_rust-0.2.0 → fcmaes_rust-0.2.1}/crates/fcmaes-core/src/pareto.rs +0 -0
- {fcmaes_rust-0.2.0 → fcmaes_rust-0.2.1}/crates/fcmaes-core/src/pareto_tests.rs +0 -0
- {fcmaes_rust-0.2.0 → fcmaes_rust-0.2.1}/crates/fcmaes-core/src/retry.rs +0 -0
- {fcmaes_rust-0.2.0 → fcmaes_rust-0.2.1}/crates/fcmaes-core/src/rng.rs +0 -0
- {fcmaes_rust-0.2.0 → fcmaes_rust-0.2.1}/crates/fcmaes-core/tests/data/pareto_archive_2d.csv +0 -0
- {fcmaes_rust-0.2.0 → fcmaes_rust-0.2.1}/crates/fcmaes-core/tests/pareto_fixture.rs +0 -0
- {fcmaes_rust-0.2.0 → fcmaes_rust-0.2.1}/crates/fcmaes-gtop/Cargo.toml +0 -0
- {fcmaes_rust-0.2.0 → fcmaes_rust-0.2.1}/crates/fcmaes-gtop/src/lib.rs +0 -0
- {fcmaes_rust-0.2.0 → fcmaes_rust-0.2.1}/crates/fcmaes-py/Cargo.toml +0 -0
- {fcmaes_rust-0.2.0 → fcmaes_rust-0.2.1}/crates/fcmaes-py/python_tests/test_bindings.py +0 -0
- {fcmaes_rust-0.2.0 → fcmaes_rust-0.2.1}/crates/fcmaes-py/python_tests/test_type_stubs.py +0 -0
- {fcmaes_rust-0.2.0 → fcmaes_rust-0.2.1}/crates/fcmaes-py/src/lib.rs +0 -0
- {fcmaes_rust-0.2.0 → fcmaes_rust-0.2.1}/pyproject.toml +0 -0
- {fcmaes_rust-0.2.0 → fcmaes_rust-0.2.1}/python/README.md +0 -0
- {fcmaes_rust-0.2.0 → fcmaes_rust-0.2.1}/python/fcmaes_rust/__init__.py +0 -0
- {fcmaes_rust-0.2.0 → fcmaes_rust-0.2.1}/python/fcmaes_rust/py.typed +0 -0
|
@@ -433,7 +433,7 @@ checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223"
|
|
|
433
433
|
|
|
434
434
|
[[package]]
|
|
435
435
|
name = "fcmaes-core"
|
|
436
|
-
version = "0.2.
|
|
436
|
+
version = "0.2.1"
|
|
437
437
|
dependencies = [
|
|
438
438
|
"libm",
|
|
439
439
|
"nalgebra",
|
|
@@ -445,7 +445,7 @@ dependencies = [
|
|
|
445
445
|
|
|
446
446
|
[[package]]
|
|
447
447
|
name = "fcmaes-examples"
|
|
448
|
-
version = "0.2.
|
|
448
|
+
version = "0.2.1"
|
|
449
449
|
dependencies = [
|
|
450
450
|
"fcmaes-core",
|
|
451
451
|
"fcmaes-gtop",
|
|
@@ -457,11 +457,11 @@ dependencies = [
|
|
|
457
457
|
|
|
458
458
|
[[package]]
|
|
459
459
|
name = "fcmaes-gtop"
|
|
460
|
-
version = "0.2.
|
|
460
|
+
version = "0.2.1"
|
|
461
461
|
|
|
462
462
|
[[package]]
|
|
463
463
|
name = "fcmaes-job-worker"
|
|
464
|
-
version = "0.2.
|
|
464
|
+
version = "0.2.1"
|
|
465
465
|
dependencies = [
|
|
466
466
|
"fcmaes-core",
|
|
467
467
|
"fcmaes-native-worker",
|
|
@@ -487,7 +487,7 @@ dependencies = [
|
|
|
487
487
|
|
|
488
488
|
[[package]]
|
|
489
489
|
name = "fcmaes-py"
|
|
490
|
-
version = "0.2.
|
|
490
|
+
version = "0.2.1"
|
|
491
491
|
dependencies = [
|
|
492
492
|
"fcmaes-core",
|
|
493
493
|
"fcmaes-gtop",
|
|
@@ -1148,8 +1148,8 @@ checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe"
|
|
|
1148
1148
|
|
|
1149
1149
|
[[package]]
|
|
1150
1150
|
name = "optimization-job-api"
|
|
1151
|
-
version = "0.
|
|
1152
|
-
source = "git+https://github.com/dietmarwo/optimization-jobs?rev=
|
|
1151
|
+
version = "0.3.0"
|
|
1152
|
+
source = "git+https://github.com/dietmarwo/optimization-jobs?rev=37b30e428c5fdd017975e0093cc261243148257f#37b30e428c5fdd017975e0093cc261243148257f"
|
|
1153
1153
|
dependencies = [
|
|
1154
1154
|
"fs2",
|
|
1155
1155
|
"libc",
|
|
@@ -1160,8 +1160,8 @@ dependencies = [
|
|
|
1160
1160
|
|
|
1161
1161
|
[[package]]
|
|
1162
1162
|
name = "optimization-runner"
|
|
1163
|
-
version = "0.
|
|
1164
|
-
source = "git+https://github.com/dietmarwo/optimization-jobs?rev=
|
|
1163
|
+
version = "0.3.0"
|
|
1164
|
+
source = "git+https://github.com/dietmarwo/optimization-jobs?rev=37b30e428c5fdd017975e0093cc261243148257f#37b30e428c5fdd017975e0093cc261243148257f"
|
|
1165
1165
|
dependencies = [
|
|
1166
1166
|
"clap",
|
|
1167
1167
|
"fs2",
|
|
@@ -7,7 +7,7 @@ codegen-units = 1
|
|
|
7
7
|
lto = "thin"
|
|
8
8
|
|
|
9
9
|
[workspace.package]
|
|
10
|
-
version = "0.2.
|
|
10
|
+
version = "0.2.1"
|
|
11
11
|
edition = "2024"
|
|
12
12
|
rust-version = "1.88"
|
|
13
13
|
license = "MIT"
|
|
@@ -20,8 +20,8 @@ fcmaes-core = { path = "crates/fcmaes-core" }
|
|
|
20
20
|
fcmaes-gtop = { path = "crates/fcmaes-gtop" }
|
|
21
21
|
# The shared job API (envelope, result contract, worker SDK, runner) lives in
|
|
22
22
|
# github.com/dietmarwo/optimization-jobs; change the revision there first.
|
|
23
|
-
optimization-job-api = { git = "https://github.com/dietmarwo/optimization-jobs", rev = "
|
|
24
|
-
optimization-runner = { git = "https://github.com/dietmarwo/optimization-jobs", rev = "
|
|
23
|
+
optimization-job-api = { git = "https://github.com/dietmarwo/optimization-jobs", rev = "37b30e428c5fdd017975e0093cc261243148257f" }
|
|
24
|
+
optimization-runner = { git = "https://github.com/dietmarwo/optimization-jobs", rev = "37b30e428c5fdd017975e0093cc261243148257f" }
|
|
25
25
|
|
|
26
26
|
# The runner and its workers hash their staged executables (tens of MB in
|
|
27
27
|
# debug builds) on every job start; unoptimized SHA-256 made debug start-up
|
|
@@ -120,7 +120,7 @@ pub struct BiteResult {
|
|
|
120
120
|
pub x: Vec<f64>,
|
|
121
121
|
/// Objective value at [`x`](Self::x).
|
|
122
122
|
pub y: f64,
|
|
123
|
-
///
|
|
123
|
+
/// Objective evaluations actually made; never more than `max_evaluations`.
|
|
124
124
|
pub evaluations: u64,
|
|
125
125
|
/// Number of candidates incorporated into the optimizer state.
|
|
126
126
|
pub iterations: i32,
|
|
@@ -43,7 +43,7 @@ pub struct AcmaResult {
|
|
|
43
43
|
pub x: Vec<f64>,
|
|
44
44
|
/// Objective value at [`x`](Self::x).
|
|
45
45
|
pub y: f64,
|
|
46
|
-
///
|
|
46
|
+
/// Objective evaluations actually made (see `max_evaluations`).
|
|
47
47
|
pub evaluations: u64,
|
|
48
48
|
/// Number of completed generations.
|
|
49
49
|
pub iterations: i32,
|
|
@@ -58,7 +58,9 @@ pub struct CmaesParams {
|
|
|
58
58
|
pub popsize: i32,
|
|
59
59
|
/// Number of selected parents; non-positive values use half the population.
|
|
60
60
|
pub mu: i32,
|
|
61
|
-
///
|
|
61
|
+
/// Evaluation budget, checked before each generation: whole generations
|
|
62
|
+
/// are evaluated, so a run can make up to `popsize - 1` more evaluations.
|
|
63
|
+
/// The result's `evaluations` field reports the actual count.
|
|
62
64
|
pub max_evaluations: u64,
|
|
63
65
|
/// Scale applied to numerical termination tolerances.
|
|
64
66
|
pub accuracy: f64,
|
|
@@ -47,7 +47,7 @@ pub struct CrfmnesResult {
|
|
|
47
47
|
pub x: Vec<f64>,
|
|
48
48
|
/// Objective value at [`x`](Self::x).
|
|
49
49
|
pub y: f64,
|
|
50
|
-
///
|
|
50
|
+
/// Objective evaluations actually made (see `max_evaluations`).
|
|
51
51
|
pub evaluations: u64,
|
|
52
52
|
/// Number of completed generations.
|
|
53
53
|
pub iterations: i32,
|
|
@@ -60,7 +60,9 @@ pub struct CrfmnesResult {
|
|
|
60
60
|
pub struct CrfmnesParams {
|
|
61
61
|
/// Population size; values below two are raised to two.
|
|
62
62
|
pub popsize: i32,
|
|
63
|
-
///
|
|
63
|
+
/// Evaluation budget, checked before each generation: whole generations
|
|
64
|
+
/// are evaluated, so a run can make up to `popsize - 1` more evaluations.
|
|
65
|
+
/// The result's `evaluations` field reports the actual count.
|
|
64
66
|
pub max_evaluations: u64,
|
|
65
67
|
/// Stop after finding an objective value strictly below this threshold.
|
|
66
68
|
pub stop_fitness: f64,
|
|
@@ -40,22 +40,27 @@ use crate::rng::Rng;
|
|
|
40
40
|
/// Outcome of a Dual Annealing run.
|
|
41
41
|
#[derive(Clone, Debug)]
|
|
42
42
|
pub struct DaResult {
|
|
43
|
-
/// Best decoded decision vector found.
|
|
43
|
+
/// Best decoded decision vector found. When no start point was accepted
|
|
44
|
+
/// (`stop == -1`), the best point evaluated, or the last point tried if
|
|
45
|
+
/// every value was NaN or `+inf`.
|
|
44
46
|
pub x: Vec<f64>,
|
|
45
|
-
/// Objective value at [`x`](Self::x).
|
|
47
|
+
/// Objective value at [`x`](Self::x); `f64::MAX` if it was NaN.
|
|
46
48
|
pub y: f64,
|
|
47
|
-
///
|
|
49
|
+
/// Objective evaluations actually made; never more than
|
|
50
|
+
/// [`DaParams::max_evaluations`].
|
|
48
51
|
pub evaluations: u64,
|
|
49
52
|
/// Reserved iteration counter; currently zero.
|
|
50
53
|
pub iterations: i32,
|
|
51
|
-
/// Termination code; `-1`
|
|
54
|
+
/// Termination code; `-1` means no start point with a value below `1e16`
|
|
55
|
+
/// was found within 1,000 attempts or the evaluation budget.
|
|
52
56
|
pub stop: i32,
|
|
53
57
|
}
|
|
54
58
|
|
|
55
59
|
/// Tunable inputs for [`optimize_da`].
|
|
56
60
|
#[derive(Clone, Debug)]
|
|
57
61
|
pub struct DaParams {
|
|
58
|
-
/// Maximum number of global and local objective evaluations combined
|
|
62
|
+
/// Maximum number of global and local objective evaluations combined,
|
|
63
|
+
/// including the attempts to find a start point; `0` selects 10,000,000.
|
|
59
64
|
pub max_evaluations: u64,
|
|
60
65
|
/// Enable the projected limited-memory local-search phase.
|
|
61
66
|
pub use_local_search: bool,
|
|
@@ -307,6 +312,9 @@ impl<'a, O: Objective> Da<'a, O> {
|
|
|
307
312
|
loop {
|
|
308
313
|
self.current_energy = self.value(&self.current_location.clone());
|
|
309
314
|
if self.current_energy >= BIG_VALUE || self.current_energy.is_nan() {
|
|
315
|
+
if self.max_eval_reached() {
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
310
318
|
if reinit_counter >= MAX_REINIT_COUNT {
|
|
311
319
|
self.reinit_failed = true;
|
|
312
320
|
return;
|
|
@@ -567,7 +575,7 @@ impl<'a, O: Objective> Da<'a, O> {
|
|
|
567
575
|
}
|
|
568
576
|
if temperature < TEMPERATURE_RESTART {
|
|
569
577
|
self.reset_energy(&[]);
|
|
570
|
-
if self.reinit_failed {
|
|
578
|
+
if self.reinit_failed || self.max_eval_reached() {
|
|
571
579
|
return;
|
|
572
580
|
}
|
|
573
581
|
break;
|
|
@@ -592,15 +600,36 @@ impl<'a, O: Objective> Da<'a, O> {
|
|
|
592
600
|
self.emin = self.current_energy;
|
|
593
601
|
self.xmin = self.current_location.clone();
|
|
594
602
|
self.not_improved_max_idx = 1000;
|
|
595
|
-
if !self.reinit_failed {
|
|
603
|
+
if !self.reinit_failed && !self.max_eval_reached() {
|
|
596
604
|
self.search();
|
|
597
605
|
}
|
|
606
|
+
let started = !self.xbest.is_empty();
|
|
607
|
+
let (x, y) = if started {
|
|
608
|
+
(self.decode(&self.xbest), self.ebest)
|
|
609
|
+
} else if !self.fit_best_x.is_empty() {
|
|
610
|
+
// No start point below BIG_VALUE: report the best point evaluated.
|
|
611
|
+
let x = self.closest_feasible(&self.fit_best_x);
|
|
612
|
+
(self.decode(&x), self.fit_best_y)
|
|
613
|
+
} else {
|
|
614
|
+
// Every value was NaN or +inf: report the last point tried.
|
|
615
|
+
let x = self.closest_feasible(&self.current_location);
|
|
616
|
+
let y = if self.current_energy.is_nan() {
|
|
617
|
+
f64::MAX
|
|
618
|
+
} else {
|
|
619
|
+
self.current_energy
|
|
620
|
+
};
|
|
621
|
+
(self.decode(&x), y)
|
|
622
|
+
};
|
|
598
623
|
DaResult {
|
|
599
|
-
x
|
|
600
|
-
y
|
|
624
|
+
x,
|
|
625
|
+
y,
|
|
601
626
|
evaluations: self.eval_counter,
|
|
602
627
|
iterations: 0,
|
|
603
|
-
stop: if self.reinit_failed
|
|
628
|
+
stop: if self.reinit_failed || !started {
|
|
629
|
+
-1
|
|
630
|
+
} else {
|
|
631
|
+
0
|
|
632
|
+
},
|
|
604
633
|
}
|
|
605
634
|
}
|
|
606
635
|
}
|
|
@@ -701,6 +730,65 @@ mod tests {
|
|
|
701
730
|
assert!(result.evaluations > 1_000);
|
|
702
731
|
}
|
|
703
732
|
|
|
733
|
+
#[test]
|
|
734
|
+
fn bounded_objective_without_start_point_returns_evaluated_point() {
|
|
735
|
+
// Every value is at or above BIG_VALUE (a large penalty, +inf, NaN):
|
|
736
|
+
// no start point is accepted. The run must not panic, must keep to the
|
|
737
|
+
// budget and must report a point inside the box that was evaluated.
|
|
738
|
+
for (value, expected_y) in [
|
|
739
|
+
(1e300, 1e300),
|
|
740
|
+
(f64::INFINITY, f64::INFINITY),
|
|
741
|
+
(f64::NAN, f64::MAX),
|
|
742
|
+
] {
|
|
743
|
+
let objective = move |_: &[f64]| value;
|
|
744
|
+
for max_evaluations in [60, 5_000] {
|
|
745
|
+
let result = optimize_da(
|
|
746
|
+
&objective,
|
|
747
|
+
&[0.5, 0.5],
|
|
748
|
+
vec![-1.0, 0.0],
|
|
749
|
+
vec![1.0, 2.0],
|
|
750
|
+
&DaParams {
|
|
751
|
+
max_evaluations,
|
|
752
|
+
use_local_search: true,
|
|
753
|
+
seed: 7,
|
|
754
|
+
runid: 0,
|
|
755
|
+
},
|
|
756
|
+
);
|
|
757
|
+
assert_eq!(result.stop, -1);
|
|
758
|
+
assert_eq!(result.y, expected_y);
|
|
759
|
+
assert!(result.evaluations <= max_evaluations);
|
|
760
|
+
assert_eq!(result.x.len(), 2);
|
|
761
|
+
assert!((-1.0..=1.0).contains(&result.x[0]) && (0.0..=2.0).contains(&result.x[1]));
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
#[test]
|
|
767
|
+
fn budget_bounds_start_point_search() {
|
|
768
|
+
let calls = std::sync::atomic::AtomicU64::new(0);
|
|
769
|
+
let objective = |x: &[f64]| {
|
|
770
|
+
calls.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
|
|
771
|
+
if x[0] > 0.9 { x[0] } else { 1e20 }
|
|
772
|
+
};
|
|
773
|
+
let result = optimize_da(
|
|
774
|
+
&objective,
|
|
775
|
+
&[0.0],
|
|
776
|
+
vec![0.0],
|
|
777
|
+
vec![1.0],
|
|
778
|
+
&DaParams {
|
|
779
|
+
max_evaluations: 200,
|
|
780
|
+
use_local_search: false,
|
|
781
|
+
seed: 3,
|
|
782
|
+
runid: 0,
|
|
783
|
+
},
|
|
784
|
+
);
|
|
785
|
+
assert!(result.evaluations <= 200);
|
|
786
|
+
assert_eq!(
|
|
787
|
+
result.evaluations,
|
|
788
|
+
calls.load(std::sync::atomic::Ordering::Relaxed)
|
|
789
|
+
);
|
|
790
|
+
}
|
|
791
|
+
|
|
704
792
|
#[test]
|
|
705
793
|
fn finite_difference_handles_both_box_boundaries() {
|
|
706
794
|
let objective = sphere as fn(&[f64]) -> f64;
|
|
@@ -44,7 +44,9 @@ pub struct DeResult {
|
|
|
44
44
|
pub x: Vec<f64>,
|
|
45
45
|
/// Objective value at [`x`](Self::x).
|
|
46
46
|
pub y: f64,
|
|
47
|
-
///
|
|
47
|
+
/// Objective evaluations actually made; the serial
|
|
48
|
+
/// [`optimize`](De::optimize) can exceed [`DeParams::max_evaluations`]
|
|
49
|
+
/// (see there).
|
|
48
50
|
pub evaluations: u64,
|
|
49
51
|
/// Number of completed generations.
|
|
50
52
|
pub iterations: i32,
|
|
@@ -57,7 +59,11 @@ pub struct DeResult {
|
|
|
57
59
|
pub struct DeParams {
|
|
58
60
|
/// Population size; non-positive values select the dimension-dependent default.
|
|
59
61
|
pub popsize: i32,
|
|
60
|
-
///
|
|
62
|
+
/// Evaluation budget. [`optimize_delayed`](De::optimize_delayed) never
|
|
63
|
+
/// exceeds it. The serial [`optimize`](De::optimize) checks it before each
|
|
64
|
+
/// generation, and a generation costs one or two evaluations per member,
|
|
65
|
+
/// so a run can make up to `2 * popsize - 1` more evaluations;
|
|
66
|
+
/// [`DeResult::evaluations`] reports the actual count.
|
|
61
67
|
pub max_evaluations: u64,
|
|
62
68
|
/// Expected lifetime controlling age-based population reinitialization.
|
|
63
69
|
pub keep: f64,
|
|
@@ -454,6 +460,10 @@ impl De {
|
|
|
454
460
|
}
|
|
455
461
|
|
|
456
462
|
/// Run the serial generational loop against an in-process objective.
|
|
463
|
+
///
|
|
464
|
+
/// The budget is checked before each generation, so the run can overshoot
|
|
465
|
+
/// [`DeParams::max_evaluations`] by up to `2 * popsize - 1` evaluations;
|
|
466
|
+
/// use [`optimize_delayed`](De::optimize_delayed) for an exact limit.
|
|
457
467
|
pub fn optimize(&mut self, obj: &impl Objective) -> DeResult {
|
|
458
468
|
self.iterations = 1;
|
|
459
469
|
self.fitfun.reset_evaluations();
|
|
@@ -44,7 +44,7 @@ pub struct PgpeResult {
|
|
|
44
44
|
pub x: Vec<f64>,
|
|
45
45
|
/// Objective value at [`x`](Self::x).
|
|
46
46
|
pub y: f64,
|
|
47
|
-
///
|
|
47
|
+
/// Objective evaluations actually made (see `max_evaluations`).
|
|
48
48
|
pub evaluations: u64,
|
|
49
49
|
/// Number of completed distribution updates.
|
|
50
50
|
pub iterations: i32,
|
|
@@ -57,7 +57,9 @@ pub struct PgpeResult {
|
|
|
57
57
|
pub struct PgpeParams {
|
|
58
58
|
/// Population size; the implementation rounds odd values up for mirrored pairs.
|
|
59
59
|
pub popsize: i32,
|
|
60
|
-
///
|
|
60
|
+
/// Evaluation budget, checked before each generation: whole generations
|
|
61
|
+
/// are evaluated, so a run can make up to `popsize - 1` more evaluations.
|
|
62
|
+
/// The result's `evaluations` field reports the actual count.
|
|
61
63
|
pub max_evaluations: u64,
|
|
62
64
|
/// Stop after finding an objective value strictly below this threshold.
|
|
63
65
|
pub stop_fitness: f64,
|