Skip to content

Commit

Permalink
Appveyor CI - MSVC - N.6
Browse files Browse the repository at this point in the history
  • Loading branch information
darioizzo committed Sep 16, 2019
1 parent 7a9a8c3 commit db2859d
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ matrix:
packages:
- clang-7
- env: PAGMO_PLUGINS_NONFREE_BUILD="Python37"
- dist: bionic
dist: bionic
compiler: gcc
os: linux
addons:
Expand Down
1 change: 0 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ install:

# Rename sh.exe as sh.exe in PATH interferes with MinGW.
- if [%BUILD_TYPE%]==[MinGW_64_Debug] rename "C:\Program Files\Git\usr\bin\sh.exe" "sh2.exe"

- if [%BUILD_TYPE%]==[MinGW_64_Python27] rename "C:\Program Files\Git\usr\bin\sh.exe" "sh2.exe"
- if [%BUILD_TYPE%]==[MinGW_64_Python36] rename "C:\Program Files\Git\usr\bin\sh.exe" "sh2.exe"
- if [%BUILD_TYPE%]==[MinGW_64_Python37] rename "C:\Program Files\Git\usr\bin\sh.exe" "sh2.exe"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void SetWorhpPrint(worhp_print_t l1) {}

void WorhpVersion(int *major, int *minor, char patch[PATCH_STRING_LENGTH])
{
#ifdef __STDC_LIB_EXT1__
#ifdef __STDC_LIB_EXT1__ //Avoiding a warning in MSVC builds
strcpy_s(patch, sizeof(char) * PATCH_STRING_LENGTH, "1");
#else
strcpy(patch, "1");
Expand Down
8 changes: 4 additions & 4 deletions include/pagmo_plugins_nonfree/snopt7.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ see https://www.gnu.org/licenses/. */

#include <boost/type_traits/is_object.hpp>
#include <limits> // std::numeric_limits
#include <map>
#include <mutex>
#include <pagmo/algorithms/not_population_based.hpp>
#include <pagmo/population.hpp>
#include <string>
#include <map>
#include <vector>

#include <pagmo_plugins_nonfree/detail/visibility.hpp>
Expand Down Expand Up @@ -218,11 +218,11 @@ class PPNF_DLL_PUBLIC snopt7 : public not_population_based
* be activated.
*
* @param screen_output when ``true`` will activate the screen output from the SNOPT7 library, otherwise
* will let pagmo regulate logs and screen_output via its pagmo::algorithm::set_verbosity mechanism.
* will let pagmo regulate logs and screen_output via its pagmo::algorithm::set_verbosity mechanism.
* @param snopt7_c_library The path to the snopt7_c library.
* @param minor_version The minor version of your Snopt7 library. Only two APIs are supported at the
* moment: a) 7.2 - 7.6 and b) 7.7. You may try to use this plugin with different minor version numbers, but at your
* own risk.
* moment: a) 7.2 - 7.6 and b) 7.7. You may try to use this plugin with different minor version numbers, but at your
* own risk.
*
*/
snopt7(bool screen_output = false, std::string snopt7_c_library = "/usr/local/lib/libsnopt7_c.so",
Expand Down
9 changes: 0 additions & 9 deletions include/pagmo_plugins_nonfree/worhp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,6 @@ class PPNF_DLL_PUBLIC worhp : public not_population_based
* @param worhp_library The filename, including the absolute path, of the worhp library.
*
*/
/// Mutex type to protect the library load.
using mutex_t = std::mutex;

worhp(bool screen_output = false, std::string worhp_library = "/usr/local/lib/libworhp.so");
population evolve(population pop) const;
void set_verbosity(unsigned n);
Expand Down Expand Up @@ -208,9 +205,6 @@ class PPNF_DLL_PUBLIC worhp : public not_population_based
return seed;
}
};
// Used to suppress screen output from worhp
static void no_screen_output(int, const char[]);

// Log update and print to screen
void update_log(const problem &prob, const vector_double &fit, long long unsigned fevals0) const;
// Objective function
Expand Down Expand Up @@ -256,9 +250,6 @@ class PPNF_DLL_PUBLIC worhp : public not_population_based
void load(Archive &ar) = delete;
template <typename Archive>
void save(Archive &ar) const = delete;

