From 1b62ed6e507457cb56453d05daa8be8f5df5f0d0 Mon Sep 17 00:00:00 2001 From: Robin Verschueren Date: Thu, 10 Aug 2017 23:28:18 +0200 Subject: [PATCH] MSVC support (#108) * Trying compiling with MSVC. Outstanding errors: variable-sized * Can compiler qpoases_chen and nonlinear_chain examples with MSVC * Correct some errors introduced by working towards msvc * Get rid of timing dependencies * MSVC still compiling examples * Add Appveyor * Try other branch * run cmake * submodules * Add openblas, fortran * small fix * Fix build error * try other openblas * Small adaptations to dependencies in order to compile with msvc * Always answer yes * New version of dependencies * Find conda libs * Find shared library of gfortran * change testing in Appveyor * Fix lint errors * Fix CMake error in qpDUNES --- .appveyor.yml | 17 ++ .gitignore | 1 + CMakeLists.txt | 17 +- acados/CMakeLists.txt | 12 +- acados/ocp_nlp/ocp_nlp_gn_sqp.c | 6 +- acados/ocp_qp/ocp_qp_condensing_qpoases.c | 13 +- acados/ocp_qp/ocp_qp_hpmpc.c | 2 +- acados/ocp_qp/ocp_qp_ooqp.c | 14 +- acados/sim/sim_collocation.c | 9 +- acados/sim/sim_erk_integrator.c | 18 +- acados/sim/sim_erk_integrator.h | 2 +- acados/sim/sim_lifted_irk_integrator.c | 41 ++--- acados/sim/sim_lifted_irk_integrator.h | 2 +- acados/utils/timing.c | 16 +- acados/utils/timing.h | 20 +-- cmake/FindFortranLibs.cmake | 13 +- cmake/FindOpenBLAS.cmake | 10 ++ cmake/external/blasfeo.cmake | 4 +- examples/CMakeLists.txt | 2 - examples/c/CMakeLists.txt | 33 ++-- examples/c/chain_model/jac_chain_nm10.c | 2 +- examples/c/chain_model/jac_chain_nm2.c | 2 +- examples/c/chain_model/jac_chain_nm3.c | 2 +- examples/c/chain_model/jac_chain_nm4.c | 2 +- examples/c/chain_model/jac_chain_nm5.c | 2 +- examples/c/chain_model/jac_chain_nm6.c | 2 +- examples/c/chain_model/jac_chain_nm7.c | 2 +- examples/c/chain_model/jac_chain_nm8.c | 2 +- examples/c/chain_model/jac_chain_nm9.c | 2 +- examples/c/chen_nmpc_hpmpc.c | 8 +- examples/c/chen_nmpc_qpoases.c | 73 ++++---- examples/c/chen_sqp_hpmpc.c | 6 +- examples/c/chen_sqp_qpoases.c | 6 +- examples/c/linear_mpc.c | 6 +- examples/c/mass_spring_hpmpc.c | 156 +++++++++--------- examples/c/mass_spring_hpmpc_libstr.c | 10 +- examples/c/mass_spring_partial_tightening.c | 12 +- examples/c/mass_spring_qpoases.c | 112 ++++++------- examples/c/nonlinear_chain_sqp.c | 91 +++++----- examples/c/pendulum_hpmpc_libstr.c | 7 +- examples/c/pendulum_partial_tightening.c | 8 +- .../esp32_specific/main.c | 6 +- external/CMakeLists.txt | 6 +- external/blasfeo | 2 +- external/hpipm | 2 +- external/qpDUNES-dev | 2 +- external/qpOASES/CMakeLists.txt | 13 +- 47 files changed, 423 insertions(+), 373 deletions(-) create mode 100644 .appveyor.yml diff --git a/.appveyor.yml b/.appveyor.yml new file mode 100644 index 0000000000..7fa3a56c8f --- /dev/null +++ b/.appveyor.yml @@ -0,0 +1,17 @@ + +branches: + only: + - msvc + +install: + - call C:\Miniconda36-x64\Scripts\activate.bat + - conda install --yes -c msys2 m2w64-gcc-libgfortran m2w64-openblas + +build_script: + - git submodule update --init --recursive + - cmake -E make_directory build + - cmake -E chdir build cmake .. + - cmake --build build --config Debug + - cmake -E chdir build ctest --output-on-failure + - cmake --build build --config Release + - cmake -E chdir build ctest --output-on-failure diff --git a/.gitignore b/.gitignore index 9cf88a4fbc..4e35d186db 100644 --- a/.gitignore +++ b/.gitignore @@ -78,3 +78,4 @@ octave-workspace notes.txt *.dSYM/ cmakelint +.vs diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ff3275890..114ad80037 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,6 +24,11 @@ set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") set(CMAKE_VERBOSE_MAKEFILE ON) set(CMAKE_POSITION_INDEPENDENT_CODE TRUE) +if(CMAKE_SYSTEM MATCHES "Windows") + set(CMAKE_FIND_LIBRARY_PREFIXES "lib" CACHE INTERNAL "Library prefix") + set(CMAKE_FIND_LIBRARY_SUFFIXES ".dll" CACHE INTERNAL "Library suffix") +endif() + # Set up build type if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release @@ -34,13 +39,9 @@ message(STATUS "Build type is ${CMAKE_BUILD_TYPE}") enable_testing(true) -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -Werror -fdiagnostics-show-option") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Werror -fdiagnostics-show-option") -elseif(CMAKE_C_COMPILER_ID MATCHES "MSVC") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -WX") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -Wall -Werror -fdiagnostics-show-option") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Werror -fdiagnostics-show-option") endif() # Set install directories @@ -94,4 +95,6 @@ add_custom_target(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake") # Cpplint -include(lint) +if(NOT ${CMAKE_SYSTEM} MATCHES "Windows") + include(lint) +endif() diff --git a/acados/CMakeLists.txt b/acados/CMakeLists.txt index faf963f8aa..8ecbd415c0 100644 --- a/acados/CMakeLists.txt +++ b/acados/CMakeLists.txt @@ -29,20 +29,28 @@ endif() file(GLOB_RECURSE ACADOS_SRC "${PROJECT_SOURCE_DIR}/acados/*.c") # Exclude helper files list(REMOVE_ITEM ACADOS_SRC "${PROJECT_SOURCE_DIR}/acados/ocp_qp/condensing_helper_functions.c") +# Exclude files not compatible with MSVC +if(CMAKE_C_COMPILER_ID MATCHES "MSVC") + list(REMOVE_ITEM ACADOS_SRC "${PROJECT_SOURCE_DIR}/acados/ocp_qp/ocp_qp_hpmpc.c") +endif() if(NOT EXISTS ${PROJECT_SOURCE_DIR}/external/OOQP) list(REMOVE_ITEM ACADOS_SRC "${PROJECT_SOURCE_DIR}/acados/ocp_qp/ocp_qp_ooqp.c") endif() # Define acados library -add_library(acados STATIC ${ACADOS_SRC}) +add_library(acados ${ACADOS_SRC}) target_include_directories(acados PUBLIC $ # for include "acados/..." $ $) -target_link_libraries(acados PUBLIC qpOASES_e hpmpc blasfeo qpdunes) +# HPMPC must come before BLASFEO! +if(NOT CMAKE_C_COMPILER_ID MATCHES "MSVC") + target_link_libraries(acados PUBLIC hpmpc) +endif() +target_link_libraries(acados PUBLIC qpOASES_e blasfeo qpdunes) # TODO: The following definition should go ASAP! target_compile_definitions(acados PRIVATE EXT_DEP) diff --git a/acados/ocp_nlp/ocp_nlp_gn_sqp.c b/acados/ocp_nlp/ocp_nlp_gn_sqp.c index 78d7919073..ba853e5ca6 100644 --- a/acados/ocp_nlp/ocp_nlp_gn_sqp.c +++ b/acados/ocp_nlp/ocp_nlp_gn_sqp.c @@ -134,7 +134,7 @@ int_t ocp_nlp_gn_sqp(const ocp_nlp_in *nlp_in, ocp_nlp_out *nlp_out, void *nlp_a w[w_idx+j] = gn_sqp_mem->common->x[N][j]; } - acado_timer timer; + acados_timer timer; real_t timings = 0; real_t timings_sim = 0; real_t timings_la = 0; @@ -143,7 +143,7 @@ int_t ocp_nlp_gn_sqp(const ocp_nlp_in *nlp_in, ocp_nlp_out *nlp_out, void *nlp_a real_t feas, stepX, stepU; int_t status; - acado_tic(&timer); + acados_tic(&timer); for (int_t sqp_iter = 0; sqp_iter < gn_sqp_args->common->maxIter; sqp_iter++) { feas = stepX = stepU = -1e10; @@ -276,7 +276,7 @@ int_t ocp_nlp_gn_sqp(const ocp_nlp_in *nlp_in, ocp_nlp_out *nlp_out, void *nlp_a "step U: %+.3e \n", sqp_iter, feas, stepX, stepU); } - timings += acado_toc(&timer); + timings += acados_toc(&timer); #ifdef MEASURE_TIMINGS printf("\nAverage of %.3f ms in the integrator,\n", 1e3*timings_sim/(gn_sqp_args->common->maxIter)); diff --git a/acados/ocp_qp/ocp_qp_condensing_qpoases.c b/acados/ocp_qp/ocp_qp_condensing_qpoases.c index 05d8da0bc4..6c6bb0559c 100644 --- a/acados/ocp_qp/ocp_qp_condensing_qpoases.c +++ b/acados/ocp_qp/ocp_qp_condensing_qpoases.c @@ -48,6 +48,9 @@ #include "qpOASES_e/QProblemB.h" #include "qpOASES_e/QProblem.h" #endif +#else + #include "qpOASES_e/QProblemB.h" + #include "qpOASES_e/QProblem.h" #endif #include "acados/ocp_qp/condensing.h" @@ -312,7 +315,7 @@ int_t ocp_qp_condensing_qpoases(ocp_qp_in *qp_in, ocp_qp_out *qp_out, workspace++; workspace = 0; mem_ = 0; - mem_++; + (void) mem_; d_zeros(&A_row_major, work.nconstraints, work.nconvars); convert_to_row_major(out.A, A_row_major, work.nconstraints, work.nconvars); @@ -393,12 +396,12 @@ void ocp_qp_condensing_qpoases_initialize(ocp_qp_in *qp_in, void *args_, void *m // TODO(dimitris): replace dummy commands once interface completed args->dummy = 42.0; if (qp_in->nx[0] > 0) - mem_++; - work++; + (void) mem_; + (void) work; } void ocp_qp_condensing_qpoases_destroy(void *mem_, void *work) { // TODO(dimitris): replace dummy commands once interface completed - mem_++; - work++; + (void) mem_; + (void) work; } diff --git a/acados/ocp_qp/ocp_qp_hpmpc.c b/acados/ocp_qp/ocp_qp_hpmpc.c index 44208a6b26..424a25ebd1 100644 --- a/acados/ocp_qp/ocp_qp_hpmpc.c +++ b/acados/ocp_qp/ocp_qp_hpmpc.c @@ -60,7 +60,7 @@ void ocp_qp_hpmpc_initialize(ocp_qp_in *qp_in, void *args_, void *mem_, void **w // TODO(andrea): replace dummy commands once interface completed args->max_iter = args->max_iter; if (qp_in->nx[0] > 0) - mem_++; + (void) mem_; work++; } diff --git a/acados/ocp_qp/ocp_qp_ooqp.c b/acados/ocp_qp/ocp_qp_ooqp.c index ea13105849..29c8259c3f 100644 --- a/acados/ocp_qp/ocp_qp_ooqp.c +++ b/acados/ocp_qp/ocp_qp_ooqp.c @@ -653,32 +653,32 @@ int_t ocp_qp_ooqp(ocp_qp_in *in, ocp_qp_out *out, void *args_, void *memory_, vo // printf("$$ FIRST RUN FLAG %d\n", mem->firstRun); #ifdef MEASURE_TIMINGS - acado_timer timer; + acados_timer timer; real_t cputime; - acado_tic(&timer); + acados_tic(&timer); #endif // NOTE: has to be called after setting up the memory which contains the problem dimensions ocp_qp_ooqp_cast_workspace(work, mem); #ifdef MEASURE_TIMINGS - cputime = acado_toc(&timer); + cputime = acados_toc(&timer); printf(">>> OOQP workspace casted in %.3f ms.\n", 1e3*cputime); #endif #ifdef MEASURE_TIMINGS - acado_tic(&timer); + acados_tic(&timer); #endif ocp_qp_ooqp_update_memory(in, args, mem, work); #ifdef MEASURE_TIMINGS - cputime = acado_toc(&timer); + cputime = acados_toc(&timer); printf(">>> OOQP memory initialized in %.3f ms.\n", 1e3*cputime); #endif if (0) print_inputs(mem); #ifdef MEASURE_TIMINGS - acado_tic(&timer); + acados_tic(&timer); #endif // TODO(dimitris): implement dense OOQP // call sparse OOQP @@ -692,7 +692,7 @@ int_t ocp_qp_ooqp(ocp_qp_in *in, ocp_qp_out *out, void *args_, void *memory_, vo work->x, work->gamma, work->phi, work->y, work->z, work->lambda, work->pi, &work->objectiveValue, args->printLevel, &return_value); #ifdef MEASURE_TIMINGS - cputime = acado_toc(&timer); + cputime = acados_toc(&timer); printf(">>> OOQP problem solved in %.3f ms.\n\n", 1e3*cputime); #endif diff --git a/acados/sim/sim_collocation.c b/acados/sim/sim_collocation.c index d070c0487c..a1f222ade7 100644 --- a/acados/sim/sim_collocation.c +++ b/acados/sim/sim_collocation.c @@ -110,8 +110,10 @@ void get_Gauss_nodes(const int_t num_stages, real_t *nodes) { } void read_Gauss_simplified(const int_t num_stages, Newton_scheme *scheme) { - real_t D[2*num_stages]; - real_t T[num_stages*num_stages]; + real_t *D; + D = (real_t *) calloc(2 * num_stages, sizeof(real_t)); + real_t *T; + T = (real_t *) calloc(num_stages*num_stages, sizeof(real_t)); char simplified[80]; int_t *perm; real_t *T_inv; @@ -258,7 +260,8 @@ real_t LU_system_solve(real_t* const A, real_t* const b, int* const perm, int intSwap; int DIM = dim; int DIM_RHS = dim2; - real_t bPerm[DIM*DIM_RHS]; + real_t *bPerm; + bPerm = (real_t *) calloc(DIM*DIM_RHS, sizeof(real_t)); real_t tmp_var; for (i = 0; i < DIM; ++i) { diff --git a/acados/sim/sim_erk_integrator.c b/acados/sim/sim_erk_integrator.c index ffc75e39a1..86b4b8566a 100644 --- a/acados/sim/sim_erk_integrator.c +++ b/acados/sim/sim_erk_integrator.c @@ -38,7 +38,7 @@ static void sim_erk_cast_workspace(sim_erk_workspace *work, if (!in->sens_forw) { NF = 0; } - int_t nhess = (int_t)(NF+1)*(real_t)NF/2.0; + int_t nhess = (int_t) (NF+1)*(real_t)NF/2.0; char *ptr = (char *)work; ptr += sizeof(sim_erk_workspace); @@ -90,7 +90,7 @@ int_t sim_erk(const sim_in *in, sim_out *out, void *args, void *mem, void *work_ } int_t nhess = (int_t)(NF+1)*(real_t)NF/2.0; - mem = 0; mem += 0; + mem = 0; (void) mem; real_t *A_mat = opts->A_mat; real_t *b_vec = opts->b_vec; @@ -107,9 +107,9 @@ int_t sim_erk(const sim_in *in, sim_out *out, void *args, void *mem, void *work_ real_t *rhs_adj_in = work->rhs_adj_in; #ifdef MEASURE_TIMINGS - acado_timer timer, timer_ad; + acados_timer timer, timer_ad; real_t timing_ad = 0.0; - acado_tic(&timer); + acados_tic(&timer); #endif for (i = 0; i < nx; i++) forw_traj[i] = in->x[i]; if (in->sens_forw) { @@ -140,11 +140,11 @@ int_t sim_erk(const sim_in *in, sim_out *out, void *args, void *mem, void *work_ } } #ifdef MEASURE_TIMINGS - acado_tic(&timer_ad); + acados_tic(&timer_ad); #endif in->VDE_forw(rhs_forw_in, &(K_traj[s*nx*(1+NF)]), in->vde); // k evaluation #ifdef MEASURE_TIMINGS - timing_ad += acado_toc(&timer_ad); + timing_ad += acados_toc(&timer_ad); #endif } for (s = 0; s < num_stages; s++) { @@ -199,11 +199,11 @@ int_t sim_erk(const sim_in *in, sim_out *out, void *args, void *mem, void *work_ } } #ifdef MEASURE_TIMINGS - acado_tic(&timer_ad); + acados_tic(&timer_ad); #endif in->VDE_adj(rhs_adj_in, &(adj_traj[s*nAdj])); // adjoint VDE evaluation #ifdef MEASURE_TIMINGS - timing_ad += acado_toc(&timer_ad); + timing_ad += acados_toc(&timer_ad); #endif } for (s = 0; s < num_stages; s++) { @@ -218,7 +218,7 @@ int_t sim_erk(const sim_in *in, sim_out *out, void *args, void *mem, void *work_ } } #ifdef MEASURE_TIMINGS - out->info->CPUtime = acado_toc(&timer); + out->info->CPUtime = acados_toc(&timer); out->info->LAtime = 0.0; out->info->ADtime = timing_ad; #endif diff --git a/acados/sim/sim_erk_integrator.h b/acados/sim/sim_erk_integrator.h index 83e1d3b889..31b0a00b4d 100644 --- a/acados/sim/sim_erk_integrator.h +++ b/acados/sim/sim_erk_integrator.h @@ -43,7 +43,7 @@ int_t sim_erk(const sim_in *in, sim_out *out, void *args, void *mem, void *work) int_t sim_erk_calculate_workspace_size(const sim_in *in, void *args); -void sim_erk_create_arguments(void *args, int_t num_stages); +void sim_erk_create_arguments(void *args, const int_t num_stages); void sim_erk_initialize(const sim_in *in, void *args_, void **work); void sim_erk_destroy(void *work); diff --git a/acados/sim/sim_lifted_irk_integrator.c b/acados/sim/sim_lifted_irk_integrator.c index 87364b69b8..21a6058b88 100644 --- a/acados/sim/sim_lifted_irk_integrator.c +++ b/acados/sim/sim_lifted_irk_integrator.c @@ -190,7 +190,8 @@ real_t solve_system_ACADO(real_t* const A, real_t* const b, int* const perm, int dim += 0; dim2 += 0; #endif - real_t bPerm[DIM*DIM_RHS]; + real_t *bPerm; + bPerm = (real_t *) calloc(DIM*DIM_RHS, sizeof(real_t)); real_t tmp_var; for (i = 0; i < DIM; ++i) { @@ -238,7 +239,8 @@ real_t solve_system_trans_ACADO(real_t* const A, real_t* const b, dim += 0; dim2 += 0; #endif - real_t bPerm[DIM*DIM_RHS]; + real_t *bPerm; + bPerm = (real_t *) calloc(DIM*DIM_RHS, sizeof(real_t)); real_t tmp_var; @@ -375,7 +377,7 @@ void form_linear_system_matrix(int_t istep, const sim_in *in, void *args, real_t tmp_eig, tmp_eig2; #ifdef MEASURE_TIMINGS - acado_timer timer_ad; + acados_timer timer_ad; #else timing_ad += 0; #endif @@ -430,11 +432,11 @@ void form_linear_system_matrix(int_t istep, const sim_in *in, void *args, } } #ifdef MEASURE_TIMINGS - acado_tic(&timer_ad); + acados_tic(&timer_ad); #endif in->jac_fun(rhs_in, jac_tmp); // k evaluation #ifdef MEASURE_TIMINGS - timing_ad += acado_toc(&timer_ad); + timing_ad += acados_toc(&timer_ad); #endif // } if (opts->scheme.type == simplified_in || opts->scheme.type == simplified_inis) { @@ -531,7 +533,7 @@ int_t sim_lifted_irk(const sim_in *in, sim_out *out, void *args, #endif // !TRIPLE_LOOP #ifdef MEASURE_TIMINGS - acado_timer timer, timer_la, timer_ad; + acados_timer timer, timer_la, timer_ad; real_t timing_la = 0.0; real_t timing_ad = 0.0; #endif @@ -540,7 +542,7 @@ int_t sim_lifted_irk(const sim_in *in, sim_out *out, void *args, // printf("NU = %d, NF = %d \n", nu, NF); #ifdef MEASURE_TIMINGS - acado_tic(&timer); + acados_tic(&timer); #endif for (i = 0; i < nx; i++) out_tmp[i] = in->x[i]; @@ -615,7 +617,7 @@ int_t sim_lifted_irk(const sim_in *in, sim_out *out, void *args, construct_subsystems(sys_sol_trans, sys_sol2, num_stages, nx, 1); } #ifdef MEASURE_TIMINGS - acado_tic(&timer_la); + acados_tic(&timer_la); #endif int_t idx = 0; for (s1 = 0; s1 < num_stages; s1++) { @@ -647,7 +649,7 @@ int_t sim_lifted_irk(const sim_in *in, sim_out *out, void *args, #endif // TRIPLE_LOOP } #ifdef MEASURE_TIMINGS - timing_la += acado_toc(&timer_la); + timing_la += acados_toc(&timer_la); #endif // TRANSFORM using transf2_T: if (opts->scheme.type == simplified_in || opts->scheme.type == simplified_inis) { @@ -696,7 +698,7 @@ int_t sim_lifted_irk(const sim_in *in, sim_out *out, void *args, int_t idx; if (opts->scheme.type == exact || (istep == 0 && !opts->scheme.freeze)) { #ifdef MEASURE_TIMINGS - acado_tic(&timer_la); + acados_tic(&timer_la); #endif idx = 0; for (s1 = 0; s1 < num_stages; s1++) { @@ -732,7 +734,7 @@ int_t sim_lifted_irk(const sim_in *in, sim_out *out, void *args, #endif // TRIPLE_LOOP } #ifdef MEASURE_TIMINGS - timing_la += acado_toc(&timer_la); + timing_la += acados_toc(&timer_la); #endif } @@ -759,13 +761,13 @@ int_t sim_lifted_irk(const sim_in *in, sim_out *out, void *args, } rhs_in[nx*(1+NF)+nu] = ((real_t) istep+c_vec[s1])/((real_t) in->nSteps); // time #ifdef MEASURE_TIMINGS - acado_tic(&timer_ad); + acados_tic(&timer_ad); #endif in->VDE_forw(rhs_in, VDE_tmp[s1], in->vde); // k evaluation #ifdef MEASURE_TIMINGS - timing_ad += acado_toc(&timer_ad); + timing_ad += acados_toc(&timer_ad); #endif // put VDE_tmp in sys_sol: for (j = 0; j < 1+NF; j++) { @@ -818,7 +820,7 @@ int_t sim_lifted_irk(const sim_in *in, sim_out *out, void *args, } #ifdef MEASURE_TIMINGS - acado_tic(&timer_la); + acados_tic(&timer_la); #endif idx = 0; for (s1 = 0; s1 < num_stages; s1++) { @@ -873,7 +875,7 @@ int_t sim_lifted_irk(const sim_in *in, sim_out *out, void *args, #endif // TRIPLE_LOOP } #ifdef MEASURE_TIMINGS - timing_la += acado_toc(&timer_la); + timing_la += acados_toc(&timer_la); #endif if (opts->scheme.type == simplified_in || opts->scheme.type == simplified_inis) { // construct sys_sol_trans from sys_sol2: @@ -978,7 +980,7 @@ int_t sim_lifted_irk(const sim_in *in, sim_out *out, void *args, for (i = 0; i < nx*NF; i++) out->S_forw[i] = out_tmp[nx+i]; #ifdef MEASURE_TIMINGS - out->info->CPUtime = acado_toc(&timer); + out->info->CPUtime = acados_toc(&timer); out->info->LAtime = timing_la; out->info->ADtime = timing_ad; #endif @@ -1053,7 +1055,7 @@ void sim_lifted_irk_create_memory(const sim_in *in, void *args, sim_RK_opts *opts = (sim_RK_opts*) args; int_t num_stages = opts->num_stages; int_t NF = in->nsens_forw; - int_t num_sys = ceil(num_stages/2.0); + int_t num_sys = (int_t) ceil(num_stages/2.0); // printf("num_stages: %d \n", num_stages); // printf("ceil(num_stages/2.0): %d \n", (int)ceil(num_stages/2.0)); // printf("floor(num_stages/2.0): %d \n", (int)floor(num_stages/2.0)); @@ -1196,8 +1198,8 @@ void sim_irk_create_arguments(void *args, const int_t num_stages, const char* na } -void sim_irk_create_Newton_scheme(void *args, const int_t num_stages, const char* name, - enum Newton_type_collocation type) { +void sim_irk_create_Newton_scheme(void *args, int_t num_stages, const char* name, + enum Newton_type_collocation type) { sim_RK_opts *opts = (sim_RK_opts*) args; opts->scheme.type = type; opts->scheme.freeze = false; @@ -1244,4 +1246,3 @@ void sim_lifted_irk_destroy(void *mem, void *work) { free(work); sim_lifted_irk_free_memory(mem); } - diff --git a/acados/sim/sim_lifted_irk_integrator.h b/acados/sim/sim_lifted_irk_integrator.h index 1136e31b63..be5b745c2a 100644 --- a/acados/sim/sim_lifted_irk_integrator.h +++ b/acados/sim/sim_lifted_irk_integrator.h @@ -79,7 +79,7 @@ void sim_lifted_irk_create_memory(const sim_in *in, void *args, sim_lifted_irk_memory *mem); void sim_lifted_irk_free_memory(void *mem_); -void sim_irk_create_arguments(void *args, int_t num_stages, const char* name); +void sim_irk_create_arguments(void *args, const int_t num_stages, const char* name); void sim_lifted_irk_initialize(const sim_in *in, void *args_, void *mem_, void **work); void sim_lifted_irk_destroy(void *mem, void *work); diff --git a/acados/utils/timing.c b/acados/utils/timing.c index 3f79a4f2d2..af9d9d85c5 100755 --- a/acados/utils/timing.c +++ b/acados/utils/timing.c @@ -22,23 +22,23 @@ #if !(defined _DSPACE) #if (defined _WIN32 || defined _WIN64) && !(defined __MINGW32__ || defined __MINGW64__) -void acado_tic(acado_timer* t) { +void acados_tic(acados_timer* t) { QueryPerformanceFrequency(&t->freq); QueryPerformanceCounter(&t->tic); } -real_t acado_toc(acado_timer* t) { +real_t acados_toc(acados_timer* t) { QueryPerformanceCounter(&t->toc); return ((t->toc.QuadPart - t->tic.QuadPart) / (real_t)t->freq.QuadPart); } #elif(defined __APPLE__) -void acado_tic(acado_timer* t) { +void acados_tic(acados_timer* t) { /* read current clock cycles */ t->tic = mach_absolute_time(); } -real_t acado_toc(acado_timer* t) { +real_t acados_toc(acados_timer* t) { uint64_t duration; /* elapsed time in clock cycles*/ t->toc = mach_absolute_time(); @@ -58,12 +58,12 @@ real_t acado_toc(acado_timer* t) { /* C99 mode */ /* read current time */ -void acado_tic(acado_timer* t) { +void acados_tic(acados_timer* t) { gettimeofday(&t->tic, 0); } /* return time passed since last call to tic on this timer */ -real_t acado_toc(acado_timer* t) { +real_t acados_toc(acados_timer* t) { struct timeval temp; gettimeofday(&t->toc, 0); @@ -83,13 +83,13 @@ real_t acado_toc(acado_timer* t) { /* ANSI */ /* read current time */ -void acado_tic(acado_timer* t) { +void acados_tic(acados_timer* t) { clock_gettime(CLOCK_MONOTONIC, &t->tic); } /* return time passed since last call to tic on this timer */ -real_t acado_toc(acado_timer* t) { +real_t acados_toc(acados_timer* t) { struct timespec temp; clock_gettime(CLOCK_MONOTONIC, &t->toc); diff --git a/acados/utils/timing.h b/acados/utils/timing.h index baff19e9cd..55a1d3a722 100644 --- a/acados/utils/timing.h +++ b/acados/utils/timing.h @@ -29,11 +29,11 @@ #include /** A structure for keeping internal timer data. */ -typedef struct acado_timer_ { +typedef struct acados_timer_ { LARGE_INTEGER tic; LARGE_INTEGER toc; LARGE_INTEGER freq; -} acado_timer; +} acados_timer; #elif(defined __APPLE__) @@ -41,11 +41,11 @@ typedef struct acado_timer_ { #include /** A structure for keeping internal timer data. */ -typedef struct acado_timer_ { +typedef struct acados_timer_ { uint64_t tic; uint64_t toc; mach_timebase_info_data_t tinfo; -} acado_timer; +} acados_timer; #else @@ -58,29 +58,29 @@ typedef struct acado_timer_ { #include #include -typedef struct acado_timer_ { +typedef struct acados_timer_ { struct timeval tic; struct timeval toc; -} acado_timer; +} acados_timer; #else /* ANSI C */ /** A structure for keeping internal timer data. */ -typedef struct acado_timer_ { +typedef struct acados_timer_ { struct timespec tic; struct timespec toc; -} acado_timer; +} acados_timer; #endif /* __STDC_VERSION__ >= 199901L */ #endif /* (defined _WIN32 || defined _WIN64) */ /** A function for measurement of the current time. */ -void acado_tic(acado_timer* t); +void acados_tic(acados_timer* t); /** A function which returns the elapsed time. */ -real_t acado_toc(acado_timer* t); +real_t acados_toc(acados_timer* t); #endif diff --git a/cmake/FindFortranLibs.cmake b/cmake/FindFortranLibs.cmake index e845ec65f9..1a3029a5e6 100644 --- a/cmake/FindFortranLibs.cmake +++ b/cmake/FindFortranLibs.cmake @@ -17,13 +17,24 @@ # # -find_library(FORTRAN_LIBRARY gfortran +find_library(FORTRAN_LIBRARY NAMES libgfortran.so libgfortran.dylib gfortran HINTS /usr/lib/gcc/x86_64-linux-gnu/* /usr/local/lib/gcc/* ${CMAKE_FIND_ROOT_PATH} + $ENV{PATH} CMAKE_FIND_ROOT_PATH_BOTH) +if (NOT FORTRAN_LIBRARY) + find_library(FORTRAN_LIBRARY gfortran-3 + HINTS + /usr/lib/gcc/x86_64-linux-gnu/* + /usr/local/lib/gcc/* + ${CMAKE_FIND_ROOT_PATH} + $ENV{PATH} + CMAKE_FIND_ROOT_PATH_BOTH) +endif () + include(FindPackageHandleStandardArgs) find_package_handle_standard_args(FortranLibs FOUND_VAR FORTRANLIBS_FOUND REQUIRED_VARS FORTRAN_LIBRARY) \ No newline at end of file diff --git a/cmake/FindOpenBLAS.cmake b/cmake/FindOpenBLAS.cmake index 9324967a37..3ba97293e7 100644 --- a/cmake/FindOpenBLAS.cmake +++ b/cmake/FindOpenBLAS.cmake @@ -71,6 +71,7 @@ SET(Open_BLAS_LIB_SEARCH_PATHS $ENV{OpenBLAS}/lib $ENV{OpenBLAS_HOME} $ENV{OpenBLAS_HOME}/lib + $ENV{PATH} ) FIND_PATH(OpenBLAS_INCLUDE_DIR NAMES cblas.h PATHS ${Open_BLAS_INCLUDE_SEARCH_PATHS}) @@ -78,6 +79,15 @@ FIND_LIBRARY(OpenBLAS_LIB NAMES openblas PATHS ${Open_BLAS_LIB_SEARCH_PATHS}) SET(OpenBLAS_FOUND ON) +IF(OpenBLAS_LIB) + get_filename_component(OpenBLAS_HOME ${OpenBLAS_LIB} DIRECTORY) + get_filename_component(OpenBLAS_HOME ${OpenBLAS_HOME} DIRECTORY) + FIND_PATH(OpenBLAS_INCLUDE_DIR NAMES cblas.h + PATHS + ${OpenBLAS_HOME}/include/OpenBLAS + ${OpenBLAS_HOME}/include/) +ENDIF() + # Check include files IF(NOT OpenBLAS_INCLUDE_DIR) SET(OpenBLAS_FOUND OFF) diff --git a/cmake/external/blasfeo.cmake b/cmake/external/blasfeo.cmake index 95a04e81f9..529f03c757 100644 --- a/cmake/external/blasfeo.cmake +++ b/cmake/external/blasfeo.cmake @@ -6,8 +6,8 @@ if(NOT DEFINED BLASFEO_TARGET) set(BLASFEO_TARGET GENERIC) endif() if(NOT DEFINED BLASFEO_LA) - set(BLASFEO_LA HIGH_PERFORMANCE) -# set(BLASFEO_LA REFERENCE) +# set(BLASFEO_LA HIGH_PERFORMANCE) + set(BLASFEO_LA REFERENCE) # set(BLASFEO_LA BLAS) endif() diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 7ad81f14e3..891bbcd8e1 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -20,8 +20,6 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -Werror -fdiagnostics-show-option") -elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -WX") endif() add_subdirectory(c) diff --git a/examples/c/CMakeLists.txt b/examples/c/CMakeLists.txt index 5600507b69..b3eca23878 100644 --- a/examples/c/CMakeLists.txt +++ b/examples/c/CMakeLists.txt @@ -17,6 +17,7 @@ # # +add_definitions(-DEXT_DEP) configure_file(chain_model/chain_model.h.in chain_model/chain_model.h @ONLY) # Define sources for models used in the examples @@ -30,9 +31,11 @@ file(GLOB PENDULUM_MODEL_SRC pendulum_model/pendulum_model.c pendulum_model/jac_pendulum.c) # Define examples -add_executable(mass_spring_hpmpc_example mass_spring_hpmpc.c) -target_link_libraries(mass_spring_hpmpc_example acados) -add_test(mass_spring_hpmpc_example mass_spring_hpmpc_example) +if(NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC") + add_executable(mass_spring_hpmpc_example mass_spring_hpmpc.c) + target_link_libraries(mass_spring_hpmpc_example acados) + add_test(mass_spring_hpmpc_example mass_spring_hpmpc_example) +endif() # add_executable(mass_spring_partial_tightening_example # mass_spring_partial_tightening.c @@ -60,9 +63,11 @@ add_test(mass_spring_hpmpc_example mass_spring_hpmpc_example) #) #target_link_libraries(nonlinear_chain_ocp_nlp acados) -add_executable(mass_spring_qpoases_example mass_spring_qpoases.c) -target_link_libraries(mass_spring_qpoases_example acados) -add_test(mass_spring_qpoases_example mass_spring_qpoases_example) +if(NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC") + add_executable(mass_spring_qpoases_example mass_spring_qpoases.c) + target_link_libraries(mass_spring_qpoases_example acados) + add_test(mass_spring_qpoases_example mass_spring_qpoases_example) +endif() add_executable(chen_nmpc_qpoases_example chen_nmpc_qpoases.c ${CHEN_MODEL_SRC}) @@ -73,17 +78,15 @@ add_executable(nonlinear_chain_sqp_example nonlinear_chain_sqp.c ${CHAIN_MODEL_SRC}) target_include_directories(nonlinear_chain_sqp_example PRIVATE "${CMAKE_BINARY_DIR}") target_link_libraries(nonlinear_chain_sqp_example acados) -# Following test takes too long! -# add_test( -# NAME nonlinear_chain_sqp_example -# COMMAND "${CMAKE_COMMAND}" -E chdir ${EXECUTABLE_OUTPUT_PATH} ./nonlinear_chain_sqp_example -# ) +# add_test(nonlinear_chain_sqp_example nonlinear_chain_sqp_example) # add_executable(pendulum_hpmpc_libstr_example pendulum_hpmpc_libstr.c ${PENDULUM_MODEL_SRC}) # target_link_libraries(pendulum_hpmpc_libstr_example acados) # add_test(NAME pendulum_hpmpc_libstr_example COMMAND "${CMAKE_COMMAND}" -E chdir ${EXECUTABLE_OUTPUT_PATH} ./pendulum_hpmpc_libstr_example) -add_executable(pendulum_partial_tightening_example - pendulum_partial_tightening.c ${PENDULUM_MODEL_SRC}) -target_link_libraries(pendulum_partial_tightening_example acados) -add_test(pendulum_partial_tightening_example pendulum_partial_tightening_example) \ No newline at end of file +if(NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC") + add_executable(pendulum_partial_tightening_example + pendulum_partial_tightening.c ${PENDULUM_MODEL_SRC}) + target_link_libraries(pendulum_partial_tightening_example acados) + add_test(pendulum_partial_tightening_example pendulum_partial_tightening_example) +endif() \ No newline at end of file diff --git a/examples/c/chain_model/jac_chain_nm10.c b/examples/c/chain_model/jac_chain_nm10.c index 16d33c65b6..2087510a4b 100644 --- a/examples/c/chain_model/jac_chain_nm10.c +++ b/examples/c/chain_model/jac_chain_nm10.c @@ -42,7 +42,7 @@ static const int CASADI_PREFIX(s2)[] = {54, 54, 0, 54, 108, 162, 216, 270, 324, #define s2 CASADI_PREFIX(s2) /* jacFun */ int jac_chain_nm10(void* mem, const real_t** arg, real_t** res, int* iw, real_t* w) { - mem = 0; mem += 0; w = 0; w += 0; iw = 0; iw += 0; + mem = 0; (void) mem; w = 0; w += 0; iw = 0; iw += 0; real_t a0=arg[0] ? arg[0][3] : 0; if (res[0]!=0) res[0][0]=a0; a0=arg[0] ? arg[0][4] : 0; diff --git a/examples/c/chain_model/jac_chain_nm2.c b/examples/c/chain_model/jac_chain_nm2.c index a26f642ac3..3244d37750 100644 --- a/examples/c/chain_model/jac_chain_nm2.c +++ b/examples/c/chain_model/jac_chain_nm2.c @@ -42,7 +42,7 @@ static const int CASADI_PREFIX(s2)[] = {6, 6, 0, 6, 12, 18, 24, 30, 36, 0, 1, 2, #define s2 CASADI_PREFIX(s2) /* jacFun */ int jac_chain_nm2(void* mem, const real_t** arg, real_t** res, int* iw, real_t* w) { - mem = 0; mem += 0; w = 0; w += 0; iw = 0; iw += 0; + mem = 0; (void ) mem; w = 0; w += 0; iw = 0; iw += 0; real_t a0=arg[0] ? arg[0][3] : 0; if (res[0]!=0) res[0][0]=a0; a0=arg[0] ? arg[0][4] : 0; diff --git a/examples/c/chain_model/jac_chain_nm3.c b/examples/c/chain_model/jac_chain_nm3.c index cfe3913f89..3d9f495731 100644 --- a/examples/c/chain_model/jac_chain_nm3.c +++ b/examples/c/chain_model/jac_chain_nm3.c @@ -42,7 +42,7 @@ static const int CASADI_PREFIX(s2)[] = {12, 12, 0, 12, 24, 36, 48, 60, 72, 84, 9 #define s2 CASADI_PREFIX(s2) /* jacFun */ int jac_chain_nm3(void* mem, const real_t** arg, real_t** res, int* iw, real_t* w) { - mem = 0; mem += 0; w = 0; w += 0; iw = 0; iw += 0; + mem = 0; (void) mem; w = 0; w += 0; iw = 0; iw += 0; real_t a0=arg[0] ? arg[0][3] : 0; if (res[0]!=0) res[0][0]=a0; a0=arg[0] ? arg[0][4] : 0; diff --git a/examples/c/chain_model/jac_chain_nm4.c b/examples/c/chain_model/jac_chain_nm4.c index 3ce24aac64..a23628966c 100644 --- a/examples/c/chain_model/jac_chain_nm4.c +++ b/examples/c/chain_model/jac_chain_nm4.c @@ -42,7 +42,7 @@ static const int CASADI_PREFIX(s2)[] = {18, 18, 0, 18, 36, 54, 72, 90, 108, 126, #define s2 CASADI_PREFIX(s2) /* jacFun */ int jac_chain_nm4(void* mem, const real_t** arg, real_t** res, int* iw, real_t* w) { - mem = 0; mem += 0; w = 0; w += 0; iw = 0; iw += 0; + mem = 0; (void) mem; w = 0; w += 0; iw = 0; iw += 0; real_t a0=arg[0] ? arg[0][3] : 0; if (res[0]!=0) res[0][0]=a0; a0=arg[0] ? arg[0][4] : 0; diff --git a/examples/c/chain_model/jac_chain_nm5.c b/examples/c/chain_model/jac_chain_nm5.c index 1a2ce0a12a..2ed5d0d09b 100644 --- a/examples/c/chain_model/jac_chain_nm5.c +++ b/examples/c/chain_model/jac_chain_nm5.c @@ -42,7 +42,7 @@ static const int CASADI_PREFIX(s2)[] = {24, 24, 0, 24, 48, 72, 96, 120, 144, 168 #define s2 CASADI_PREFIX(s2) /* jacFun */ int jac_chain_nm5(void* mem, const real_t** arg, real_t** res, int* iw, real_t* w) { - mem = 0; mem += 0; w = 0; w += 0; iw = 0; iw += 0; + mem = 0; (void) mem; w = 0; w += 0; iw = 0; iw += 0; real_t a0=arg[0] ? arg[0][3] : 0; if (res[0]!=0) res[0][0]=a0; a0=arg[0] ? arg[0][4] : 0; diff --git a/examples/c/chain_model/jac_chain_nm6.c b/examples/c/chain_model/jac_chain_nm6.c index 4b3ac2f0a5..4584f2b410 100644 --- a/examples/c/chain_model/jac_chain_nm6.c +++ b/examples/c/chain_model/jac_chain_nm6.c @@ -42,7 +42,7 @@ static const int CASADI_PREFIX(s2)[] = {30, 30, 0, 30, 60, 90, 120, 150, 180, 21 #define s2 CASADI_PREFIX(s2) /* jacFun */ int jac_chain_nm6(void* mem, const real_t** arg, real_t** res, int* iw, real_t* w) { - mem = 0; mem += 0; w = 0; w += 0; iw = 0; iw += 0; + mem = 0; (void) mem; w = 0; w += 0; iw = 0; iw += 0; real_t a0=arg[0] ? arg[0][3] : 0; if (res[0]!=0) res[0][0]=a0; a0=arg[0] ? arg[0][4] : 0; diff --git a/examples/c/chain_model/jac_chain_nm7.c b/examples/c/chain_model/jac_chain_nm7.c index f872869b66..dd1073ee58 100644 --- a/examples/c/chain_model/jac_chain_nm7.c +++ b/examples/c/chain_model/jac_chain_nm7.c @@ -42,7 +42,7 @@ static const int CASADI_PREFIX(s2)[] = {36, 36, 0, 36, 72, 108, 144, 180, 216, 2 #define s2 CASADI_PREFIX(s2) /* jacFun */ int jac_chain_nm7(void* mem, const real_t** arg, real_t** res, int* iw, real_t* w) { - mem = 0; mem += 0; w = 0; w += 0; iw = 0; iw += 0; + mem = 0; (void) mem; w = 0; w += 0; iw = 0; iw += 0; real_t a0=arg[0] ? arg[0][3] : 0; if (res[0]!=0) res[0][0]=a0; a0=arg[0] ? arg[0][4] : 0; diff --git a/examples/c/chain_model/jac_chain_nm8.c b/examples/c/chain_model/jac_chain_nm8.c index 9bd9d5d800..c83cab731b 100644 --- a/examples/c/chain_model/jac_chain_nm8.c +++ b/examples/c/chain_model/jac_chain_nm8.c @@ -42,7 +42,7 @@ static const int CASADI_PREFIX(s2)[] = {42, 42, 0, 42, 84, 126, 168, 210, 252, 2 #define s2 CASADI_PREFIX(s2) /* jacFun */ int jac_chain_nm8(void* mem, const real_t** arg, real_t** res, int* iw, real_t* w) { - mem = 0; mem += 0; w = 0; w += 0; iw = 0; iw += 0; + mem = 0; (void) mem; w = 0; w += 0; iw = 0; iw += 0; real_t a0=arg[0] ? arg[0][3] : 0; if (res[0]!=0) res[0][0]=a0; a0=arg[0] ? arg[0][4] : 0; diff --git a/examples/c/chain_model/jac_chain_nm9.c b/examples/c/chain_model/jac_chain_nm9.c index 454750536d..2a0ea5fd9f 100644 --- a/examples/c/chain_model/jac_chain_nm9.c +++ b/examples/c/chain_model/jac_chain_nm9.c @@ -42,7 +42,7 @@ static const int CASADI_PREFIX(s2)[] = {48, 48, 0, 48, 96, 144, 192, 240, 288, 3 #define s2 CASADI_PREFIX(s2) /* jacFun */ int jac_chain_nm9(void* mem, const real_t** arg, real_t** res, int* iw, real_t* w) { - mem = 0; mem += 0; w = 0; w += 0; iw = 0; iw += 0; + mem = 0; (void) mem; w = 0; w += 0; iw = 0; iw += 0; real_t a0=arg[0] ? arg[0][3] : 0; if (res[0]!=0) res[0][0]=a0; a0=arg[0] ? arg[0][4] : 0; diff --git a/examples/c/chen_nmpc_hpmpc.c b/examples/c/chen_nmpc_hpmpc.c index 6facc68cf5..56352b9e3d 100644 --- a/examples/c/chen_nmpc_hpmpc.c +++ b/examples/c/chen_nmpc_hpmpc.c @@ -22,7 +22,7 @@ #include #include #include -#include + // flush denormals to zero #if defined(TARGET_X64_AVX2) || defined(TARGET_X64_AVX) || \ defined(TARGET_X64_SSE3) || defined(TARGET_X86_ATOM) || \ @@ -319,9 +319,9 @@ int main() { qp_out.pi = ppi; qp_out.lam = plam; - acado_timer timer; + acados_timer timer; real_t total_time = 0; - acado_tic(&timer); + acados_tic(&timer); for (int_t iter = 0; iter < max_iters; iter++) { // printf("\n------ ITERATION %d ------\n", iter); for (int_t sqp_iter = 0; sqp_iter < max_sqp_iters; sqp_iter++) { @@ -374,7 +374,7 @@ int main() { #ifdef DEBUG print_states_controls(&w[0], N); #endif // DEBUG - total_time = acado_toc(&timer); + total_time = acados_toc(&timer); printf("Average of %.3f ms per iteration.\n", 1e3*total_time/max_iters); // free(workspace); return 0; diff --git a/examples/c/chen_nmpc_qpoases.c b/examples/c/chen_nmpc_qpoases.c index 92259161d0..4f6bf2fe48 100644 --- a/examples/c/chen_nmpc_qpoases.c +++ b/examples/c/chen_nmpc_qpoases.c @@ -20,7 +20,7 @@ #include #include -#include "hpmpc/include/aux_d.h" +#include "blasfeo/include/blasfeo_d_aux_ext_dep.h" #include "acados/ocp_qp/ocp_qp_condensing_qpoases.h" #include "acados/sim/sim_erk_integrator.h" @@ -59,7 +59,6 @@ static void shift_controls(real_t *w, real_t *u_end, int_t N) { // Simple SQP example for acados int main() { // Problem data - int_t N = NN; real_t x0[NX] = {0.5, 0}; real_t w[NN*(NX+NU)+NX] = {0}; // States and controls stacked real_t Q[NX*NX] = {0}; @@ -112,27 +111,27 @@ int main() { int_t nu[NN] = {0}; int_t nb[NN+1] = {0}; int_t nc[NN+1] = {0}; - for (int_t i = 0; i < N; i++) { + for (int_t i = 0; i < NN; i++) { nx[i] = NX; nu[i] = NU; } - nx[N] = NX; + nx[NN] = NX; - real_t *pA[N]; - real_t *pB[N]; - real_t *pb[N]; - real_t *pQ[N+1]; - real_t *pS[N]; - real_t *pR[N]; - real_t *pq[N+1]; - real_t *pr[N]; - real_t *px[N+1]; - real_t *pu[N]; - real_t *ppi[N]; - real_t *plam[N+1]; + real_t *pA[NN]; + real_t *pB[NN]; + real_t *pb[NN]; + real_t *pQ[NN+1]; + real_t *pS[NN]; + real_t *pR[NN]; + real_t *pq[NN+1]; + real_t *pr[NN]; + real_t *px[NN+1]; + real_t *pu[NN]; + real_t *ppi[NN]; + real_t *plam[NN+1]; real_t *px0[1]; d_zeros(&px0[0], nx[0], 1); - for (int_t i = 0; i < N; i++) { + for (int_t i = 0; i < NN; i++) { d_zeros(&pA[i], nx[i+1], nx[i]); d_zeros(&pB[i], nx[i+1], nu[i]); d_zeros(&pb[i], nx[i+1], 1); @@ -144,13 +143,13 @@ int main() { d_zeros(&ppi[i], nx[i], 1); d_zeros(&plam[i], nb[i]+nc[i], 1); } - d_zeros(&pq[N], nx[N], 1); - d_zeros(&px[N], nx[N], 1); - d_zeros(&plam[N], nb[N]+nc[N], 1); + d_zeros(&pq[NN], nx[NN], 1); + d_zeros(&px[NN], nx[NN], 1); + d_zeros(&plam[NN], nb[NN]+nc[NN], 1); // Allocate OCP QP variables ocp_qp_in qp_in; - qp_in.N = N; + qp_in.N = NN; ocp_qp_out qp_out; ocp_qp_condensing_qpoases_args args; real_t *work = NULL; @@ -158,11 +157,11 @@ int main() { qp_in.nu = nu; qp_in.nb = nb; qp_in.nc = nc; - for (int_t i = 0; i < N; i++) { + for (int_t i = 0; i < NN; i++) { pQ[i] = Q; pR[i] = R; } - pQ[N] = Q; + pQ[NN] = Q; qp_in.Q = (const real_t **) pQ; qp_in.S = (const real_t **) pS; qp_in.R = (const real_t **) pR; @@ -177,13 +176,13 @@ int main() { qp_out.pi = ppi; qp_out.lam = plam; - acado_timer timer; + acados_timer timer; real_t total_time = 0; - acado_tic(&timer); + acados_tic(&timer); for (int_t iter = 0; iter < max_iters; iter++) { // printf("\n------ ITERATION %d ------\n", iter); for (int_t sqp_iter = 0; sqp_iter < max_sqp_iters; sqp_iter++) { - for (int_t i = 0; i < N; i++) { + for (int_t i = 0; i < NN; i++) { // Pass state and control to integrator for (int_t j = 0; j < NX; j++) sim_in.x[j] = w[i*(NX+NU)+j]; for (int_t j = 0; j < NU; j++) sim_in.u[j] = w[i*(NX+NU)+NX+j]; @@ -206,27 +205,27 @@ int main() { px0[0][j] = (x0[j]-w[j]); } for (int_t j = 0; j < NX; j++) { - pq[N][j] = Q[j*(NX+1)]*(w[N*(NX+NU)+j]-xref[j]); + pq[NN][j] = Q[j*(NX+1)]*(w[NN*(NX+NU)+j]-xref[j]); } int status = ocp_qp_condensing_qpoases(&qp_in, &qp_out, &args, NULL, work); if (status) { printf("qpOASES returned error status %d\n", status); return -1; } - for (int_t i = 0; i < N; i++) { + for (int_t i = 0; i < NN; i++) { for (int_t j = 0; j < NX; j++) w[i*(NX+NU)+j] += qp_out.x[i][j]; for (int_t j = 0; j < NU; j++) w[i*(NX+NU)+NX+j] += qp_out.u[i][j]; } - for (int_t j = 0; j < NX; j++) w[N*(NX+NU)+j] += qp_out.x[N][j]; + for (int_t j = 0; j < NX; j++) w[NN*(NX+NU)+j] += qp_out.x[NN][j]; } for (int_t i = 0; i < NX; i++) x0[i] = w[NX+NU+i]; - shift_states(w, x_end, N); - shift_controls(w, u_end, N); + shift_states(w, x_end, NN); + shift_controls(w, u_end, NN); } #ifdef DEBUG - print_states_controls(&w[0], N); + print_states_controls(&w[0], NN); #endif // DEBUG - total_time = acado_toc(&timer); // in seconds + total_time = acados_toc(&timer); // in seconds printf("Average of %.3f ms per iteration.\n", 1e3*total_time/max_iters); free(sim_in.x); @@ -236,7 +235,7 @@ int main() { free(sim_out.S_forw); d_free(px0[0]); - for (int_t i = 0; i < N; i++) { + for (int_t i = 0; i < NN; i++) { d_free(pA[i]); d_free(pB[i]); d_free(pb[i]); @@ -248,9 +247,9 @@ int main() { d_free(ppi[i]); d_free(plam[i]); } - d_free(pq[N]); - d_free(px[N]); - d_free(plam[N]); + d_free(pq[NN]); + d_free(px[NN]); + d_free(plam[NN]); free(rk_opts.A_mat); free(rk_opts.b_vec); diff --git a/examples/c/chen_sqp_hpmpc.c b/examples/c/chen_sqp_hpmpc.c index 191e2801a9..4fe2247ddc 100644 --- a/examples/c/chen_sqp_hpmpc.c +++ b/examples/c/chen_sqp_hpmpc.c @@ -331,7 +331,7 @@ int main() { qp_out.lam = plam; qp_out.t = pt; - acado_timer timer; + acados_timer timer; real_t total_time = 0; // Define residuals @@ -388,7 +388,7 @@ int main() { double mu_tol = 1e-6; for ( int_t i = 0; i < NX; i++ ) w[0][i] = x0[i]; - acado_tic(&timer); + acados_tic(&timer); while ( ip_iter < max_ip_iters && (!sol_found) ) { // Pass state and control to integrator for ( int_t j = 0; j < NX; j++ ) sim_in.x[j] = w[0][j]; @@ -753,7 +753,7 @@ int main() { } #endif // DEBUG - total_time = acado_toc(&timer); + total_time = acados_toc(&timer); printf("\n\nAverage of %.3f ms per iteration.\n", 1e3*total_time/timing_iters); // free(workspace); return 0; diff --git a/examples/c/chen_sqp_qpoases.c b/examples/c/chen_sqp_qpoases.c index 95887a93f1..d7dec752f2 100644 --- a/examples/c/chen_sqp_qpoases.c +++ b/examples/c/chen_sqp_qpoases.c @@ -190,7 +190,7 @@ int main() { initialise_qpoases(&qp_in); - acado_timer timer; + acados_timer timer; real_t total_time = 0; // Define residuals @@ -211,7 +211,7 @@ int main() { d_zeros(&res_ineq[ii], 2*nb[ii], 1); d_zeros(&res_compl[ii], 2*nb[ii], 1); - acado_tic(&timer); + acados_tic(&timer); for ( int_t iter = 0; iter < timing_iters; iter++ ) { for ( int_t i = 0; i < NX; i++ ) w[0][i] = x0[i]; @@ -299,7 +299,7 @@ int main() { #ifdef DEBUG print_states_controls(&w[0], N); #endif // DEBUG - total_time = acado_toc(&timer); + total_time = acados_toc(&timer); printf("Average of %.3f ms per iteration.\n", 1e3*total_time/timing_iters); free(sim_in.x); diff --git a/examples/c/linear_mpc.c b/examples/c/linear_mpc.c index b208340953..f532f26c22 100644 --- a/examples/c/linear_mpc.c +++ b/examples/c/linear_mpc.c @@ -41,7 +41,7 @@ int main() { int_t nMPC = 10; - acado_timer timer; + acados_timer timer; real_t *cputimes; d_zeros(&cputimes, 1, nMPC); @@ -202,9 +202,9 @@ int main() { } // solve QP - acado_tic(&timer); + acados_tic(&timer); ocp_qp_qpdunes(&qp_in, &qp_out, &args, &mem, work); - cputimes[kk] = 1000*acado_toc(&timer); + cputimes[kk] = 1000*acados_toc(&timer); // simulate system for (int ii = 0; ii < NX; ii++) { diff --git a/examples/c/mass_spring_hpmpc.c b/examples/c/mass_spring_hpmpc.c index 769b6cde23..49afc3ff1d 100644 --- a/examples/c/mass_spring_hpmpc.c +++ b/examples/c/mass_spring_hpmpc.c @@ -20,7 +20,7 @@ #include #include #include -#include + // flush denormals to zero #if defined(TARGET_X64_AVX2) || defined(TARGET_X64_AVX) || \ defined(TARGET_X64_SSE3) || defined(TARGET_X86_ATOM) || \ @@ -34,6 +34,7 @@ #include "acados/ocp_qp/ocp_qp_common.h" #include "acados/ocp_qp/ocp_qp_hpmpc.h" +#include "acados/utils/timing.h" #include "acados/utils/tools.h" #include "acados/utils/types.h" @@ -42,6 +43,8 @@ #define MAXITER 10 #define TOL 1e-8 #define MINSTEP 1e-8 +#define NN 15 + /************************************************ Mass-spring system: nx/2 masses connected each other with springs (in a row), @@ -166,7 +169,6 @@ int main() { // system test problem) int nu = 3; // number of inputs (controllers) (it has to be at least 1 and // at most nx/2 for the mass-spring system test problem) - int N = 15; // horizon length int nb = 11; // number of box constrained inputs and states int ng = 0; // 4; // number of general constraints int ngN = 4; // 4; // number of general constraints at the last stage @@ -177,22 +179,22 @@ int main() { int nbx = nb - nu > 0 ? nb - nu : 0; // stage-wise variant size - int nxx[N + 1]; + int nxx[NN + 1]; nxx[0] = 0; - for (ii = 1; ii <= N; ii++) nxx[ii] = nx; + for (ii = 1; ii <= NN; ii++) nxx[ii] = nx; - int nuu[N + 1]; - for (ii = 0; ii < N; ii++) nuu[ii] = nu; - nuu[N] = 0; + int nuu[NN + 1]; + for (ii = 0; ii < NN; ii++) nuu[ii] = nu; + nuu[NN] = 0; - int nbb[N + 1]; + int nbb[NN + 1]; nbb[0] = nbu; - for (ii = 1; ii < N; ii++) nbb[ii] = nb; - nbb[N] = nbx; + for (ii = 1; ii < NN; ii++) nbb[ii] = nb; + nbb[NN] = nbx; - int ngg[N + 1]; - for (ii = 0; ii < N; ii++) ngg[ii] = ng; - ngg[N] = ngN; + int ngg[NN + 1]; + for (ii = 0; ii < NN; ii++) ngg[ii] = ng; + ngg[NN] = ngN; printf( " Test problem: mass-spring system with %d masses and %d controls.\n", @@ -201,7 +203,7 @@ int main() { printf( " MPC problem size: %d states, %d inputs, %d horizon length, %d " "two-sided box constraints, %d two-sided general constraints.\n", - nx, nu, N, nb, ng); + nx, nu, NN, nb, ng); printf("\n"); printf( " IP method parameters: predictor-corrector IP, double precision, %d " @@ -295,18 +297,18 @@ int main() { // d_print_mat(nbb[1], 1, lb1, nbb[1]); int *idxbN; - int_zeros(&idxbN, nbb[N], 1); + int_zeros(&idxbN, nbb[NN], 1); double *lbN; - d_zeros(&lbN, nbb[N], 1); + d_zeros(&lbN, nbb[NN], 1); double *ubN; - d_zeros(&ubN, nbb[N], 1); + d_zeros(&ubN, nbb[NN], 1); for (jj = 0; jj < nbx; jj++) { lbN[jj] = -4.0; // umin ubN[jj] = 4.0; // umax idxbN[jj] = jj; } - // int_print_mat(nbb[N], 1, idxbN, nbb[N]); - // d_print_mat(nbb[N], 1, lbN, nbb[N]); + // int_print_mat(nbb[NN], 1, idxbN, nbb[NN]); + // d_print_mat(nbb[NN], 1, lbN, nbb[NN]); /************************************************ * general constraints @@ -373,21 +375,21 @@ int main() { * problems data ************************************************/ - double *hA[N]; - double *hB[N]; - double *hb[N]; - double *hQ[N + 1]; - double *hS[N]; - double *hR[N]; - double *hq[N + 1]; - double *hr[N]; - double *hlb[N + 1]; - double *hub[N + 1]; - int *hidxb[N + 1]; - double *hC[N + 1]; - double *hD[N]; - double *hlg[N + 1]; - double *hug[N + 1]; + double *hA[NN]; + double *hB[NN]; + double *hb[NN]; + double *hQ[NN + 1]; + double *hS[NN]; + double *hR[NN]; + double *hq[NN + 1]; + double *hr[NN]; + double *hlb[NN + 1]; + double *hub[NN + 1]; + int *hidxb[NN + 1]; + double *hC[NN + 1]; + double *hD[NN]; + double *hlg[NN + 1]; + double *hug[NN + 1]; hA[0] = A0; hB[0] = B; @@ -404,7 +406,7 @@ int main() { hD[0] = D; hlg[0] = lg; hug[0] = ug; - for (ii = 1; ii < N; ii++) { + for (ii = 1; ii < NN; ii++) { hA[ii] = A; hB[ii] = B; hb[ii] = b; @@ -421,45 +423,45 @@ int main() { hlg[ii] = lg; hug[ii] = ug; } - hQ[N] = Q; // or maybe initialize to the solution of the DARE??? - hq[N] = q; // or maybe initialize to the solution of the DARE??? - hlb[N] = lbN; - hub[N] = ubN; - hidxb[N] = idxbN; - hC[N] = CN; - hlg[N] = lgN; - hug[N] = ugN; + hQ[NN] = Q; // or maybe initialize to the solution of the DARE??? + hq[NN] = q; // or maybe initialize to the solution of the DARE??? + hlb[NN] = lbN; + hub[NN] = ubN; + hidxb[NN] = idxbN; + hC[NN] = CN; + hlg[NN] = lgN; + hug[NN] = ugN; /************************************************ * solution ************************************************/ - double *hx[N + 1]; - double *hu[N]; - double *hpi[N]; - double *hlam[N+1]; - double *ht[N+1]; + double *hx[NN + 1]; + double *hu[NN]; + double *hpi[NN]; + double *hlam[NN+1]; + double *ht[NN+1]; - for (ii = 0; ii < N; ii++) { + for (ii = 0; ii < NN; ii++) { d_zeros(&hx[ii], nxx[ii], 1); d_zeros(&hu[ii], nuu[ii], 1); d_zeros(&hpi[ii], nxx[ii+1], 1); d_zeros(&hlam[ii], 2*nbb[ii]+2*ngg[ii], 1); d_zeros(&ht[ii], 2*nbb[ii]+2*ngg[ii], 1); } - d_zeros(&hx[N], nxx[N], 1); - d_zeros(&hlam[N], 2*nbb[N]+2*ngg[N], 1); - d_zeros(&ht[N], 2*nbb[N]+2*ngg[N], 1); + d_zeros(&hx[NN], nxx[NN], 1); + d_zeros(&hlam[NN], 2*nbb[NN]+2*ngg[NN], 1); + d_zeros(&ht[NN], 2*nbb[NN]+2*ngg[NN], 1); /************************************************ * XXX initial guess ************************************************/ - double *hux_in[N+1]; - double *hlam_in[N+1]; - double *ht_in[N+1]; + double *hux_in[NN+1]; + double *hlam_in[NN+1]; + double *ht_in[NN+1]; - for (ii = 0; ii <= N; ii++) { + for (ii = 0; ii <= NN; ii++) { d_zeros(&hux_in[ii], nuu[ii]+nxx[ii], 1); d_zeros(&hlam_in[ii], 2*nbb[ii]+2*ngg[ii], 1); d_zeros(&ht_in[ii], 2*nbb[ii]+2*ngg[ii], 1); @@ -470,7 +472,7 @@ int main() { ************************************************/ ocp_qp_in qp_in; - qp_in.N = N; + qp_in.N = NN; qp_in.nx = (const int *) nxx; qp_in.nu = (const int *) nuu; qp_in.nb = (const int *) nbb; @@ -510,8 +512,8 @@ int main() { hpmpc_args.mu0 = 1.0; // 0.0 // hpmpc_args.sigma_min = 1e-3; hpmpc_args.warm_start = 0; - hpmpc_args.N2 = N; - hpmpc_args.M = N; + hpmpc_args.N2 = NN; + hpmpc_args.M = NN; double inf_norm_res[5] = {0.0, 0.0, 0.0, 0.0, 0.0}; hpmpc_args.inf_norm_res = &inf_norm_res[0]; @@ -525,9 +527,9 @@ int main() { ************************************************/ // int work_space_size = -// ocp_qp_hpmpc_workspace_size_bytes(N, nxx, nuu, nbb, ngg, hidxb, &hpmpc_args); +// ocp_qp_hpmpc_workspace_size_bytes(NN, nxx, nuu, nbb, ngg, hidxb, &hpmpc_args); int work_space_size = 0; -// for(int iii=0; iii<=N; iii++) printf("\n%d\n", qp_in.nb[iii]); +// for(int iii=0; iii<=NN; iii++) printf("\n%d\n", qp_in.nb[iii]); work_space_size = ocp_qp_hpmpc_calculate_workspace_size(&qp_in, &hpmpc_args); printf("\nwork space size: %d bytes\n", work_space_size); @@ -542,8 +544,8 @@ int main() { int return_value; - struct timeval tv0, tv1; - gettimeofday(&tv0, NULL); // stop + acados_timer tv0; + acados_tic(&tv0); // start // nrep = 1; for (rep = 0; rep < nrep; rep++) { @@ -552,7 +554,7 @@ int main() { return_value = ocp_qp_hpmpc(&qp_in, &qp_out, &hpmpc_args, mem, workspace); } - gettimeofday(&tv1, NULL); // stop + double time = acados_toc(&tv0); // stop if (return_value == ACADOS_SUCCESS) printf("\nACADOS status: solution found in %d iterations\n", hpmpc_args.out_iter); @@ -564,13 +566,10 @@ int main() { printf("\nACADOS status: below minimum step size length\n"); printf("\nu = \n"); - for (ii = 0; ii < N; ii++) d_print_mat(1, nuu[ii], hu[ii], 1); + for (ii = 0; ii < NN; ii++) d_print_mat(1, nuu[ii], hu[ii], 1); printf("\nx = \n"); - for (ii = 0; ii <= N; ii++) d_print_mat(1, nxx[ii], hx[ii], 1); - - double time = (tv1.tv_sec - tv0.tv_sec) / (nrep + 0.0) + - (tv1.tv_usec - tv0.tv_usec) / (nrep * 1e6); + for (ii = 0; ii <= NN; ii++) d_print_mat(1, nxx[ii], hx[ii], 1); printf("\n"); printf(" inf norm res: %e, %e, %e, %e, %e\n", inf_norm_res[0], inf_norm_res[1], \ @@ -600,14 +599,14 @@ int main() { * call the solver (partial condensing) ************************************************/ - gettimeofday(&tv0, NULL); // stop + acados_tic(&tv0); // start for (rep = 0; rep < nrep; rep++) { // call the QP OCP solver return_value = ocp_qp_hpmpc(&qp_in, &qp_out, &hpmpc_args, mem, workspace_part_cond); } - gettimeofday(&tv1, NULL); // stop + double time_part_cond = acados_toc(&tv0); // stop if (return_value == ACADOS_SUCCESS) printf("\nACADOS status: solution found in %d iterations\n", hpmpc_args.out_iter); @@ -619,13 +618,10 @@ int main() { printf("\nACADOS status: below minimum step size length\n"); printf("\nu = \n"); - for (ii = 0; ii < N; ii++) d_print_mat(1, nuu[ii], hu[ii], 1); + for (ii = 0; ii < NN; ii++) d_print_mat(1, nuu[ii], hu[ii], 1); printf("\nx = \n"); - for (ii = 0; ii <= N; ii++) d_print_mat(1, nxx[ii], hx[ii], 1); - - double time_part_cond = (tv1.tv_sec - tv0.tv_sec) / (nrep + 0.0) + - (tv1.tv_usec - tv0.tv_usec) / (nrep * 1e6); + for (ii = 0; ii <= NN; ii++) d_print_mat(1, nxx[ii], hx[ii], 1); printf("\n"); printf(" inf norm res: %e, %e, %e, %e, %e\n", inf_norm_res[0], inf_norm_res[1], \ @@ -671,16 +667,16 @@ int main() { d_free(lgN); d_free(ugN); - for (ii = 0; ii < N; ii++) { + for (ii = 0; ii < NN; ii++) { d_free(hx[ii]); d_free(hu[ii]); d_free(hpi[ii]); d_free(hlam[ii]); d_free(ht[ii]); } - d_free(hx[N]); - d_free(hlam[N]); - d_free(ht[N]); + d_free(hx[NN]); + d_free(hlam[NN]); + d_free(ht[NN]); free(workspace); #if 0 diff --git a/examples/c/mass_spring_hpmpc_libstr.c b/examples/c/mass_spring_hpmpc_libstr.c index 9a89b32b9e..12cd635483 100644 --- a/examples/c/mass_spring_hpmpc_libstr.c +++ b/examples/c/mass_spring_hpmpc_libstr.c @@ -20,7 +20,6 @@ #include #include #include -#include // flush denormals to zero #if defined(TARGET_X64_AVX2) || defined(TARGET_X64_AVX) || \ defined(TARGET_X64_SSE3) || defined(TARGET_X86_ATOM) || \ @@ -558,15 +557,15 @@ int main() { int return_value; - struct timeval tv0, tv1; - gettimeofday(&tv0, NULL); // stop + acados_timer tv0; + acados_tic(&tv0); // start for (rep = 0; rep < nrep; rep++) { // call the QP OCP solver return_value = ocp_qp_hpmpc_libstr(&qp_in, &qp_out, &hpmpc_args, workspace); } - gettimeofday(&tv1, NULL); // stop + double time = acados_toc(&tv0); // stop if (return_value == ACADOS_SUCCESS) printf("\nACADOS status: solution found\n"); @@ -583,9 +582,6 @@ int main() { printf("\nx = \n"); for (ii = 0; ii <= N; ii++) d_print_mat(1, nxx[ii], hx[ii], 1); - double time = (tv1.tv_sec - tv0.tv_sec) / (nrep + 0.0) + - (tv1.tv_usec - tv0.tv_usec) / (nrep * 1e6); - printf("\n"); printf(" Average solution time over %d runs: %5.2e seconds\n", nrep, time); printf("\n\n"); diff --git a/examples/c/mass_spring_partial_tightening.c b/examples/c/mass_spring_partial_tightening.c index 31db6bb4c9..586846e68d 100644 --- a/examples/c/mass_spring_partial_tightening.c +++ b/examples/c/mass_spring_partial_tightening.c @@ -20,7 +20,7 @@ #include #include #include -#include + // flush denormals to zero #if defined(TARGET_X64_AVX2) || defined(TARGET_X64_AVX) || \ defined(TARGET_X64_SSE3) || defined(TARGET_X86_ATOM) || \ @@ -33,6 +33,7 @@ #include "acados/ocp_qp/ocp_qp_common.h" #include "acados/ocp_qp/ocp_qp_hpmpc.h" +#include "acados/utils/timing.h" #include "acados/utils/tools.h" #include "acados/utils/types.h" @@ -588,15 +589,15 @@ int main() { int return_value; - struct timeval tv0, tv1; - gettimeofday(&tv0, NULL); // stop + acados_timer tv0; + acados_tic(&tv0); // start // call the QP OCP solver // return_value = ocp_qp_hpmpc_libstr(&qp_in, &qp_out, &hpmpc_args, workspace); return_value = ocp_qp_hpmpc_libstr_pt(&qp_in, &qp_out, &hpmpc_args, M, 0.1, workspace); - gettimeofday(&tv1, NULL); // stop + double time = acados_toc(&tv0); // stop if (return_value == ACADOS_SUCCESS) printf("\nACADOS status: solution found\n"); @@ -613,9 +614,6 @@ int main() { printf("\nx = \n"); for (ii = 0; ii <= N; ii++) d_print_mat(1, nxx[ii], hx[ii], 1); - double time = (tv1.tv_sec - tv0.tv_sec) / (nrep + 0.0) + - (tv1.tv_usec - tv0.tv_usec) / (nrep * 1e6); - printf("\n"); printf(" Average solution time over %d runs: %5.2e seconds\n", nrep, time); printf("\n\n"); diff --git a/examples/c/mass_spring_qpoases.c b/examples/c/mass_spring_qpoases.c index 96d8ddf9bb..049d1a40b3 100644 --- a/examples/c/mass_spring_qpoases.c +++ b/examples/c/mass_spring_qpoases.c @@ -21,17 +21,18 @@ #include #include #include -#include #include "blasfeo/include/blasfeo_target.h" #include "blasfeo/include/blasfeo_i_aux_ext_dep.h" #include "blasfeo/include/blasfeo_d_aux_ext_dep.h" #include "acados/ocp_qp/ocp_qp_condensing_qpoases.h" +#include "acados/utils/timing.h" #include "acados/utils/tools.h" // define number of repetitions #define NREP 10 +#define NN 20 // horizon length /************************************************ Mass-spring system: nx/2 masses connected each other with springs (in a row), @@ -126,7 +127,6 @@ int main() { // system test problem) int nu = 3; // number of inputs (controllers) (it has to be at least 1 and // at most nx/2 for the mass-spring system test problem) - int N = 20; // horizon length int nb = 11; // number of box constrained inputs and states int ng = 0; // 4; // number of general constraints int ngN = 8; // 4; // number of general constraints at the last stage @@ -135,21 +135,21 @@ int main() { int nbx = nb - nu > 0 ? nb - nu : 0; // stage-wise variant size - int nxx[N + 1]; - for (ii = 0; ii <= N; ii++) nxx[ii] = nx; + int nxx[NN + 1]; + for (ii = 0; ii <= NN; ii++) nxx[ii] = nx; - int nuu[N + 1]; - for (ii = 0; ii < N; ii++) nuu[ii] = nu; - nuu[N] = 0; + int nuu[NN + 1]; + for (ii = 0; ii < NN; ii++) nuu[ii] = nu; + nuu[NN] = 0; - int nbb[N + 1]; - for (ii = 0; ii < N; ii++) nbb[ii] = nb; - nbb[N] = nbx; + int nbb[NN + 1]; + for (ii = 0; ii < NN; ii++) nbb[ii] = nb; + nbb[NN] = nbx; - int ngg[N + 1]; - for (ii = 0; ii < N; ii++) ngg[ii] = ng; + int ngg[NN + 1]; + for (ii = 0; ii < NN; ii++) ngg[ii] = ng; ngg[0] = 1; - ngg[N] = ngN; + ngg[NN] = ngN; printf( " Test problem: mass-spring system with %d masses and %d controls.\n", @@ -158,7 +158,7 @@ int main() { printf( " MPC problem size: %d states, %d inputs, %d horizon length, %d " "two-sided box constraints, %d two-sided general constraints.\n", - nx, nu, N, nb, ng); + nx, nu, NN, nb, ng); printf("\n"); /************************************************ @@ -229,11 +229,11 @@ int main() { } int *idxbN; - int_zeros(&idxbN, nbb[N], 1); + int_zeros(&idxbN, nbb[NN], 1); double *lbN; - d_zeros(&lbN, nbb[N], 1); + d_zeros(&lbN, nbb[NN], 1); double *ubN; - d_zeros(&ubN, nbb[N], 1); + d_zeros(&ubN, nbb[NN], 1); for (jj = 0; jj < nbx; jj++) { lbN[jj] = -4.0; // umin ubN[jj] = +4.0; // umax @@ -304,21 +304,21 @@ int main() { ocp_qp_in qp_in; ocp_qp_out qp_out; - double *hA[N]; - double *hB[N]; - double *hb[N]; - double *hQ[N + 1]; - double *hS[N]; - double *hR[N]; - double *hq[N + 1]; - double *hr[N]; - double *hlb[N + 1]; - double *hub[N + 1]; - int *hidxb[N + 1]; - double *hC[N + 1]; - double *hD[N]; - double *hlg[N + 1]; - double *hug[N + 1]; + double *hA[NN]; + double *hB[NN]; + double *hb[NN]; + double *hQ[NN + 1]; + double *hS[NN]; + double *hR[NN]; + double *hq[NN + 1]; + double *hr[NN]; + double *hlb[NN + 1]; + double *hub[NN + 1]; + int *hidxb[NN + 1]; + double *hC[NN + 1]; + double *hD[NN]; + double *hlg[NN + 1]; + double *hug[NN + 1]; hA[0] = A; hB[0] = B; @@ -335,7 +335,7 @@ int main() { hD[0] = D0; hlg[0] = lg0; hug[0] = ug0; - for (ii = 1; ii < N; ii++) { + for (ii = 1; ii < NN; ii++) { hA[ii] = A; hB[ii] = B; hb[ii] = b; @@ -352,30 +352,30 @@ int main() { hlg[ii] = lg; hug[ii] = ug; } - hQ[N] = Q; // or maybe initialize to the solution of the DARE??? - hq[N] = q; // or maybe initialize to the solution of the DARE??? - hlb[N] = lbN; - hub[N] = ubN; - hidxb[N] = idxbN; - hC[N] = CN; - hlg[N] = lgN; - hug[N] = ugN; + hQ[NN] = Q; // or maybe initialize to the solution of the DARE??? + hq[NN] = q; // or maybe initialize to the solution of the DARE??? + hlb[NN] = lbN; + hub[NN] = ubN; + hidxb[NN] = idxbN; + hC[NN] = CN; + hlg[NN] = lgN; + hug[NN] = ugN; /************************************************ * solution ************************************************/ - double *hx[N + 1]; - double *hu[N + 1]; - double *hpi[N + 1]; - for (ii = 0; ii < N; ii++) { + double *hx[NN + 1]; + double *hu[NN + 1]; + double *hpi[NN + 1]; + for (ii = 0; ii < NN; ii++) { d_zeros(&hx[ii], nxx[ii], 1); d_zeros(&hu[ii], nuu[ii], 1); d_zeros(&hpi[ii], nxx[ii+1], 1); } - d_zeros(&hx[N], nxx[N], 1); + d_zeros(&hx[NN], nxx[NN], 1); - qp_in.N = N; + qp_in.N = NN; qp_in.nx = nxx; qp_in.nu = nuu; qp_in.nb = nbb; @@ -422,24 +422,22 @@ int main() { ************************************************/ int return_value; - struct timeval tv0, tv1; - gettimeofday(&tv0, NULL); // stop + + acados_timer tv0; + acados_tic(&tv0); // start for (int rep = 0; rep < nrep; rep++) { // call the QP OCP solver return_value = ocp_qp_condensing_qpoases(&qp_in, &qp_out, &args, NULL, NULL); } - gettimeofday(&tv1, NULL); // stop - - double time = (tv1.tv_sec - tv0.tv_sec) / (nrep + 0.0) + - (tv1.tv_usec - tv0.tv_usec) / (nrep * 1e6); + double time = acados_toc(&tv0); // stop printf("\nu = \n"); - for (ii = 0; ii < N; ii++) d_print_mat(1, nuu[ii], hu[ii], 1); + for (ii = 0; ii < NN; ii++) d_print_mat(1, nuu[ii], hu[ii], 1); printf("\nx = \n"); - for (ii = 0; ii <= N; ii++) d_print_mat(1, nxx[ii], hx[ii], 1); + for (ii = 0; ii <= NN; ii++) d_print_mat(1, nxx[ii], hx[ii], 1); printf("\n"); printf(" Average solution time over %d runs: %5.2e seconds\n", nrep, time); @@ -485,11 +483,11 @@ int main() { d_free(lgN); d_free(ugN); - for (ii = 0; ii < N; ii++) { + for (ii = 0; ii < NN; ii++) { d_free(hx[ii]); d_free(hu[ii]); } - d_free(hx[N]); + d_free(hx[NN]); return 0; } diff --git a/examples/c/nonlinear_chain_sqp.c b/examples/c/nonlinear_chain_sqp.c index 572bc7cbaf..3cdd5d1f14 100644 --- a/examples/c/nonlinear_chain_sqp.c +++ b/examples/c/nonlinear_chain_sqp.c @@ -46,18 +46,18 @@ extern int vde_chain_nm7(const real_t** arg, real_t** res, int* iw, real_t* w, i extern int vde_chain_nm8(const real_t** arg, real_t** res, int* iw, real_t* w, int mem); extern int vde_chain_nm9(const real_t** arg, real_t** res, int* iw, real_t* w, int mem); -// static void shift_states(real_t *w, real_t *x_end, int_t N) { -// for (int_t i = 0; i < N; i++) { +// static void shift_states(real_t *w, real_t *x_end, int_t NN) { +// for (int_t i = 0; i < NN; i++) { // for (int_t j = 0; j < NX; j++) w[i*(NX+NU)+j] = w[(i+1)*(NX+NU)+j]; // } -// for (int_t j = 0; j < NX; j++) w[N*(NX+NU)+j] = x_end[j]; +// for (int_t j = 0; j < NX; j++) w[NN*(NX+NU)+j] = x_end[j]; // } // -// static void shift_controls(real_t *w, real_t *u_end, int_t N) { -// for (int_t i = 0; i < N-1; i++) { +// static void shift_controls(real_t *w, real_t *u_end, int_t NN) { +// for (int_t i = 0; i < NN-1; i++) { // for (int_t j = 0; j < NU; j++) w[i*(NX+NU)+NX+j] = w[(i+1)*(NX+NU)+NX+j]; // } -// for (int_t j = 0; j < NU; j++) w[(N-1)*(NX+NU)+NX+j] = u_end[j]; +// for (int_t j = 0; j < NU; j++) w[(NN-1)*(NX+NU)+NX+j] = u_end[j]; // } // Simple SQP example for acados @@ -83,7 +83,6 @@ int main() { int_t jj; // Problem data - int_t N = NN; real_t *x0; real_t *w; // States and controls stacked real_t *Q; @@ -267,11 +266,11 @@ int main() { int_t nu[NN] = {0}; int_t nb[NN+1] = {0}; int_t nc[NN+1] = {0}; - for (int_t i = 0; i < N; i++) { + for (int_t i = 0; i < NN; i++) { nx[i] = NX; nu[i] = NU; } - nx[N] = NX; + nx[NN] = NX; /************************************************ * box constraints @@ -297,9 +296,9 @@ int main() { int *idxb1; int_zeros(&idxb1, NU, 1); - double *lb1[N-1]; - double *ub1[N-1]; - for (int_t i = 0; i < N-1; i++) { + double *lb1[NN-1]; + double *ub1[NN-1]; + for (int_t i = 0; i < NN-1; i++) { d_zeros(&lb1[i], NU, 1); d_zeros(&ub1[i], NU, 1); // for (jj = 0; jj < nbx; jj++) { @@ -314,18 +313,18 @@ int main() { } } - real_t *pA[N]; - real_t *pB[N]; - real_t *pb[N]; - real_t *pQ[N+1]; - real_t *pS[N]; - real_t *pR[N]; - real_t *pq[N+1]; - real_t *pr[N]; - real_t *px[N+1]; - real_t *pu[N]; - real_t *ppi[N]; - for (int_t i = 0; i < N; i++) { + real_t *pA[NN]; + real_t *pB[NN]; + real_t *pb[NN]; + real_t *pQ[NN+1]; + real_t *pS[NN]; + real_t *pR[NN]; + real_t *pq[NN+1]; + real_t *pr[NN]; + real_t *px[NN+1]; + real_t *pu[NN]; + real_t *ppi[NN]; + for (int_t i = 0; i < NN; i++) { d_zeros(&pA[i], nx[i+1], nx[i]); d_zeros(&pB[i], nx[i+1], nu[i]); d_zeros(&pb[i], nx[i+1], 1); @@ -336,17 +335,17 @@ int main() { d_zeros(&pu[i], nu[i], 1); d_zeros(&ppi[i], nx[i+1], 1); } - d_zeros(&pq[N], nx[N], 1); - d_zeros(&px[N], nx[N], 1); + d_zeros(&pq[NN], nx[NN], 1); + d_zeros(&px[NN], nx[NN], 1); - real_t *hlb[N+1]; - real_t *hub[N+1]; - int *hidxb[N+1]; + real_t *hlb[NN+1]; + real_t *hub[NN+1]; + int *hidxb[NN+1]; hlb[0] = lb0; hub[0] = ub0; hidxb[0] = idxb0; - for (int_t i = 1; i < N; i++) { + for (int_t i = 1; i < NN; i++) { hlb[i] = lb1[i-1]; hub[i] = ub1[i-1]; hidxb[i] = idxb1; @@ -355,7 +354,7 @@ int main() { // Allocate OCP QP variables ocp_qp_in qp_in; - qp_in.N = N; + qp_in.N = NN; ocp_qp_out qp_out; ocp_qp_condensing_qpoases_args args; real_t *work = NULL; @@ -363,11 +362,11 @@ int main() { qp_in.nu = nu; qp_in.nb = nb; qp_in.nc = nc; - for (int_t i = 0; i < N; i++) { + for (int_t i = 0; i < NN; i++) { pQ[i] = Q; pR[i] = R; } - pQ[N] = Q; + pQ[NN] = Q; qp_in.Q = (const real_t **) pQ; qp_in.S = (const real_t **) pS; qp_in.R = (const real_t **) pR; @@ -383,7 +382,7 @@ int main() { qp_out.u = pu; qp_out.pi = ppi; - acado_timer timer; + acados_timer timer; real_t timings = 0; real_t timings_sim = 0; real_t timings_la = 0; @@ -391,14 +390,14 @@ int main() { // for (int_t iter = 0; iter < max_iters; iter++) { // printf("\n------ TIME STEP %d ------\n", iter); - acado_tic(&timer); + acados_tic(&timer); for (int_t sqp_iter = 0; sqp_iter < max_sqp_iters; sqp_iter++) { feas = -1e10; stepX = -1e10; stepU = -1e10; #if PARALLEL #pragma omp parallel for #endif - for (int_t i = 0; i < N; i++) { + for (int_t i = 0; i < NN; i++) { // Pass state and control to integrator for (int_t j = 0; j < NX; j++) sim_in[i].x[j] = w[i*(NX+NU)+j]; for (int_t j = 0; j < NU; j++) sim_in[i].u[j] = w[i*(NX+NU)+NX+j]; @@ -422,7 +421,7 @@ int main() { timings_la += sim_out[i].info->LAtime; timings_ad += sim_out[i].info->ADtime; } - for (int_t i = 0; i < N; i++) { + for (int_t i = 0; i < NN; i++) { // Update bounds: if ( i == 0 ) { for (int_t j = 0; j < NU; j++) { @@ -448,13 +447,13 @@ int main() { lb0[j] = (x0[j]-w[j]); } for (int_t j = 0; j < NX; j++) { - pq[N][j] = Q[j*(NX+1)]*(w[N*(NX+NU)+j]-xref[j]); + pq[NN][j] = Q[j*(NX+1)]*(w[NN*(NX+NU)+j]-xref[j]); } // Set updated bounds: hlb[0] = lb0; hub[0] = ub0; - for (int_t i = 1; i < N; i++) { + for (int_t i = 1; i < NN; i++) { hlb[i] = lb1[i-1]; hub[i] = ub1[i-1]; } @@ -465,7 +464,7 @@ int main() { printf("qpOASES returned error status %d\n", status); return -1; } - for (int_t i = 0; i < N; i++) { + for (int_t i = 0; i < NN; i++) { for (int_t j = 0; j < NX; j++) { w[i*(NX+NU)+j] += qp_out.x[i][j]; if (fabs(qp_out.x[i][j]) > stepX) stepX = fabs(qp_out.x[i][j]); @@ -476,8 +475,8 @@ int main() { } } for (int_t j = 0; j < NX; j++) { - w[N*(NX+NU)+j] += qp_out.x[N][j]; - if (fabs(qp_out.x[N][j]) > stepX) stepX = fabs(qp_out.x[N][j]); + w[NN*(NX+NU)+j] += qp_out.x[NN][j]; + if (fabs(qp_out.x[NN][j]) > stepX) stepX = fabs(qp_out.x[NN][j]); } if (sqp_iter == max_sqp_iters-1) { @@ -486,9 +485,9 @@ int main() { } } // for (int_t i = 0; i < NX; i++) x0[i] = w[NX+NU+i]; -// shift_states(w, x_end, N); -// shift_controls(w, u_end, N); - timings += acado_toc(&timer); +// shift_states(w, x_end, NN); +// shift_controls(w, u_end, NN); + timings += acados_toc(&timer); // } #ifdef MEASURE_TIMINGS @@ -503,7 +502,7 @@ int main() { 1e3*timings/(max_sqp_iters*max_iters)); // #ifdef DEBUG -// print_matrix_name("stdout", "sol", w, NX+NU, N); +// print_matrix_name("stdout", "sol", w, NX+NU, NN); // #endif // DEBUG } } diff --git a/examples/c/pendulum_hpmpc_libstr.c b/examples/c/pendulum_hpmpc_libstr.c index 7b27c61de5..4dcfe963d2 100644 --- a/examples/c/pendulum_hpmpc_libstr.c +++ b/examples/c/pendulum_hpmpc_libstr.c @@ -27,7 +27,6 @@ #include #include #include -#include // flush denormals to zero #if defined(TARGET_X64_AVX2) || defined(TARGET_X64_AVX) || \ defined(TARGET_X64_SSE3) || defined(TARGET_X86_ATOM) || \ @@ -468,9 +467,9 @@ int main() { qp_out.pi = ppi; qp_out.lam = plam; - acado_timer timer; + acados_timer timer; real_t total_time = 0; - acado_tic(&timer); + acados_tic(&timer); for (int_t iter = 0; iter < max_iters; iter++) { // printf("\n------ ITERATION %d ------\n", iter); for ( int_t ii = 0; ii < NX; ii++ ) w[ii] = x0[ii]; @@ -540,7 +539,7 @@ int main() { plot_states_controls(w, T); #endif // PLOT_RESULTS - total_time += acado_toc(&timer); + total_time += acados_toc(&timer); printf("Average of %.3f ms per iteration.\n", 1e3*total_time/max_iters); free(workspace); return 0; diff --git a/examples/c/pendulum_partial_tightening.c b/examples/c/pendulum_partial_tightening.c index 47ecc8c5fa..3702adf5a8 100644 --- a/examples/c/pendulum_partial_tightening.c +++ b/examples/c/pendulum_partial_tightening.c @@ -27,8 +27,6 @@ #include #include #include -#include -// #include // flush denormals to zero #if defined(TARGET_X64_AVX2) || defined(TARGET_X64_AVX) || \ @@ -592,7 +590,7 @@ int main() { v_zeros_align(&workspace, work_space_size); ocp_qp_hpmpc_create_memory(&qp_in, &hpmpc_args, &mem); - acado_timer timer; + acados_timer timer; real_t timings = 0; real_t sum_timings = 0; real_t min_timings = 1000000; @@ -624,7 +622,7 @@ int main() { for (int_t sim_iter = 0; sim_iter < NSIM; sim_iter++) { for (int_t iter = 0; iter < NREP; iter++) { - acado_tic(&timer); + acados_tic(&timer); // initialize nlp dual variables for (int_t i = M; i < N; i++) { for (int_t j = 0; j < 2*nb[i]+2*ngg[i]; j++) { @@ -687,7 +685,7 @@ int main() { // for (int_t i = 0; i < NX; i++) x0[i] = w[NX+NU+i]; // shift_states(w, x_end, N); // shift_controls(w, u_end, N); - timings = acado_toc(&timer); + timings = acados_toc(&timer); sum_timings+=timings; if (timings < min_timings) min_timings = timings; } diff --git a/experimental/dang/esp32/script_test_nmpc_qpoases/esp32_specific/main.c b/experimental/dang/esp32/script_test_nmpc_qpoases/esp32_specific/main.c index 78fe608450..3130b1bf2e 100644 --- a/experimental/dang/esp32/script_test_nmpc_qpoases/esp32_specific/main.c +++ b/experimental/dang/esp32/script_test_nmpc_qpoases/esp32_specific/main.c @@ -205,13 +205,13 @@ qp_out.x = px; qp_out.u = pu; printf("Free heap size before initializing qpoases: %d\n",esp_get_free_heap_size()); // for debug -acado_timer timer; +acados_timer timer; // real_t timings = 0; // move creator out of the loop timings = 0; for (int_t iter = 0; iter < max_iters; iter++) { // printf("\n------ ITERATION %d ------\n", iter); - acado_tic(&timer); + acados_tic(&timer); for (int_t sqp_iter = 0; sqp_iter < max_sqp_iters; sqp_iter++) { for (int_t i = 0; i < N; i++) { // Pass state and control to integrator @@ -253,7 +253,7 @@ for (int_t iter = 0; iter < max_iters; iter++) { for (int_t i = 0; i < NX; i++) x0[i] = w[NX+NU+i]; shift_states(w, x_end, N); shift_controls(w, u_end, N); - timings += acado_toc(&timer); + timings += acados_toc(&timer); } printf("Free heap size: %d\n",esp_get_free_heap_size()); // for debug diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 21f0c012c4..9f876883de 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -20,8 +20,10 @@ set(TARGET "GENERIC" CACHE STRING "Target architecture") set(LA "HIGH_PERFORMANCE" CACHE STRING "Linear algebra optimization level") add_subdirectory(blasfeo) -include(external/hpmpc) -add_subdirectory(hpipm) +if(NOT CMAKE_C_COMPILER_ID MATCHES "MSVC") + include(external/hpmpc) + add_subdirectory(hpipm) +endif() add_subdirectory(qpDUNES-dev) add_subdirectory(qpOASES) if (NOT CMAKE_BUILD_TYPE MATCHES NoExternalLibs) diff --git a/external/blasfeo b/external/blasfeo index 8f0b5b89ef..c9176b1618 160000 --- a/external/blasfeo +++ b/external/blasfeo @@ -1 +1 @@ -Subproject commit 8f0b5b89ef054b375033f3fd93ee2608621f9082 +Subproject commit c9176b161844c3900308850a7c44d36dbae531af diff --git a/external/hpipm b/external/hpipm index 0b4b13530a..5125656e85 160000 --- a/external/hpipm +++ b/external/hpipm @@ -1 +1 @@ -Subproject commit 0b4b13530a3895d8341af10ac849ab73e9ffc42e +Subproject commit 5125656e85c6c2c9e38d70f0c10c055fd08c42c6 diff --git a/external/qpDUNES-dev b/external/qpDUNES-dev index 2c8d166f36..1b78be2ed2 160000 --- a/external/qpDUNES-dev +++ b/external/qpDUNES-dev @@ -1 +1 @@ -Subproject commit 2c8d166f3607e97fa1bd6b8b57d32691104b05a1 +Subproject commit 1b78be2ed2be37b00d1905b03c810c7aadbec1a9 diff --git a/external/qpOASES/CMakeLists.txt b/external/qpOASES/CMakeLists.txt index c66ac45d83..68dd2acdfd 100644 --- a/external/qpOASES/CMakeLists.txt +++ b/external/qpOASES/CMakeLists.txt @@ -67,7 +67,10 @@ if(CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang") add_definitions(-D__SUPPRESSANYOUTPUT__) add_definitions(-D__NO_STATIC__) elseif(CMAKE_C_COMPILER_ID MATCHES "MSVC") - set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -nologo -EHsc -DWIN32") + set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -nologo -EHsc") + add_definitions(-DWIN32) + add_definitions(-D__SUPPRESSANYOUTPUT__) + add_definitions(-D__NO_STATIC__) endif() set(CMAKE_C_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D__DEBUG__") @@ -80,11 +83,15 @@ set(CMAKE_C_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D__DEBUG__") file(GLOB SRC src/*.c) # library -add_library(qpOASES_e STATIC ${SRC}) +add_library(qpOASES_e ${SRC}) target_include_directories(qpOASES_e PUBLIC $ $) -target_link_libraries(qpOASES_e m) + +if(CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang") + target_link_libraries(qpOASES_e m) +endif() + install(TARGETS qpOASES_e EXPORT qpOASES_eConfig LIBRARY DESTINATION lib ARCHIVE DESTINATION lib