Ipopt
trunk
|
00001 // Copyright (C) 2012, The Science and Technology Facilities Council (STFC) 00002 // Copyright (C) 2009, Jonathan Hogg <jdh41.at.cantab.net> 00003 // Copyright (C) 2004, 2007 International Business Machines and others. 00004 // All Rights Reserved. 00005 // This code is published under the Eclipse Public License. 00006 // 00007 // $Id: IpMa97SolverInterface.hpp 2001 2011-06-02 17:43:07Z andreasw $ 00008 // 00009 // Authors: Jonathan Hogg STFC 2012-12-21 00010 // Jonathan Hogg 2009-07-29 00011 // Carl Laird, Andreas Waechter IBM 2004-03-17 00012 00013 #ifndef __IPMA97SOLVERINTERFACE_HPP__ 00014 #define __IPMA97SOLVERINTERFACE_HPP__ 00015 00016 #include "IpSparseSymLinearSolverInterface.hpp" 00017 extern "C" 00018 { 00019 #include "hsl_ma97d.h" 00020 } 00021 00022 namespace Ipopt 00023 { 00024 00104 class Ma97SolverInterface: public SparseSymLinearSolverInterface 00105 { 00106 private: 00107 enum order_opts { 00108 ORDER_AUTO, 00109 ORDER_BEST, 00110 ORDER_AMD, 00111 ORDER_METIS, 00112 ORDER_MATCHED_AUTO, 00113 ORDER_MATCHED_AMD, 00114 ORDER_MATCHED_METIS 00115 }; 00116 enum scale_opts { 00117 SWITCH_NEVER, 00118 SWITCH_AT_START, 00119 SWITCH_AT_START_REUSE, 00120 SWITCH_ON_DEMAND, 00121 SWITCH_ON_DEMAND_REUSE, 00122 SWITCH_NDELAY, 00123 SWITCH_NDELAY_REUSE, 00124 SWITCH_OD_ND, 00125 SWITCH_OD_ND_REUSE 00126 }; 00127 00128 int ndim_; // Number of dimensions 00129 double *val_; // Storage for variables 00130 int numneg_; // Number of negative pivots in last factorization 00131 int numdelay_; // Number of delayed pivots last time we scaled 00132 void *akeep_; // Stores pointer to factors (only understood Fortran code!) 00133 void *fkeep_; // Stores pointer to factors (only understood Fortran code!) 00134 bool pivtol_changed_; // indicates if pivtol has been changed 00135 bool rescale_; // Indicates if we shuold rescale next factorization 00136 double *scaling_; // Store scaling for reuse if doing dynamic scaling 00137 int fctidx_; // Current factorization number to dump to 00138 00139 /* Options */ 00140 struct ma97_control control_; 00141 double umax_; 00142 int ordering_; 00143 int scaling_type_; 00144 enum scale_opts switch_[3]; 00145 int scaling_val_[3]; 00146 int current_level_; 00147 bool dump_; 00148 00149 public: 00150 00151 Ma97SolverInterface() : 00152 val_(NULL), numdelay_(0), akeep_(NULL), fkeep_(NULL), pivtol_changed_(false), 00153 rescale_(false), scaling_(NULL), fctidx_(0), scaling_type_(0), 00154 dump_(false) 00155 {} 00156 ~Ma97SolverInterface(); 00157 00158 static void RegisterOptions(SmartPtr<RegisteredOptions> roptions); 00159 00160 bool InitializeImpl(const OptionsList& options, 00161 const std::string& prefix); 00162 00171 ESymSolverStatus InitializeStructure(Index dim, Index nonzeros, 00172 const Index* ia, 00173 const Index* ja); 00174 00181 double* GetValuesArrayPtr() 00182 { 00183 return val_; 00184 } 00185 00218 ESymSolverStatus MultiSolve(bool new_matrix, 00219 const Index* ia, 00220 const Index* ja, 00221 Index nrhs, 00222 double* rhs_vals, 00223 bool check_NegEVals, 00224 Index numberOfNegEVals); 00225 00232 Index NumberOfNegEVals() const 00233 { 00234 return numneg_; 00235 } 00237 00238 //* @name Options of Linear solver */ 00240 00246 bool IncreaseQuality(); 00247 00251 bool ProvidesInertia() const 00252 { 00253 return true; 00254 } 00255 00259 EMatrixFormat MatrixFormat() const 00260 { 00261 return CSR_Format_1_Offset; 00262 } 00264 00270 bool ProvidesDegeneracyDetection() const 00271 { 00272 return false; 00273 } 00276 ESymSolverStatus DetermineDependentRows(const Index* ia, 00277 const Index* ja, 00278 std::list<Index>& c_deps) 00279 { 00280 return SYMSOLVER_FATAL_ERROR; 00281 } 00282 00284 static int ScaleNameToNum(const std::string& name); 00285 }; 00286 00287 } // namespace Ipopt 00288 00289 #endif