Mercurial > hg > octave-max
changeset 1862:58b42823284f
[project @ 1996-02-04 10:35:54 by jwe]
author | jwe |
---|---|
date | Sun, 04 Feb 1996 10:36:00 +0000 |
parents | 620a65533630 |
children | 986e565efd0a |
files | liboctave/NPSOL.cc liboctave/NPSOL.h |
diffstat | 2 files changed, 154 insertions(+), 323 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/NPSOL.cc +++ b/liboctave/NPSOL.cc @@ -308,29 +308,6 @@ return x; } -NPSOL_options::NPSOL_options (void) -{ - init (); -} - -NPSOL_options::NPSOL_options (const NPSOL_options& opt) -{ - copy (opt); -} - -NPSOL_options& -NPSOL_options::operator = (const NPSOL_options& opt) -{ - if (this != &opt) - copy (opt); - - return *this; -} - -NPSOL_options::~NPSOL_options (void) -{ -} - void NPSOL_options::init (void) { @@ -382,255 +359,6 @@ } void -NPSOL_options::set_default_options (void) -{ - init (); -} - -// Passing invalid values to the set_* functions will result in -// setting the default option. - -void -NPSOL_options::set_central_difference_interval (double val) -{ - x_central_difference_interval = (val > 0.0) ? val : -1.0; -} - -void -NPSOL_options::set_crash_tolerance (double val) -{ - x_crash_tolerance = (val >= 0.0) ? val : 0.1; -} - -void -NPSOL_options::set_difference_interval (double val) -{ - x_difference_interval = (val > 0.0) ? val : -1.0; -} - -void -NPSOL_options::set_function_precision (double val) -{ - x_function_precision = (val > 0.0) ? val : pow (DBL_EPSILON, 0.9); -} - -void -NPSOL_options::set_infinite_bound (double val) -{ - x_infinite_bound = (val > 0.0) ? val : 1.0e+30; -} - -void -NPSOL_options::set_infinite_step (double val) -{ - x_infinite_step = (val > 0.0) ? val : 1.0e+30; -} - -void -NPSOL_options::set_linear_feasibility_tolerance (double val) -{ - x_linear_feasibility_tolerance = (val > 0.0) ? val : sqrt (DBL_EPSILON); -} - -void -NPSOL_options::set_linesearch_tolerance (double val) -{ - x_linesearch_tolerance = (val >= 0.0 && val < 1.0) ? val : 0.9; -} - -void -NPSOL_options::set_nonlinear_feasibility_tolerance (double val) -{ - x_nonlinear_feasibility_tolerance = (val > 0.0) ? val : sqrt (DBL_EPSILON); -} - -void -NPSOL_options::set_optimality_tolerance (double val) -{ - x_optimality_tolerance = (val > 0.0) ? val : pow (DBL_EPSILON, 0.8); -} - -void -NPSOL_options::set_derivative_level (int val) -{ - x_derivative_level = (val >= 0 && val < 4) ? val : 0; -} - -void -NPSOL_options::set_major_iteration_limit (int val) -{ - x_major_iteration_limit = (val > 0) ? val : -1; -} - -void -NPSOL_options::set_minor_iteration_limit (int val) -{ - x_minor_iteration_limit = (val > 0) ? val : -1; -} - -void -NPSOL_options::set_major_print_level (int val) -{ - x_major_print_level = (val >= 0) ? val : -1; -} - -void -NPSOL_options::set_minor_print_level (int val) -{ - x_minor_print_level = (val >= 0) ? val : -1; -} - -void -NPSOL_options::set_start_objective_check (int val) -{ - x_start_objective_check = (val >= 0) ? val : -1; -} - -void -NPSOL_options::set_start_constraint_check (int val) -{ - x_start_constraint_check = (val >= 0) ? val : -1; -} - -void -NPSOL_options::set_stop_objective_check (int val) -{ - x_stop_objective_check = (val >= 0) ? val : -1; -} - -void -NPSOL_options::set_stop_constraint_check (int val) -{ - x_stop_constraint_check = (val >= 0) ? val : -1; -} - -void -NPSOL_options::set_verify_level (int val) -{ - x_verify_level = ((val > -1 && val < 4) || (val > 9 && val < 14)) ? val : 0; -} - -double -NPSOL_options::central_difference_interval (void) const -{ - return x_central_difference_interval; -} - -double -NPSOL_options::crash_tolerance (void) const -{ - return x_crash_tolerance; -} - -double -NPSOL_options::difference_interval (void) const -{ - return x_difference_interval; -} - -double -NPSOL_options::function_precision (void) const -{ - return x_function_precision; -} - -double -NPSOL_options::infinite_bound (void) const -{ - return x_infinite_bound; -} - -double -NPSOL_options::infinite_step (void) const -{ - return x_infinite_step; -} - -double -NPSOL_options::linear_feasibility_tolerance (void) const -{ - return x_linear_feasibility_tolerance; -} - -double -NPSOL_options::linesearch_tolerance (void) const -{ - return x_linesearch_tolerance; -} - -double -NPSOL_options::nonlinear_feasibility_tolerance (void) const -{ - return x_nonlinear_feasibility_tolerance; -} - -double -NPSOL_options::optimality_tolerance (void) const -{ - return x_optimality_tolerance; -} - -int -NPSOL_options::derivative_level (void) const -{ - return x_derivative_level; -} - -int -NPSOL_options::major_iteration_limit (void) const -{ - return x_major_iteration_limit; -} - -int -NPSOL_options::minor_iteration_limit (void) const -{ - return x_minor_iteration_limit; -} - -int -NPSOL_options::major_print_level (void) const -{ - return x_major_print_level; -} - -int -NPSOL_options::minor_print_level (void) const -{ - return x_minor_print_level; -} - -int -NPSOL_options::start_objective_check (void) const -{ - return x_start_objective_check; -} - -int -NPSOL_options::start_constraint_check (void) const -{ - return x_start_constraint_check; -} - -int -NPSOL_options::stop_objective_check (void) const -{ - return x_stop_objective_check; -} - -int -NPSOL_options::stop_constraint_check (void) const -{ - return x_stop_constraint_check; -} - -int -NPSOL_options::verify_level (void) const -{ - return x_verify_level; -} - -void NPSOL_options::pass_options_to_npsol (void) { F77_FCN (npoptn, NPOPTN) ("Nolist", 6L);
--- a/liboctave/NPSOL.h +++ b/liboctave/NPSOL.h @@ -1,7 +1,7 @@ // NPSOL.h -*- C++ -*- /* -Copyright (C) 1992, 1993, 1994, 1995 John W. Eaton +Copyright (C) 1996 John W. Eaton This file is part of Octave. @@ -30,77 +30,178 @@ #ifndef NPSOL_MISSING +#include <cmath> + #include "dColVector.h" #include "NLP.h" -class NPSOL_options +class +NPSOL_options { - public: +public: - NPSOL_options (void); - NPSOL_options (const NPSOL_options& opt); + NPSOL_options (void) { init (); } + + NPSOL_options (const NPSOL_options& opt) { copy (opt); } NPSOL_options& operator = (const NPSOL_options& opt); + { + if (this != &opt) + copy (opt); - ~NPSOL_options (void); + return *this; + } + + ~NPSOL_options (void) { } void init (void); + void copy (const NPSOL_options& opt); - void set_default_options (void); + void set_default_options (void) { init (); } + +// XXX FIXME XXX -- is this a good idea? + +// Passing invalid values to the set_* functions will result in +// setting the default option. + + void set_central_difference_interval (double val) + { x_central_difference_interval = (val > 0.0) ? val : -1.0; } + + void set_crash_tolerance (double val) + { x_crash_tolerance = (val >= 0.0) ? val : 0.1; } + + void set_difference_interval (double val) + { x_difference_interval = (val > 0.0) ? val : -1.0; } + + void set_function_precision (double val) + { x_function_precision = (val > 0.0) ? val : ::pow (DBL_EPSILON, 0.9); } + + void set_infinite_bound (double val) + { x_infinite_bound = (val > 0.0) ? val : 1.0e+30; } + + void set_infinite_step (double val) + { x_infinite_step = (val > 0.0) ? val : 1.0e+30; } + + void set_linear_feasibility_tolerance (double val) + { + x_linear_feasibility_tolerance + = (val > 0.0) ? val : ::sqrt (DBL_EPSILON); + } - void set_central_difference_interval (double val); - void set_crash_tolerance (double val); - void set_difference_interval (double val); - void set_function_precision (double val); - void set_infinite_bound (double val); - void set_infinite_step (double val); - void set_linear_feasibility_tolerance (double val); - void set_linesearch_tolerance (double val); - void set_nonlinear_feasibility_tolerance (double val); - void set_optimality_tolerance (double val); + void set_linesearch_tolerance (double val) + { x_linesearch_tolerance = (val >= 0.0 && val < 1.0) ? val : 0.9; } + + void set_nonlinear_feasibility_tolerance (double val) + { + x_nonlinear_feasibility_tolerance + = (val > 0.0) ? val : ::sqrt (DBL_EPSILON); + } + + void set_optimality_tolerance (double val) + { x_optimality_tolerance = (val > 0.0) ? val : ::pow (DBL_EPSILON, 0.8); } + + void set_derivative_level (int val) + { x_derivative_level = (val >= 0 && val < 4) ? val : 0; } + + void set_major_iteration_limit (int val) + { x_major_iteration_limit = (val > 0) ? val : -1; } - void set_derivative_level (int val); - void set_major_iteration_limit (int val); - void set_minor_iteration_limit (int val); - void set_major_print_level (int val); - void set_minor_print_level (int val); - void set_start_objective_check (int val); - void set_start_constraint_check (int val); - void set_stop_objective_check (int val); - void set_stop_constraint_check (int val); - void set_verify_level (int val); + void set_minor_iteration_limit (int val) + { x_minor_iteration_limit = (val > 0) ? val : -1; } + + void set_major_print_level (int val) + { x_major_print_level = (val >= 0) ? val : -1; } + + void set_minor_print_level (int val) + { x_minor_print_level = (val >= 0) ? val : -1; } + + void set_start_objective_check (int val) + { x_start_objective_check = (val >= 0) ? val : -1; } + + void set_start_constraint_check (int val) + { x_start_constraint_check = (val >= 0) ? val : -1; } + + void set_stop_objective_check (int val) + { x_stop_objective_check = (val >= 0) ? val : -1; } - double central_difference_interval (void) const; - double crash_tolerance (void) const; - double difference_interval (void) const; - double function_precision (void) const; - double infinite_bound (void) const; - double infinite_step (void) const; - double linear_feasibility_tolerance (void) const; - double linesearch_tolerance (void) const; - double nonlinear_feasibility_tolerance (void) const; - double optimality_tolerance (void) const; + void set_stop_constraint_check (int val) + { x_stop_constraint_check = (val >= 0) ? val : -1; } + + void set_verify_level (int val) + { + x_verify_level + = ((val > -1 && val < 4) || (val > 9 && val < 14)) ? val : 0; + } + + double central_difference_interval (void) const + { return x_central_difference_interval; } + + double crash_tolerance (void) const + { return x_crash_tolerance; } + + double difference_interval (void) const + { return x_difference_interval; } + + double function_precision (void) const + { return x_function_precision; } + + double infinite_bound (void) const + { return x_infinite_bound; } + + double infinite_step (void) const + { return x_infinite_step; } + + double linear_feasibility_tolerance (void) const + { return x_linear_feasibility_tolerance; } + + double linesearch_tolerance (void) const + { return x_linesearch_tolerance; } - int derivative_level (void) const; - int major_iteration_limit (void) const; - int minor_iteration_limit (void) const; - int major_print_level (void) const; - int minor_print_level (void) const; - int start_objective_check (void) const; - int start_constraint_check (void) const; - int stop_objective_check (void) const; - int stop_constraint_check (void) const; - int verify_level (void) const; + double nonlinear_feasibility_tolerance (void) const + { return x_nonlinear_feasibility_tolerance; } + + double optimality_tolerance (void) const + { return x_optimality_tolerance; } + + int derivative_level (void) const + { return x_derivative_level; } + + int major_iteration_limit (void) const + { return x_major_iteration_limit; } + + int minor_iteration_limit (void) const + { return x_minor_iteration_limit; } + + int major_print_level (void) const + { return x_major_print_level; } - protected: + int minor_print_level (void) const + { return x_minor_print_level; } + + int start_objective_check (void) const + { return x_start_objective_check; } + + int start_constraint_check (void) const + { return x_start_constraint_check; } + + int stop_objective_check (void) const + { return x_stop_objective_check; } + + int stop_constraint_check (void) const + { return x_stop_constraint_check; } + + int verify_level (void) const + { return x_verify_level; } + +protected: void pass_options_to_npsol (void); void set_option (const char *key, int opt); void set_option (const char *key, double opt); - private: +private: double x_central_difference_interval; double x_crash_tolerance; @@ -112,6 +213,7 @@ double x_linesearch_tolerance; double x_nonlinear_feasibility_tolerance; double x_optimality_tolerance; + int x_derivative_level; int x_major_iteration_limit; int x_minor_iteration_limit; @@ -124,9 +226,10 @@ int x_verify_level; }; -class NPSOL : public NLP, public NPSOL_options +class +NPSOL : public NLP, public NPSOL_options { - public: +public: NPSOL (void) : NLP (), NPSOL_options () { }