ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-3.0/src/minimizers/OOPSEMinimizer.hpp
Revision: 1884
Committed: Tue Dec 14 19:08:44 2004 UTC (20 years, 7 months ago) by tim
File size: 5743 byte(s)
Log Message:
more fix in MPI version

File Contents

# User Rev Content
1 tim 1884 /*
2     * Copyright (C) 2000-2004 Object Oriented Parallel Simulation Engine (OOPSE) project
3     *
4     * Contact: oopse@oopse.org
5     *
6     * This program is free software; you can redistribute it and/or
7     * modify it under the terms of the GNU Lesser General Public License
8     * as published by the Free Software Foundation; either version 2.1
9     * of the License, or (at your option) any later version.
10     * All we ask is that proper credit is given for our work, which includes
11     * - but is not limited to - adding the above copyright notice to the beginning
12     * of your source code files, and to any copyright notice that you may distribute
13     * with programs based on this work.
14     *
15     * This program is distributed in the hope that it will be useful,
16     * but WITHOUT ANY WARRANTY; without even the implied warranty of
17     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18     * GNU Lesser General Public License for more details.
19     *
20     * You should have received a copy of the GNU Lesser General Public License
21     * along with this program; if not, write to the Free Software
22     * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23     *
24     */
25 gezelter 1490
26 tim 1884 #ifndef MINIMIZERS_OOPSEMINIMIZER_HPP
27     #define MINIMIZERS_OOPSEMINIMIZER_HPP
28    
29 gezelter 1490 #include <iostream>
30    
31 tim 1492 #include "integrators/Integrator.hpp"
32     #include "minimizers/MinimizerParameterSet.hpp"
33 gezelter 1490
34    
35    
36 tim 1824
37 tim 1884
38     // base class of minimizer
39    
40     namespace oopse {
41    
42     /** @todo need refactorying */
43 gezelter 1490 const int MIN_LSERROR = -1;
44     const int MIN_MAXITER = 0;
45     const int MIN_CONVERGE = 1;
46    
47     const int CONVG_UNCONVG = 0;
48     const int CONVG_FTOL = 1;
49     const int CONVG_GTOL = 2;
50     const int CONVG_ABSGTOL = 3;
51     const int CONVG_STEPTOL = 4;
52    
53     const int LS_SUCCEED =1;
54     const int LS_ERROR = -1;
55    
56    
57 tim 1884 class OOPSEMinimizer {
58     public:
59 gezelter 1490
60 tim 1884 OOPSEMinimizer(SimInfo *theInfo, MinimizerParameterSet* param);
61 gezelter 1490
62 tim 1884 virtual ~OOPSEMinimizer();
63 gezelter 1490
64 tim 1884 //
65     virtual void init() {}
66 gezelter 1490
67 tim 1884 //driver function of minimization method
68     virtual void minimize();
69 gezelter 1490
70 tim 1884 //
71     virtual int step() = 0;
72 gezelter 1490
73 tim 1884 //
74     virtual void prepareStep() {};
75 gezelter 1490
76 tim 1884 //line search algorithm, for the time being, we use back track algorithm
77     virtual int doLineSearch(std::vector<double>& direction, double stepSize);
78 gezelter 1490
79 tim 1884 virtual int checkConvg() = 0;
80 gezelter 1490
81 tim 1884 //print detail information of the minimization method
82     virtual void printMinimizerInfo();
83 gezelter 1490
84 tim 1884 //save the result when minimization method is done
85     virtual void saveResult(){}
86 gezelter 1490
87 tim 1884 //write out the trajectory
88     virtual void writeOut(std::vector<double>&x, double curIter);
89 gezelter 1490
90    
91 tim 1884 //get the status of minimization
92     int getMinStatus() {return minStatus;}
93 gezelter 1490
94 tim 1884 // get the dimension of the model
95     int getDim() { return ndim; }
96 gezelter 1490
97 tim 1884 //get the name of minimizer method
98     std::string getMinimizerName() { return minimizerName; }
99 gezelter 1490
100 tim 1884 //return number of current Iteration
101     int getCurIter() { return curIter; }
102 gezelter 1490
103 tim 1884 // set the verbose mode of minimizer
104     void setVerbose(bool verbose) { bVerbose = verbose;}
105 gezelter 1490
106 tim 1884 //get and set the coordinate
107     std::vector<double> getX() { return curX; }
108     void setX(std::vector<double>& x);
109 gezelter 1490
110 tim 1884 //get and set the value of object function
111     double getF() { return curF; }
112     void setF(double f) { curF = f; }
113 gezelter 1490
114 tim 1884 std::vector<double> getG() { return curG; }
115     void setG(std::vector<double>& g);
116 gezelter 1490
117 tim 1884 //get and set the gradient
118     std::vector<double> getGrad() { return curG; }
119     void setGrad(std::vector<double>& g) { curG = g; }
120 gezelter 1490
121 tim 1884 //interal function to evaluate the energy and gradient in OOPSE
122     void calcEnergyGradient(vector<double>& x, std::vector<double>& grad, double&
123     energy, int& status);
124 gezelter 1490
125 tim 1884 //calculate the value of object function
126     virtual void calcF();
127     virtual void calcF(std::vector<double>& x, double&f, int& status);
128 gezelter 1490
129 tim 1884 //calculate the gradient
130     virtual void calcG();
131     virtual void calcG(std::vector<double>& x, std::vector<double>& g, double& f, int& status);
132 gezelter 1490
133 tim 1884 //calculate the hessian
134     //virtual void calcH(int& status);
135     //virtual void calcH(vector<double>& x, std::vector<dobule>& g, SymMatrix& h, int& status);
136 gezelter 1490
137    
138 tim 1884 protected:
139 gezelter 1490
140 tim 1884 // transfrom cartesian and rotational coordinates into minimization coordinates
141     std::vector<double> getCoor();
142 gezelter 1490
143 tim 1884 // transfrom minimization coordinates into cartesian and rotational coordinates
144     void setCoor(std::vector<double>& x);
145 gezelter 1490
146 tim 1884 //flag of turning on shake algorithm
147     bool bShake;
148 gezelter 1490
149 tim 1884 //constraint the bonds;
150     int shakeR();
151 gezelter 1490
152 tim 1884 //remove the force component along the bond direction
153     int shakeF();
154 gezelter 1490
155    
156 tim 1884 SimInfo* info;
157    
158     //parameter set of minimization method
159     MinimizerParameterSet* paramSet;
160 gezelter 1490
161 tim 1884 // dimension of the model
162     int ndim;
163 gezelter 1490
164 tim 1884 //name of the minimizer
165     std::string minimizerName;
166 gezelter 1490
167 tim 1884 // current iteration number
168     int curIter;
169     //status of minimization
170     int minStatus;
171 gezelter 1490
172 tim 1884 //flag of verbose mode
173     bool bVerbose;
174 gezelter 1490
175    
176 tim 1884 //status of energy and gradient evaluation
177     int egEvalStatus;
178 gezelter 1490
179 tim 1884 //initial coordinates
180     //vector<double> initX;
181 gezelter 1490
182 tim 1884 //current value of the function
183     double curF;
184     // current coordinates
185     std::vector<double> curX;
186     //gradient at curent coordinates
187     std::vector<double> curG;
188 gezelter 1490
189 tim 1884 //hessian at current coordinates
190     //SymMatrix curH;
191 gezelter 1490
192 tim 1884 private:
193 gezelter 1490
194 tim 1884 //calculate the dimension od the model for minimization
195     void calcDim();
196 gezelter 1490
197     };
198    
199 tim 1884 }
200     #endif
201 gezelter 1490

Properties

Name Value
svn:executable *