Skip to content

Commit

Permalink
Further cleanup on simd, add a simd debug case, disable std random nu…
Browse files Browse the repository at this point in the history
…mber generator example
  • Loading branch information
JSzitas committed Nov 13, 2023
1 parent dc546f2 commit 78d1bf4
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 195 deletions.
10 changes: 6 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
all: debug example
all: debug example debug_simd

debug:
clang++ -std=c++17 -O0 -g example.cpp -o debug
clang++ -std=c++17 -O0 -g -Wall example.cpp -o debug
example:
clang++ -std=c++17 -O3 -Wall -march=native example.cpp -o example
debug_simd:
clang++ -std=c++17 -O0 -g -march=native simd_debug.cpp -o simd_debug
clang++ -std=c++17 -O0 -g -Wall -march=native simd_debug.cpp -o simd_debug
example_simd:
clang++ -std=c++17 -O0 -g -Wall -march=native example.cpp -o example_simd
clean:
rm -rf debug example
rm -rf debug example debug_simd


8 changes: 3 additions & 5 deletions changelist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ TODO:
consider moving entirely away from std::vector of std::vector to a flattened
std::vector

consider Nelder Mead PSO where PSO is used for last search using bounds found using Nelder Mead

implement BFGS and L-BFGS-B

implement Coordinate Descent and Gradient Descent
implement L-BFGS-B, or at least BFGS-B
implement CMAES
implement Coordinate Descent

15 changes: 2 additions & 13 deletions example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ void print_vector(std::vector<double> &x) {

// to use any C++ standard random number generator just pass in a generator
// functor e.g. using Mersene Twister
/*
#include <cstdint> // NOLINT
#include <random>
struct std_MT {
Expand All @@ -69,6 +70,7 @@ struct std_MT {
}
double operator()() { return this->distribution(this->generator); }
};
*/

int main() {
// define problem functor - in our case a variant of the rosenbrock function
Expand Down Expand Up @@ -119,19 +121,6 @@ int main() {
de_res.print();
print_vector(de_init);

std::cout << "Differential evolution with std::mt19937: " << std::endl;
// using standard library random number generators
std_MT std_gen;
// again initialize solver, this time also with the RNG
// if strategy is not specifieed, defaults to random
auto de_solver_MT = DE<Rosenbrock, std_MT, double>(prob, std_gen);
// reset initial state
de_init[0] = 2;
de_init[1] = 7;
de_res = de_solver_MT.minimize(de_init);
de_res.print();
print_vector(de_init);

std::cout << "Particle Swarm Optimization with xoshiro: " << std::endl;
// we also have a xoshiro generator
xoshiro<double> xos_gen;
Expand Down
Loading

0 comments on commit 78d1bf4

Please sign in to comment.