optimiser.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "pass_bits/problem.hpp"
5 #include "pass_bits/config.hpp"
6 #include <stdexcept> // throw error
7 #include <chrono> // std::chrono
8 #include <armadillo> // std::arma::vec, arma::uword
9 #include <cassert> // assert
10 #include <string> // name
11 
12 #if defined(SUPPORT_OPENMP)
13 #include <omp.h>
14 #endif
15 
16 #if defined(SUPPORT_MPI)
17 #include <mpi.h>
18 #endif
19 
20 namespace pass
21 {
26 {
33  arma::vec normalised_agent;
34 
38  double fitness_value;
39 
44 
49 
53  arma::uword iterations;
54 
58  arma::uword evaluations;
59 
63  std::chrono::nanoseconds duration;
64 
66  const double acceptable_fitness_value) noexcept;
67 
71  bool solved() const;
72 
76  arma::vec agent() const;
77 };
78 
83 class optimiser
84 {
85 public:
93 
99  arma::uword maximal_iterations;
100 
106  arma::uword maximal_evaluations;
107 
113  std::chrono::nanoseconds maximal_duration;
114 
118  const std::string name;
119 
123  optimiser(const std::string &name);
124 
129  virtual optimise_result optimise(const pass::problem &problem) = 0;
130 };
131 
132 } // namespace pass
arma::uword maximal_evaluations
Definition: optimiser.hpp:106
double acceptable_fitness_value
Definition: optimiser.hpp:92
Definition: optimiser.hpp:83
arma::vec normalised_agent
Definition: optimiser.hpp:33
std::chrono::nanoseconds maximal_duration
Definition: optimiser.hpp:113
virtual optimise_result optimise(const pass::problem &problem)=0
const double acceptable_fitness_value
Definition: optimiser.hpp:43
Definition: optimiser.hpp:25
arma::uword maximal_iterations
Definition: optimiser.hpp:99
optimise_result(const pass::problem &problem, const double acceptable_fitness_value) noexcept
Definition: optimiser.cpp:4
const std::string name
Definition: optimiser.hpp:118
const pass::problem & problem
Definition: optimiser.hpp:48
Definition: problem.hpp:20
double fitness_value
Definition: optimiser.hpp:38
arma::uword evaluations
Definition: optimiser.hpp:58
std::chrono::nanoseconds duration
Definition: optimiser.hpp:63
Definition: adaptive_parameter_search.hpp:5
arma::uword iterations
Definition: optimiser.hpp:53
optimiser(const std::string &name)
Definition: optimiser.cpp:23
bool solved() const
Definition: optimiser.cpp:13
arma::vec agent() const
Definition: optimiser.cpp:18