diff --git a/Makefile b/Makefile index 2f77c4e42e7c44f2f771b8a6b60c4f504489f079..7d9629d2ec2aabcabc11928ff5f91f85c3bc0a14 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,8 @@ -.PHONY: all clean +# Compile the C++ code for CSMOn, plus a Python wrapper and a of couple examples. -all: CSMOn CSMOn_wrapper cpp_example +.PHONY: all clean_install clean + +all: CSMOn CSMOn_wrapper cpp_example clean_install CSMOn: $(MAKE) -C cpp @@ -11,7 +13,11 @@ CSMOn_wrapper: cpp_example: cpp/pso_example.cpp g++ -o cpp/pso_example cpp/pso_example.cpp cpp/PSO.o cpp/CSMOn.o -Wall -pedantic-errors +clean_install: + $(MAKE) -i -C cpp clean + clean: $(MAKE) -i -C cpp clean $(MAKE) -i -C python clean + rm cpp/pso_example diff --git a/cpp/CSMOn.hpp b/cpp/CSMOn.hpp index d2ef6a79a85658d28c503ae90cebaa3eab238420..05635a1fe5a36e0f9979d421c9879f21e221d8e9 100644 --- a/cpp/CSMOn.hpp +++ b/cpp/CSMOn.hpp @@ -31,10 +31,11 @@ /** * @mainpage Convergence Stabilization Modeling operating in Online Mode * - * This is an automated method to estimate the best moment to stop swarm - * iterations based on the analysis of the convergence behavior presented - * during optimization, aiming to provide an effective balance between - * saving fitness evaluations and keeping the optimization quality. + * CSMOn ( formely called of C'MOn! ) is an automated method to estimate + * the best moment to stop swarm iterations based on the analysis of the + * convergence behavior presented during optimization, aiming to provide + * an effective balance between saving fitness evaluations and keeping + * the optimization quality. * The convergence analysis is performed through a sequence of linear * regressions using exponential and log-like curves. * @@ -66,7 +67,7 @@ typedef struct _point{ }t_point; /** - * @brief Convergence Stabilization Modeling operating in Online Mode ( formely called of C'MOn! ). + * @brief Convergence Stabilization Modeling operating in Online Mode. * * @date 04/Mar/2017 * @author Peter Frank Perroni (pfperroni@gmail.com) diff --git a/cpp/Makefile b/cpp/Makefile index 18ec81985b10f2c03a3c8c3e9617e025817a073e..fde825dcba69f64cf03a2e6a50ed36cfc944a5f6 100644 --- a/cpp/Makefile +++ b/cpp/Makefile @@ -1,3 +1,5 @@ +# Compile the C++ source code for CSMOn. + FONTS=PSO.cpp CSMOn.cpp OBJECTS=$(FONTS:.cpp=.o) FLAGS=-Wall -pedantic-errors diff --git a/cpp/pso_example.cpp b/cpp/pso_example.cpp index d5f309b42eec58ea79bcedc85ffe1f445f67a6e5..454a204670c561c626468889d34607481c3de73e 100644 --- a/cpp/pso_example.cpp +++ b/cpp/pso_example.cpp @@ -112,7 +112,7 @@ int main(int argc, char *argv[]){ double fitnessFunction(double *x, int n){ double s = 0; for(int i=0; i < n; i++){ - s += (x[i]+2) * (x[i]+2) - 10 * cos(2 * PI * (x[i]+2)); + s += x[i] * x[i] - 10 * cos(2 * PI * x[i]); } return 10 * n + s; } diff --git a/python/Makefile b/python/Makefile index c7290b407e1ec4678c41a01c59747b302192c118..08ce310cbf26452cb59a12ff4d818e895d0d99a4 100644 --- a/python/Makefile +++ b/python/Makefile @@ -1,11 +1,13 @@ +# Compile the wrapper to call CSMOn from Python. + FONTS=CSMOn_wrapper.cpp DEPENDENCIES=../cpp/PSO.o ../cpp/CSMOn.o OBJECTS=$(FONTS:.cpp=.o) FLAGS=-Wall -pedantic-errors -fPIC -.PHONY: all clean +.PHONY: all clean clean-install -all: CSMOn_wrapper +all: CSMOn_wrapper clean-install CSMOn_wrapper: $(OBJECTS) g++ -o $@.so $^ $(DEPENDENCIES) $(FLAGS) -shared @@ -13,6 +15,9 @@ CSMOn_wrapper: $(OBJECTS) %.o: %.cpp g++ -I../cpp $< -c -o $@ $(FLAGS) +clean-install: + rm $(OBJECTS) + clean: - rm $(OBJECTS) CSMOn.pyc fitnessFunction.pyc + rm $(OBJECTS) CSMOn.pyc fitnessFunction.pyc CSMOn_wrapper.so