chiark / gitweb /
Use trusty
[nlopt.git] / api / nlopt-in.hpp
index 09215fdc9fcd51eecf79788452fc01c161bb9a0a..582c676fd9704e7dd073d6e8a043356f4ae9bf2a 100644 (file)
@@ -1,4 +1,4 @@
-/* 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
@@ -77,9 +77,9 @@ namespace nlopt {
     
     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;
@@ -468,6 +468,11 @@ namespace nlopt {
     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) {
@@ -476,7 +481,7 @@ namespace nlopt {
     }
 
     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) {