Mercurial > hg > octave-nkf
changeset 1874:7fc99ae70891
[project @ 1996-02-04 13:16:56 by jwe]
author | jwe |
---|---|
date | Sun, 04 Feb 1996 13:22:23 +0000 |
parents | dc859604b19b |
children | d06d35afa90d |
files | liboctave/NPSOL.h liboctave/QPSOL.h src/npsol.cc src/qpsol.cc |
diffstat | 4 files changed, 61 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/NPSOL.h +++ b/liboctave/NPSOL.h @@ -30,6 +30,7 @@ #ifndef NPSOL_MISSING +#include <cfloat> #include <cmath> #include "dColVector.h"
--- a/liboctave/QPSOL.h +++ b/liboctave/QPSOL.h @@ -30,6 +30,9 @@ #ifndef QPSOL_MISSING +#include <cfloat> +#include <cmath> + #include "dMatrix.h" #include "dColVector.h" #include "QP.h" @@ -39,27 +42,57 @@ { public: - QPSOL_options (void); - QPSOL_options (const QPSOL_options& opt); + QPSOL_options (void) { init (); } + + QPSOL_options (const QPSOL_options& opt) { set_options (opt); } - QPSOL_options& operator = (const QPSOL_options& opt); + QPSOL_options& operator = (const QPSOL_options& opt) + { + if (this != &opt) + set_options (opt); + + return *this; + } - ~QPSOL_options (void); + ~QPSOL_options (void) { } - void init (void); - void copy (const QPSOL_options& opt); + void init (void) + { + x_feasibility_tolerance = ::sqrt (DBL_EPSILON); + x_infinite_bound = 1.0e+30; + x_iteration_limit = -1; + x_print_level = 0; + } + + void set_default_options (void) { init (); } - void set_default_options (void); + void set_options (const QPSOL_options& opt) + { + x_feasibility_tolerance = opt.x_feasibility_tolerance; + x_infinite_bound = opt.x_infinite_bound; + x_iteration_limit = opt.x_iteration_limit; + x_print_level = opt.x_print_level; + } + + void set_feasibility_tolerance (double val) + { x_feasibility_tolerance = (val > 0.0) ? val : ::sqrt (DBL_EPSILON); } + + void set_infinite_bound (double val) + { x_infinite_bound = (val > 0.0) ? val : 1.0e+30; } - void set_feasibility_tolerance (double); - void set_infinite_bound (double); - void set_iteration_limit (int); - void set_print_level (int); + void set_iteration_limit (int val) + { x_iteration_limit = (val > 0) ? val : -1; } + + void set_print_level (int val) + { x_print_level = (val >= 0) ? val : 0; } - double feasibility_tolerance (void); - double infinite_bound (void); - int iteration_limit (void); - int print_level (void); + double feasibility_tolerance (void) { return x_feasibility_tolerance; } + + double infinite_bound (void) { return x_infinite_bound; } + + int iteration_limit (void) { return x_iteration_limit; } + + int print_level (void) { return x_print_level; } private:
--- a/src/npsol.cc +++ b/src/npsol.cc @@ -343,7 +343,7 @@ // 1. npsol (x, phi) NPSOL nlp (x, func); - nlp.copy (npsol_opts); + nlp.set_options (npsol_opts); soln = nlp.minimize (objf, inform, lambda); goto solved; @@ -354,7 +354,7 @@ // 2. npsol (x, phi, lb, ub) NPSOL nlp (x, func, bounds); - nlp.copy (npsol_opts); + nlp.set_options (npsol_opts); soln = nlp.minimize (objf, inform, lambda); goto solved; @@ -395,7 +395,7 @@ // 7. npsol (x, phi, llb, c, lub) NPSOL nlp (x, func, linear_constraints); - nlp.copy (npsol_opts); + nlp.set_options (npsol_opts); soln = nlp.minimize (objf, inform, lambda); } else @@ -403,7 +403,7 @@ // 3. npsol (x, phi, lb, ub, llb, c, lub) NPSOL nlp (x, func, bounds, linear_constraints); - nlp.copy (npsol_opts); + nlp.set_options (npsol_opts); soln = nlp.minimize (objf, inform, lambda); } goto solved; @@ -426,7 +426,7 @@ // 8. npsol (x, phi, nllb, g, nlub) NPSOL nlp (x, func, nonlinear_constraints); - nlp.copy (npsol_opts); + nlp.set_options (npsol_opts); soln = nlp.minimize (objf, inform, lambda); } else @@ -434,7 +434,7 @@ // 5. npsol (x, phi, lb, ub, nllb, g, nlub) NPSOL nlp (x, func, bounds, nonlinear_constraints); - nlp.copy (npsol_opts); + nlp.set_options (npsol_opts); soln = nlp.minimize (objf, inform, lambda); } goto solved; @@ -490,7 +490,7 @@ NPSOL nlp (x, func, linear_constraints, nonlinear_constraints); - nlp.copy (npsol_opts); + nlp.set_options (npsol_opts); soln = nlp.minimize (objf, inform, lambda); } else @@ -499,7 +499,7 @@ NPSOL nlp (x, func, bounds, linear_constraints, nonlinear_constraints); - nlp.copy (npsol_opts); + nlp.set_options (npsol_opts); soln = nlp.minimize (objf, inform, lambda); } goto solved;
--- a/src/qpsol.cc +++ b/src/qpsol.cc @@ -157,7 +157,7 @@ // 1. qpsol (x, H, c) QPSOL qp (x, H, c); - qp.copy (qpsol_opts); + qp.set_options (qpsol_opts); soln = qp.minimize (objf, inform, lambda); goto solved; @@ -168,7 +168,7 @@ // 2. qpsol (x, H, c, lb, ub) QPSOL qp (x, H, c, bounds); - qp.copy (qpsol_opts); + qp.set_options (qpsol_opts); soln = qp.minimize (objf, inform, lambda); goto solved; @@ -203,7 +203,7 @@ // 3. qpsol (x, H, c, lb, ub, llb, A, lub) QPSOL qp (x, H, c, bounds, linear_constraints); - qp.copy (qpsol_opts); + qp.set_options (qpsol_opts); soln = qp.minimize (objf, inform, lambda); } else @@ -211,7 +211,7 @@ // 4. qpsol (x, H, c, llb, A, lub) QPSOL qp (x, H, c, linear_constraints); - qp.copy (qpsol_opts); + qp.set_options (qpsol_opts); soln = qp.minimize (objf, inform, lambda); } goto solved;