// A mutex to protect the library load
static mutex_t m_library_load_mutex;
};

} // namespace pagmo
Expand Down
10 changes: 5 additions & 5 deletions src/snopt7.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,11 @@ snopt7::snopt7(bool screen_output, std::string snopt7_c_library, unsigned minor_
*
* The definitions of feasibility are different for SNOPT7 and pagmo. SNOPT7 requires that *max(c_viol)/||x|| <=
* eps_r* where *||x||* is the Euclidean norm of *x*, a candidate solution vector, and *eps_r* is the "Major
* feasibility tolerance" option in SNOPT7. In contrast, pagmo requires that *c_viol <= c_tol* where *c_viol* is the
* vector of absolute values of the nonlinear constraint violations and *c_tol* is the vector of constraint tolerances
* in pagmo::problem. To guarantee feasibility with respect to pagmo when SNOPT7 reports feasibility, try setting *eps_r
* <= min(c_tol)/||x||_ub*, where *||x||_ub* is an upper bound on the value of *||x||*. Care must be taken with this
* approach to ensure *eps_r* is not too small.
* feasibility tolerance" option in SNOPT7. In contrast, pagmo requires that *c_viol <= c_tol* where *c_viol* is the
* vector of absolute values of the nonlinear constraint violations and *c_tol* is the vector of constraint
* tolerances in pagmo::problem. To guarantee feasibility with respect to pagmo when SNOPT7 reports feasibility, try
* setting *eps_r <= min(c_tol)/||x||_ub*, where *||x||_ub* is an upper bound on the value of *||x||*. Care must be
* taken with this approach to ensure *eps_r* is not too small.
*
* .. seealso::
*
Expand Down
26 changes: 14 additions & 12 deletions src/worhp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ see https://www.gnu.org/licenses/. */
#include <unordered_map>
#include <vector>

#include <pagmo_plugins_nonfree/worhp.hpp>
#include "../include/pagmo_plugins_nonfree/bogus_libs/worhp_lib/worhp_bogus.h"
#include <pagmo_plugins_nonfree/worhp.hpp>

namespace pagmo
{
Expand All @@ -97,12 +97,16 @@ struct worhp_raii {
Control *m_c;
std::function<void(OptVar *, Workspace *, Params *, Control *)> m_WorhpFree;
};
namespace
{
// Used to suppress screen output from worhp
void no_screen_output(int, const char[]){};
// Mutex to protect the library loading.
std::mutex library_load_mutex;
} // namespace

} // end of namespace detail

// Mutex to protect the library loading.
worhp::mutex_t worhp::m_library_load_mutex;

/// Constructor.
/**
* The algorithm WORHP can be constructed in two different ways. According to the user
Expand All @@ -116,7 +120,9 @@ worhp::mutex_t worhp::m_library_load_mutex;
*/
worhp::worhp(bool screen_output, std::string worhp_library)
: m_worhp_library(worhp_library), m_integer_opts(), m_numeric_opts(), m_bool_opts(), m_screen_output(screen_output),
m_verbosity(0), m_log(){}
m_verbosity(0), m_log()
{
}

/// Evolve population.
/**
Expand Down Expand Up @@ -197,7 +203,7 @@ population worhp::evolve(population pop) const
// We then try to load the library at run time and locate the symbols used.
try {
// Here we import at runtime the worhp library and protect the whole try block with a mutex
std::lock_guard<std::mutex> lock(m_library_load_mutex);
std::lock_guard<std::mutex> lock(detail::library_load_mutex);
if (!boost::filesystem::is_regular_file(library_filename)) {
pagmo_throw(std::invalid_argument,
"The worhp library file name was constructed to be: " + library_filename.string()
Expand Down Expand Up @@ -332,10 +338,10 @@ We report the exact text of the original exception thrown:
int n_xml_param;
if (m_verbosity) { // pagmo log is active
ReadParams(&n_xml_param, const_cast<char *>("param.xml"), &par);
SetWorhpPrint(no_screen_output);
SetWorhpPrint(detail::no_screen_output);
} else {
if (!m_screen_output) { // pagmo log is active
SetWorhpPrint(no_screen_output);
SetWorhpPrint(detail::no_screen_output);
}
ReadParams(&n_xml_param, const_cast<char *>("param.xml"), &par);
}
Expand Down Expand Up @@ -993,9 +999,6 @@ void worhp::serialize(Archive &ar, unsigned)
m_f_cache, m_g_cache);
}

// Used to suppress screen output from worhp
void worhp::no_screen_output(int, const char[]){}

// Log update and print to screen
void worhp::update_log(const problem &prob, const vector_double &fit, long long unsigned fevals0) const
{
Expand Down Expand Up @@ -1141,4 +1144,3 @@ vector_double worhp::gradient_with_cache(const vector_double &x, const problem &
} // namespace pagmo

PAGMO_S11N_ALGORITHM_IMPLEMENT(pagmo::worhp)

0 comments on commit db2859d

Please sign in to comment.