givp/lib.rs
1// SPDX-FileCopyrightText: 2026 Arnaldo Mendes Pires Junior
2// SPDX-License-Identifier: MIT
3
4//! # GIVP — GRASP-ILS-VND with Path Relinking
5//!
6//! A metaheuristic optimizer for continuous and mixed-integer black-box
7//! optimization problems.
8//!
9//! ## Quick start
10//!
11//! ```rust
12//! use givp::{givp, GivpConfig, Direction};
13//!
14//! let sphere = |x: &[f64]| -> f64 { x.iter().map(|v| v * v).sum() };
15//! let bounds: Vec<(f64, f64)> = vec![(-5.12, 5.12); 5];
16//!
17//! let result = givp(sphere, &bounds, GivpConfig::default()).unwrap();
18//! println!("Best: {:.6} at {:?}", result.fun, result.x);
19//! ```
20
21mod cache;
22mod config;
23mod convergence;
24mod elite;
25mod error;
26mod experiment;
27mod grasp;
28mod helpers;
29mod ils;
30mod impl_core;
31mod pr;
32mod result;
33mod vnd;
34
35pub use config::{Direction, GivpConfig};
36pub use error::{GivpError, Result};
37pub use experiment::{seed_sweep, SweepSummary};
38pub use result::{OptimizeResult, TerminationReason};
39
40/// Run the GRASP-ILS-VND with Path Relinking optimizer.
41///
42/// # Arguments
43///
44/// * `func` — Objective function `&[f64] -> f64`.
45/// * `bounds` — Variable bounds as `&[(lower, upper)]`.
46/// * `config` — Algorithm configuration.
47///
48/// # Returns
49///
50/// An [`OptimizeResult`] containing the best solution found.
51pub fn givp<F>(func: F, bounds: &[(f64, f64)], config: GivpConfig) -> Result<OptimizeResult>
52where
53 F: Fn(&[f64]) -> f64 + Send + Sync,
54{
55 impl_core::run(func, bounds, config)
56}