close
Warning:
Can't synchronize with repository "(default)" (/var/svn/tolp does not appear to be a Subversion repository.). Look in the Trac log for more information.
- Timestamp:
-
Jan 4, 2011, 2:22:49 PM (14 years ago)
- Author:
-
Víctor de Buen Remiro
- Comment:
-
--
Legend:
- Unmodified
- Added
- Removed
- Modified
-
v16
|
v17
|
|
59 | 59 | La cadena de métodos se define como un conjunto de métodos que será instancias de {{{Class @Method}}} definida en [source:/tolp/OfficialTolArchiveNetwork/NonLinGloOpt/method.tol method.tol] y que se irán añadiendo a la instancia {{{Class @PipeLine}}} mediante el método {{{AddMethod}}}. Si no se especifica ningún método se utilizará uno acorde con la definición del problema. |
60 | 60 | |
61 | | Cada método tendrá definido una serie de parámetros que controlen los criterios de parada y que se incorporarán como instancia de {{{Class @StopCriteria}}} definida en [source:/tolp/OfficialTolArchiveNetwork/NonLinGloOpt/stopCriteria.tol stopCriteria.tol] |
| 61 | El algoritmo de optimización de cada método estará implementado como parte de un motor de optimización que estará definido como una instancia de la clase abstracta {{{Class @Engine}}} definida en [source:/tolp/OfficialTolArchiveNetwork/NonLinGloOpt/engine.tol engine.tol] y de la cual por el momento sólo estará disponible la herencia {{{@Engine_NLopt}}} definida en [source:/tolp/OfficialTolArchiveNetwork/NonLinGloOpt/engine_nlopt.tol engine_nlopt.tol] y que corresponde a la librería C++ [http://ab-initio.mit.edu/wiki/index.php/NLopt_C-plus-plus_Reference nlopt]. |
| 62 | |
| 63 | Cada método tendrá definido una serie de parámetros que controlen los criterios de parada y que se incorporarán como instancia de {{{Class @StopCriteria}}} definida en [source:/tolp/OfficialTolArchiveNetwork/NonLinGloOpt/stopCriteria.tol stopCriteria.tol] |
62 | 64 | |
63 | 65 | === Formulación de funciones objetivo y de restricción === |
… |
… |
|
121 | 123 | #!cpp |
122 | 124 | //Set sign ==- 1 for minimization, sign == 1 for maximization |
123 | | Real sign; |
| 125 | Real sign; |
124 | 126 | |
125 | 127 | //If true, a global optimal point will be searched. Else just a |
126 | 128 | //local one. |
127 | | Real neededGlobal; |
| 129 | Real neededGlobal; |
128 | 130 | |
129 | 131 | //Minimum analytical class of target and constraining functions must be one |
… |
… |
|
140 | 142 | //Indicates if the gradient is known analytically or numerically. |
141 | 143 | //Must be an element of |
142 | | //Set NonLinGloOpt::GradientKnowneledge = |
| 144 | //Set NonLinGloOpt::GradientKnowledge = |
143 | 145 | //[[ |
144 | 146 | //Real NONE = 0, //Doesn't exists or it's too hard to calculate |
… |
… |
|
146 | 148 | //Real NUMERICAL = 2 //Use numerical gradient |
147 | 149 | //]]; |
148 | | Real id_useGradient; |
| 150 | Real id_useGradient; |
149 | 151 | |
| 152 | //Number of variables |
| 153 | Real n; |
| 154 | |
150 | 155 | //Target function could be a simple Code or a class method of a |
151 | 156 | //particular instance. |
… |
… |
|
156 | 161 | Anything target; |
157 | 162 | |
158 | | //Initial values of variables in an nx1 column matrix |
159 | | Matrix x0; |
160 | | |
161 | 163 | }}} |
162 | 164 | |
… |
… |
|
168 | 170 | {{{ |
169 | 171 | #!cpp |
170 | | //Optimization method. |
171 | | //It must be an element of NonLinGloOpt::Algorithm |
172 | | //If it is not specified the system will choose one by calling method |
173 | | //select_automatic_algorithm |
174 | | Real id_algorithm = ?; |
175 | | |
176 | 172 | //Lower bounds for the variables |
177 | 173 | //These must be specified by an nx1 column matrix with the minimum value for each |
178 | 174 | //variable, or -1/0 if the variable is not bounded below |
179 | 175 | //If there are no lower bounds at all then it's the empty matrix |
180 | | Matrix lower_bounds = Rand(0,0,0,0); |
| 176 | Matrix lower_bounds = Rand(0,0,0,0); |
181 | 177 | |
182 | 178 | //Upper bounds for the variables |
… |
… |
|
194 | 190 | //When argument gradient is not empty, then the function, or the |
195 | 191 | //method must update it. |
196 | | Set inequations = Copy(Empty); |
| 192 | Set inequations = Copy(Empty); |
197 | 193 | |
198 | 194 | //Set of equality constraints h(x)<=0 |
… |
… |
|
204 | 200 | //When argument gradient is not empty, then the function, or the |
205 | 201 | //method must update it. |
206 | | Set equations = Copy(Empty); |
| 202 | Set equations = Copy(Empty); |
207 | 203 | |
208 | 204 | //Tolerance for the evaluation of inequality constraints to avoid |
… |
… |
|
214 | 210 | Real equationTolerance = 1E-8; |
215 | 211 | |
216 | | //Relative tolerance of the stopping criteria |
217 | | Real relativeTolerance = 1E-6; |
218 | | |
219 | | //Maximum run time for the stopping criteria |
220 | | Real maxTime = ?; |
221 | | |
222 | | //If verboseEach>0, the evaluation of the target function will be traced |
223 | | //every "verboseEach" evaluations. |
224 | | Real verboseEach = 100; |
225 | | |
226 | 212 | }}} |
227 | 213 | |
… |
… |
|
229 | 215 | === Creación y lanzamiento de la optimización === |
230 | 216 | |
231 | | Una vez definido un problema hay que crear el motor de optimización como una instancia de {{{Class @Opt}}} definida en [source:/tolp/OfficialTolArchiveNetwork/NonLinGloOpt/opt.tol opt.tol] |
232 | | {{{ |
233 | | #!cpp |
234 | | //Creating the optimizer instance |
235 | | NonLinGloOpt::@Opt opt = problem::create_optimizer(?); |
236 | | }}} |
237 | | |
238 | | y finalmente se llamará al método de optimización para que ejecute el algoritmo |
239 | | |
240 | | {{{ |
241 | | #!cpp |
242 | | //Running the optimization |
243 | | Real opt::optimize_problem(problem); |
244 | | }}} |
245 | | |
246 | | Entre medio de ambas acciones, el usuario avanzado puede retocar la instancia |
247 | | {{{opt}}} mediante los métodos de {{{@Opt}}}, cada uno de los cuales implementa |
248 | | los métodos de la clase C++ interna {{{nlopt::opt}}} cuya API puede verse |
249 | | [http://ab-initio.mit.edu/wiki/index.php/NLopt_C-plus-plus_Reference aquí] |
250 | | Estos métodos pueden leerse directamente en el [source:/tolp/OfficialTolArchiveNetwork/NonLinGloOpt/opt.tol código TOL] o exporarse en la interfaz de TOLBase. |
| 217 | El esqueleto del código de uso del paquete sería el siguiente |
| 218 | {{{ |
| 219 | #!cpp |
| 220 | //Defines the problem and the optimization pipe-line |
| 221 | NonLinGloOpt::@PipeLine pipe_line = [[ |
| 222 | //The problem (or problems) to be optimized. In this version just the first |
| 223 | //one will be solved |
| 224 | Set problems = [[ NonLinGloOpt::@Problem problem = [[ |
| 225 | ... |
| 226 | ]] ]]; |
| 227 | //The system will show a trace every this number of evaluations of target |
| 228 | //function |
| 229 | Real verboseEach = 100 |
| 230 | ]]; |
| 231 | |
| 232 | //Runs the optimization sequence |
| 233 | Real pipe_line::optimize(?); |
| 234 | |
| 235 | //Access to optimal point |
| 236 | Matrix pipe_line::x.opt; |
| 237 | //Access to optimal value of target function |
| 238 | Real pipe_line::y.opt; |
| 239 | |
| 240 | }}} |
| 241 | |
251 | 242 | |
252 | 243 | [[Image(source:/tolp/OfficialTolArchiveNetwork/NonLinGloOpt/doc/opt_methods.png)]] |