-/* Copyright (c) 2007-2010 Massachusetts Institute of Technology
+/* Copyright (c) 2007-2011 Massachusetts Institute of Technology
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
void mythrow(nlopt_result ret) const {
switch (ret) {
- case NLOPT_FAILURE: throw std::runtime_error("nlopt failure");
+ case NLOPT_FAILURE: throw std::runtime_error(get_errmsg() ? get_errmsg() : "nlopt failure");
case NLOPT_OUT_OF_MEMORY: throw std::bad_alloc();
- case NLOPT_INVALID_ARGS: throw std::invalid_argument("nlopt invalid argument");
+ case NLOPT_INVALID_ARGS: throw std::invalid_argument(get_errmsg() ? get_errmsg() : "nlopt invalid argument");
case NLOPT_ROUNDOFF_LIMITED: throw roundoff_limited();
case NLOPT_FORCED_STOP: throw forced_stop();
default: break;
NLOPT_GETSET(int, force_stop)
void force_stop() { set_force_stop(1); }
+ const char *get_errmsg() const {
+ if (!o) throw std::runtime_error("uninitialized nlopt::opt");
+ return nlopt_get_errmsg(o);
+ }
+
// algorithm-specific parameters:
void set_local_optimizer(const opt &lo) {
}
NLOPT_GETSET(unsigned, population)
- NLOPT_GETSET(unsigned, subspace_dim)
+ NLOPT_GETSET(unsigned, vector_storage)
NLOPT_GETSET_VEC(initial_step)
void set_default_initial_step(const std::vector<double> &x) {