Diana
0.8.3
|
00001 /* ----------------------------------------------------------------------------- 00002 * Diana process modelling, simulation and analysis software 00003 * Copyright (c) 2005, Michael Krasnyk 00004 * All rights reserved. 00005 * 00006 * This file is a part of Diana process modelling, simulation and analysis software 00007 * 00008 * Diana is free software; you can redistribute it and/or modify it 00009 * under the terms of the GNU General Public License as published 00010 * by the Free Software Foundation (see accompanying file LICENSE) 00011 * ----------------------------------------------------------------------------- 00012 * $Id: CapeSolver.hpp 9446 2011-08-09 13:01:04Z miroshkin $ 00013 * ----------------------------------------------------------------------------- 00014 * Description: 00015 */ 00016 00017 #ifndef CAPE_SOLVER_HPP 00018 #define CAPE_SOLVER_HPP 00019 00020 #include "CapeTypes.hpp" 00021 #include "CapeException.hpp" 00022 #include "CapeMatrix.hpp" 00023 #include "CapeModel.hpp" 00024 #include "CapeNLPTask.hpp" 00025 00026 namespace Numeric{ 00027 00028 namespace Solvers { 00029 00030 namespace NLPTasks { 00031 class ICapeNLPTask; 00032 } 00033 00036 namespace Solver{ 00037 00039 enum CapeSolverType{ 00040 CAPE_LA, 00041 CAPE_NLA, 00042 CAPE_DAE, 00043 CAPE_PDAE, 00044 CAPE_CONTI, 00045 CAPE_NLP, 00046 CAPE_IC 00047 }; 00048 00052 enum SolveReturn{ 00053 SolveSuccess, 00054 SolveIntermediate, 00055 SolveError, 00056 SolveException, 00057 SolveTooManyIterations, 00058 SolveNaNNorm, 00059 }; 00060 00061 typedef std::vector<CapeSolverType> CapeArraySolverType; 00062 00063 // Foward declaration of interfaces 00064 class ICapeNumericSolverFactory; 00065 class ICapeNumericSolver; 00066 class ICapeNumericLASolver; 00067 class ICapeNumericNLASolver; 00068 class ICapeNumericDAESolver; 00069 class ICapeNumericPDAESolver; 00070 class ICapeNumericNLPSolver; 00071 00072 // Interface sequence 00073 typedef std::vector<ICapeNumericDAESolver*> CapeArrayNumericDAESolver; 00074 typedef std::vector<ICapeNumericSolverFactory*> CapeArrayNumericSolverFactory; 00075 typedef std::vector<ICapeNumericSolver*> CapeArrayNumericSolver; 00076 typedef std::vector<ICapeNumericLASolver*> CapeArrayNumericLASolver; 00077 typedef std::vector<ICapeNumericNLASolver*> CapeArrayNumericNLASolver; 00078 typedef std::vector<ICapeNumericPDAESolver*> CapeArrayNumericPDAESolver; 00079 typedef std::vector<ICapeNumericNLPSolver*> CapeArrayNumericNLPSolver; 00080 00084 class ICapeNumericSolverFactory { 00085 public: 00091 virtual ICapeNumericSolver* CreateSolver(CapeSolverType type, 00092 Model::ICapeNumericModel* theModel, 00093 Common::Types::CapeString strLibraryName) 00094 throw (Common::Error::ECapeUnknown, Common::Error::ECapeInvalidArgument, 00095 Common::Error::ECapeOutOfBounds, Common::Error::ECapeOutOfResources, 00096 Common::Error::ECapeFailedInitialisation, Common::Error::ECapeUser) = 0; 00097 00099 virtual void Shutdown() 00100 throw (Common::Error::ECapeUnknown, Common::Error::ECapeNoImpl) = 0; 00101 }; 00102 00110 class ICapeNumericSolver : public Common::Identification::ICapeIdentification, 00111 public Common::Utilities:: ICapeUtilities { 00112 #ifndef SWIG 00113 00114 friend std::ostream& operator<<(std::ostream& out_file, const ICapeNumericSolver& solver); 00115 #endif 00116 public: 00132 virtual SolveReturn Solve() 00133 throw (Common::Error::ECapeUnknown, Common::Error::ECapeBadInvOrder, 00134 Common::Error::ECapeSolvingError, Common::Error::ECapeOutOfResources) = 0; 00135 00137 virtual Common::Types::CapeArrayDouble GetSolution() 00138 throw (Common::Error::ECapeUnknown, Common::Error::ECapeBadInvOrder) = 0; 00139 00142 virtual void Destroy() 00143 throw (Common::Error::ECapeUnknown) = 0; 00144 }; 00145 00157 class ICapeNumericLASolver : virtual public ICapeNumericSolver { 00158 #ifndef SWIG 00159 00160 friend std::ostream& operator<<(std::ostream& out_file, const ICapeNumericLASolver& solver); 00161 #endif 00162 }; 00163 00172 class ICapeNumericNLASolver : virtual public ICapeNumericSolver { 00173 #ifndef SWIG 00174 00175 friend std::ostream& operator<<(std::ostream& out_file, const ICapeNumericNLASolver& solver); 00176 #endif 00177 public: 00184 virtual void SetCvgTolerance(Common::Types::CapeDouble cvgValue) 00185 throw (Common::Error::ECapeUnknown, Common::Error::ECapeInvalidArgument, 00186 Common::Error::ECapeOutOfBounds) = 0; 00187 00194 virtual Common::Types::CapeDouble GetCvgTolerance() 00195 throw (Common::Error::ECapeUnknown, Common::Error::ECapeBadInvOrder) = 0; 00196 00202 virtual void SetMaxIterations(Common::Types::CapeLong maxIteration) 00203 throw (Common::Error::ECapeUnknown, Common::Error::ECapeInvalidArgument, 00204 Common::Error::ECapeOutOfBounds) = 0; 00205 00212 virtual Common::Types::CapeLong GetMaxIterations() 00213 throw (Common::Error::ECapeUnknown, Common::Error::ECapeBadInvOrder) = 0; 00214 00220 virtual Common::Types::CapeLong DoNIteration(Common::Types::CapeLong nbIterations) 00221 throw (Common::Error::ECapeUnknown, Common::Error::ECapeInvalidArgument, 00222 Common::Error::ECapeOutOfBounds, Common::Error::ECapeBadInvOrder, 00223 Common::Error::ECapeSolvingError, Common::Error::ECapeOutOfResources) = 0; 00224 }; 00225 00234 class ICapeNumericDAESolver : virtual public ICapeNumericSolver { 00235 #ifndef SWIG 00236 00237 friend std::ostream& operator<<(std::ostream& out_file, const ICapeNumericDAESolver& solver); 00238 #endif 00239 public: 00247 virtual void SetRelTolerance(const Common::Types::CapeArrayDouble& relTolValue) 00248 throw (Common::Error::ECapeUnknown, Common::Error::ECapeInvalidArgument, 00249 Common::Error::ECapeOutOfBounds) = 0; 00250 00258 virtual Common::Types::CapeArrayDouble GetRelTolerance() 00259 throw (Common::Error::ECapeUnknown, Common::Error::ECapeBadInvOrder) = 0; 00260 00267 virtual void SetAbsTolerance(const Common::Types::CapeArrayDouble& absTolValues) 00268 throw (Common::Error::ECapeUnknown, Common::Error::ECapeInvalidArgument, 00269 Common::Error::ECapeOutOfBounds) = 0; 00270 00277 virtual Common::Types::CapeArrayDouble GetAbsTolerance() 00278 throw (Common::Error::ECapeUnknown, Common::Error::ECapeBadInvOrder) = 0; 00279 00294 virtual Model::CapeArrayNumericEventInfo* 00295 AdvanceToNextEvent(Model::CapeArrayNumericEventInfo endConditions, 00296 Common::Types::CapeDouble& timeBefore, 00297 Common::Types::CapeDouble& timeAfter) 00298 throw (Common::Error::ECapeUnknown, Common::Error::ECapeInvalidArgument, 00299 Common::Error::ECapeOutOfBounds, Common::Error::ECapeBadInvOrder, 00300 Common::Error::ECapeSolvingError, Common::Error::ECapeOutOfResources, 00301 Common::Error::ECapeNoImpl) = 0; 00302 }; 00309 class ICapeNumericNLPSolver : virtual public ICapeNumericSolver { 00310 public: 00311 00314 virtual void SetNLPTask(Numeric::Solvers::NLPTasks::ICapeNLPTask *task) = 0; 00315 00316 }; 00317 00318 }; 00319 }; 00320 }; 00321 00322 #ifndef SWIG 00323 00324 std::ostream& operator<<(std::ostream& out_file, const Numeric::Solvers::Solver::ICapeNumericSolver& solver); 00326 std::ostream& operator<<(std::ostream& out_file, const Numeric::Solvers::Solver::ICapeNumericLASolver& solver); 00328 std::ostream& operator<<(std::ostream& out_file, const Numeric::Solvers::Solver::ICapeNumericNLASolver& solver); 00330 std::ostream& operator<<(std::ostream& out_file, const Numeric::Solvers::Solver::ICapeNumericDAESolver& solver); 00332 std::ostream& operator<<(std::ostream& out_file, const Numeric::Solvers::Solver::ICapeNumericNLPSolver& solver); 00333 #endif 00334 00335 #endif // CAPE_SOLVER_HPP