Skip to content

Commit

Permalink
Included files in example folder in respective documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
s-simoncelli committed Jul 28, 2024
1 parent 1520e38 commit 3d22e53
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 22 deletions.
2 changes: 1 addition & 1 deletion optirustic/examples/nsga2_sch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use optirustic::algorithms::{Algorithm, MaxGeneration, NSGA2, NSGA2Arg, Stopping
use optirustic::core::builtin_problems::SCHProblem;
use optirustic::core::Individual;

/// Test the Schaffer’s problem (SCH) where the following 2 objectives are minimised:
/// Solve the Schaffer’s problem (SCH) where the following 2 objectives are minimised:
/// - `f_1(x) = x^2`
/// - `f-2(x) = (x - 2)^2`
/// The problem has 1 variable (`x`) bounded to -0.001 and 0.001. The optional solution is expected
Expand Down
2 changes: 1 addition & 1 deletion optirustic/examples/nsga2_zdt1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use log::LevelFilter;
use optirustic::algorithms::{Algorithm, MaxGeneration, NSGA2, NSGA2Arg, StoppingConditionType};
use optirustic::core::builtin_problems::ZTD1Problem;

/// Test the ZDT1 problem (SCH) where the following 2 objectives are minimised:
/// Solve the ZDT1 problem (SCH) where the following 2 objectives are minimised:
/// - `f_1(x) = x_1`
/// - `f-2(x) = g(x) * [ 1 - sqrt( x_1 / g(x) ) ]`
/// with
Expand Down
10 changes: 10 additions & 0 deletions optirustic/src/algorithms/nsga2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ pub struct NSGA2Arg {
/// > 182-197, April 2002, doi: 10.1109/4235.996017.
///
/// See: <https://doi.org/10.1109/4235.996017>.
///
/// # Examples
/// ## Solve the Schaffer’s problem
/// ```rust
#[doc = include_str!("../../examples/nsga2_sch.rs")]
/// ```
/// ## Solve the ZDT1 problem
/// ```rust
#[doc = include_str!("../../examples/nsga2_zdt1.rs")]
/// ```
pub struct NSGA2 {
/// The number of individuals to use in the population.
number_of_individuals: usize,
Expand Down
22 changes: 2 additions & 20 deletions optirustic/src/utils/reference_points.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,8 @@ fn binomial_coefficient(mut n: u64, k: u64) -> u64 {
/// > 1998 8:3, 631-657. <https://doi.org/10.1137/S1052623496307510>
///
/// # Example
/// ```
/// use optirustic::utils::DasDarren1998;
/// use optirustic::core::OError;
///
/// fn main() -> Result<(), OError> {
/// // Consider the case of a 3D hyperplane with 3 objectives
/// let number_of_objectives = 3;
/// // Each objective axis is split into 5 gaps of equal size.
/// let number_of_partitions = 5;
///
/// let m = DasDarren1998::new(number_of_objectives, number_of_partitions);
/// // This returns the coordinates of the reference points between 0 and 1
/// println!("Total pints = {:?}", m.number_of_points());
///
/// let weights = m.get_weights();
/// println!("Weights = {:?}", weights);
///
/// // Save the charts of points to inspect them
/// m.plot("ref_points_3obj_5gaps.png")
/// }
/// ```rust
#[doc = include_str!("../../examples/reference_points.rs")]
/// ```
pub struct DasDarren1998 {
/// The number of problem objectives.
Expand Down

0 comments on commit 3d22e53

Please sign in to comment.