1 /* _______________________________________________________________________ 2 3 DAKOTA: Design Analysis Kit for Optimization and Terascale Applications 4 Copyright 2014-2020 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 5 This software is distributed under the GNU Lesser General Public License. 6 For more information, see the README file in the top Dakota directory. 7 _______________________________________________________________________ */ 8 9 //- Class: CONMINOptimizer 10 //- Description: Wrapper class for CONMIN 11 //- Owner: Tony Giunta 12 //- Checked by: 13 //- Version: $Id: CONMINOptimizer.hpp 6972 2010-09-17 22:18:50Z briadam $ 14 15 #ifndef CONMIN_OPTIMIZER_H 16 #define CONMIN_OPTIMIZER_H 17 18 #include "DakotaOptimizer.hpp" 19 20 21 namespace Dakota { 22 23 /** 24 * \brief A version of TraitsBase specialized for CONMIN optimizers 25 * 26 */ 27 class CONMINTraits: public TraitsBase 28 { 29 public: 30 31 /// default constructor CONMINTraits()32 CONMINTraits() { } 33 34 /// destructor ~CONMINTraits()35 virtual ~CONMINTraits() { } 36 37 /// A temporary query used in the refactor is_derived()38 virtual bool is_derived() { return true; } 39 40 /// Return the flag indicating whether method supports continuous variables supports_continuous_variables()41 bool supports_continuous_variables() { return true; } 42 43 /// Return the flag indicating whether method supports linear equalities supports_linear_equality()44 bool supports_linear_equality() { return true; } 45 46 /// Return the flag indicating whether method supports linear inequalities supports_linear_inequality()47 bool supports_linear_inequality() { return true; } 48 49 /// Return the format used for linear inequality constraints linear_inequality_format()50 LINEAR_INEQUALITY_FORMAT linear_inequality_format() 51 { return LINEAR_INEQUALITY_FORMAT::ONE_SIDED_UPPER; } 52 53 /// Return the flag indicating whether method supports nonlinear equalities supports_nonlinear_equality()54 bool supports_nonlinear_equality() { return true; } 55 56 /// Return the flag indicating whether method supports nonlinear inequalities supports_nonlinear_inequality()57 bool supports_nonlinear_inequality() { return true; } 58 59 /// Return the format used for nonlinear inequality constraints nonlinear_inequality_format()60 NONLINEAR_INEQUALITY_FORMAT nonlinear_inequality_format() 61 { return NONLINEAR_INEQUALITY_FORMAT::ONE_SIDED_UPPER; } 62 }; 63 64 65 /// Wrapper class for the CONMIN optimization library. 66 67 /** The CONMINOptimizer class provides a wrapper for CONMIN, a 68 Public-domain Fortran 77 optimization library written by Gary 69 Vanderplaats under contract to NASA Ames Research Center. The 70 CONMIN User's Manual is contained in NASA Technical Memorandum 71 X-62282, 1978. CONMIN uses a reverse communication mode, which 72 avoids the static member function issues that arise with function 73 pointer designs (see NPSOLOptimizer and SNLLOptimizer). 74 75 The user input mappings are as follows: \c max_iterations is 76 mapped into CONMIN's \c ITMAX parameter, \c 77 max_function_evaluations is implemented directly in the 78 core_run() loop since there is no CONMIN parameter equivalent, 79 \c convergence_tolerance is mapped into CONMIN's \c DELFUN and \c 80 DABFUN parameters, \c output verbosity is mapped into CONMIN's \c 81 IPRINT parameter (verbose: \c IPRINT = 4; quiet: \c IPRINT = 2), 82 gradient mode is mapped into CONMIN's \c NFDG parameter, and 83 finite difference step size is mapped into CONMIN's \c FDCH and \c 84 FDCHM parameters. Refer to [Vanderplaats, 1978] for additional 85 information on CONMIN parameters. */ 86 class CONMINOptimizer: public Optimizer 87 { 88 public: 89 90 // 91 //- Heading: Constructors and destructor 92 // 93 94 /// standard constructor 95 CONMINOptimizer(ProblemDescDB& problem_db, Model& model); 96 /// alternate constructor; construct without ProblemDescDB 97 CONMINOptimizer(const String& method_string, Model& model); 98 /// destructor 99 ~CONMINOptimizer(); 100 101 // 102 //- Heading: Virtual member function redefinitions 103 // 104 105 void core_run(); 106 107 protected: 108 109 // 110 //- Heading: Virtual member function redefinitions 111 // 112 113 /// performs run-time set up 114 void initialize_run(); 115 116 private: 117 118 // 119 //- Heading: Convenience member functions 120 // 121 122 void initialize(); ///< Shared constructor code 123 124 void allocate_workspace(); ///< Allocates workspace for the optimizer 125 126 void deallocate_workspace(); ///< Releases workspace memory 127 128 void allocate_constraints(); ///< Allocates constraint mappings 129 130 // 131 //- Heading: Data members 132 // 133 134 /// INFO from CONMIN manual 135 /** Information requested by CONMIN: 136 1 = evaluate objective and constraints, 137 2 = evaluate gradients of objective and constraints. */ 138 int conminInfo; 139 140 /// IPRINT from CONMIN manual (controls output verbosity) 141 /** Values range from 0 (nothing) to 4 (most output). 142 0 = nothing, 143 1 = initial and final function information, 144 2 = all of #1 plus function value and design vars at each iteration, 145 3 = all of #2 plus constraint values and direction vectors, 146 4 = all of #3 plus gradients of the objective function and constraints, 147 5 = all of #4 plus proposed design vector, plus objective and 148 constraint functions from the 1-D search */ 149 int printControl; 150 151 /// value of the objective function passed to CONMIN 152 Real objFnValue; 153 154 /// array of nonlinear constraint values passed to CONMIN 155 /** This array must be of nonzero length and must contain only 156 one-sided inequality constraints which are <= 0 (which requires 157 a transformation from 2-sided inequalities and equalities). */ 158 RealVector constraintValues; 159 160 /// total number of nonlinear constraints seen by CONMIN 161 int numConminNlnConstr; 162 /// total number of linear constraints seen by CONMIN 163 int numConminLinConstr; 164 /// total number of linear and nonlinear constraints seen by CONMIN 165 int numConminConstr; 166 167 // These are variables and arrays that must be declared here prior 168 // to calling the F77 CONMIN code. 169 // 170 /// Size variable for CONMIN arrays. See CONMIN manual. 171 /** N1 = number of variables + 2 */ 172 int N1; 173 /// Size variable for CONMIN arrays. See CONMIN manual. 174 /** N2 = number of constraints + 2*(number of variables) */ 175 int N2; 176 /// Size variable for CONMIN arrays. See CONMIN manual. 177 /** N3 = Maximum possible number of active constraints.*/ 178 int N3; 179 /// Size variable for CONMIN arrays. See CONMIN manual. 180 /** N4 = Maximum(N3,number of variables) */ 181 int N4; 182 /// Size variable for CONMIN arrays. See CONMIN manual. 183 /** N5 = 2*(N4) */ 184 int N5; 185 // 186 // user-controlled variables that affect CONMIN performance 187 // 188 /// Finite difference flag. 189 int NFDG; 190 /// Flag to control amount of output data. 191 int IPRINT; 192 /// Flag to specify the maximum number of iterations. 193 int ITMAX; 194 /// Relative finite difference step size. 195 double FDCH; 196 /// Absolute finite difference step size. 197 double FDCHM; 198 /// Constraint thickness parameter 199 /** The value of CT decreases in magnitude during optimization.*/ 200 double CT; 201 /// Minimum absolute value of CT used during optimization. 202 double CTMIN; 203 /// Constraint thickness parameter for linear and side constraints. 204 double CTL; 205 /// Minimum value of CTL used during optimization. 206 double CTLMIN; 207 /// Relative convergence criterion threshold. 208 /*** Threshold for the minimum relative change in the objective function. */ 209 double DELFUN; 210 /// Absolute convergence criterion threshold. 211 /*** Threshold for the minimum relative change in the objective function. */ 212 double DABFUN; 213 214 /// Array of design variables used by CONMIN (length N1 = numdv+2) 215 double *conminDesVars; 216 /// Array of lower bounds used by CONMIN (length N1 = numdv+2) 217 double *conminLowerBnds; 218 /// Array of upper bounds used by CONMIN (length N1 = numdv+2) 219 double *conminUpperBnds; 220 221 ///Internal CONMIN array. 222 /** Move direction in N-dimensional space.*/ 223 double *S; 224 ///Internal CONMIN array. 225 /** Temporary storage of constraint values.*/ 226 double *G1; 227 ///Internal CONMIN array. 228 /** Temporary storage of constraint values.*/ 229 double *G2; 230 ///Internal CONMIN array. 231 /** Temporary storage for computations involving array S.*/ 232 double *B; 233 ///Internal CONMIN array. 234 /** Temporary storage for use with arrays B and S.*/ 235 double *C; 236 ///Internal CONMIN array. 237 /** Temporary storage for use with arrays B and S.*/ 238 int *MS1; 239 ///Internal CONMIN array. 240 /** Vector of scaling parameters for design parameter values.*/ 241 double *SCAL; 242 ///Internal CONMIN array. 243 /** Temporary storage for analytic gradient data.*/ 244 double *DF; 245 ///Internal CONMIN array. 246 /** Temporary 2-D array for storage of constraint gradients.*/ 247 double *A; 248 ///Internal CONMIN array. 249 /** Array of flags to identify linear constraints. (not used in this 250 implementation of CONMIN) */ 251 int *ISC; 252 ///Internal CONMIN array. 253 /** Array of flags to identify active and violated constraints */ 254 int *IC; 255 }; 256 257 } // namespace Dakota 258 259 #endif 260