Minimum Finder
1.0
Find the minimum of one multi-dimss function
Loading...
Searching...
No Matches
structs.h
Go to the documentation of this file.
1
/*
2
@Author: Gilbert Young
3
@Time: 2024/09/19 08:56
4
@File_name: structs.h
5
@Description:
6
Header file containing the definitions of data structures used in the optimization algorithms:
7
1. Individual: structure to store coordinates and fitness for the Genetic Algorithm.
8
2. DefaultParameters: structure for default parameters for all algorithms.
9
3. Result: structure to store the optimization results.
10
*/
11
12
#ifndef STRUCTS_H
13
#define STRUCTS_H
14
15
#include <vector>
16
17
// Structure to store coordinates and fitness for Genetic Algorithm
18
struct
Individual
19
{
20
double
x
;
21
double
y
;
22
double
fitness
;
23
24
// Constructor for easier initialization
25
Individual
(
double
x_val = 0,
double
y_val = 0) :
x
(x_val),
y
(y_val),
fitness
(0) {}
26
};
27
28
// Structure for default parameters
29
struct
DefaultParameters
30
{
31
// Initial points
32
double
x0
= 0.0;
33
double
y0
= 0.0;
34
35
// Steepest Descent parameters
36
double
alpha_sd
= 0.0050;
37
double
tol_sd
= 1e-8;
38
int
maxIter_sd
= 100000;
39
40
// Conjugate Gradient parameters
41
double
tol_cg
= 1e-8;
42
int
maxIter_cg
= 100000;
43
44
// Simulated Annealing parameters
45
double
T0_sa
= 2000.0;
46
double
Tmin_sa
= 1e-8;
47
double
alpha_sa
= 0.99;
48
int
maxIter_sa
= 200000;
49
50
// Genetic Algorithm parameters
51
int
populationSize_ga
= 100;
52
int
generations_ga
= 5000;
53
double
mutationRate_ga
= 0.02;
54
double
crossoverRate_ga
= 0.8;
55
};
56
57
// Structure to store optimization results
58
struct
Result
59
{
60
double
x
;
61
double
y
;
62
double
f
;
63
int
iterations
;
64
double
duration
;
// in seconds
65
};
66
67
#endif
// STRUCTS_H
DefaultParameters
Definition
structs.h:30
DefaultParameters::x0
double x0
Definition
structs.h:32
DefaultParameters::crossoverRate_ga
double crossoverRate_ga
Definition
structs.h:54
DefaultParameters::maxIter_sa
int maxIter_sa
Definition
structs.h:48
DefaultParameters::generations_ga
int generations_ga
Definition
structs.h:52
DefaultParameters::populationSize_ga
int populationSize_ga
Definition
structs.h:51
DefaultParameters::maxIter_cg
int maxIter_cg
Definition
structs.h:42
DefaultParameters::tol_cg
double tol_cg
Definition
structs.h:41
DefaultParameters::alpha_sd
double alpha_sd
Definition
structs.h:36
DefaultParameters::maxIter_sd
int maxIter_sd
Definition
structs.h:38
DefaultParameters::tol_sd
double tol_sd
Definition
structs.h:37
DefaultParameters::y0
double y0
Definition
structs.h:33
DefaultParameters::alpha_sa
double alpha_sa
Definition
structs.h:47
DefaultParameters::T0_sa
double T0_sa
Definition
structs.h:45
DefaultParameters::mutationRate_ga
double mutationRate_ga
Definition
structs.h:53
DefaultParameters::Tmin_sa
double Tmin_sa
Definition
structs.h:46
Individual
Definition
structs.h:19
Individual::x
double x
Definition
structs.h:20
Individual::Individual
Individual(double x_val=0, double y_val=0)
Definition
structs.h:25
Individual::fitness
double fitness
Definition
structs.h:22
Individual::y
double y
Definition
structs.h:21
Result
Definition
structs.h:59
Result::duration
double duration
Definition
structs.h:64
Result::f
double f
Definition
structs.h:62
Result::y
double y
Definition
structs.h:61
Result::x
double x
Definition
structs.h:60
Result::iterations
int iterations
Definition
structs.h:63
structs.h
Generated by
1.12.0