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.

Changes between Version 16 and Version 17 of OfficialTolArchiveNetworkNonLinGloOpt


Ignore:
Timestamp:
Jan 4, 2011, 2:22:49 PM (14 years ago)
Author:
Víctor de Buen Remiro
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • OfficialTolArchiveNetworkNonLinGloOpt

    v16 v17  
    5959La 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.
    6060
    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]
     61El 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
     63Cada 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]
    6264
    6365=== Formulación de funciones objetivo y de restricción ===
     
    121123#!cpp
    122124//Set sign ==- 1 for minimization, sign == 1 for maximization
    123   Real sign;         
     125  Real sign;
    124126 
    125127//If true, a global optimal point will be searched. Else just a
    126128//local one.
    127   Real neededGlobal; 
     129  Real neededGlobal;
    128130 
    129131//Minimum analytical class of target and constraining functions must be one
     
    140142//Indicates if the gradient is known analytically or numerically.
    141143//Must be an element of
    142 //Set NonLinGloOpt::GradientKnowneledge =
     144//Set NonLinGloOpt::GradientKnowledge =
    143145//[[
    144146//Real NONE        = 0,  //Doesn't exists or it's too hard to calculate
     
    146148//Real NUMERICAL   = 2   //Use numerical gradient
    147149//]];
    148   Real id_useGradient; 
     150  Real id_useGradient;
    149151 
     152//Number of variables
     153  Real n;
     154
    150155//Target function could be a simple Code or a class method of a
    151156//particular instance.
     
    156161  Anything target;
    157162
    158 //Initial values of variables in an nx1 column matrix
    159   Matrix x0;       
    160 
    161163}}}
    162164
     
    168170{{{
    169171#!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 
    176172//Lower bounds for the variables
    177173//These must be specified by an nx1 column matrix with the minimum value for each
    178174//variable, or -1/0 if the variable is not bounded below
    179175//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);
    181177
    182178//Upper bounds for the variables
     
    194190//When argument gradient is not empty, then the function, or the
    195191//method must update it.
    196   Set inequations = Copy(Empty); 
     192  Set inequations = Copy(Empty);
    197193
    198194//Set of equality constraints h(x)<=0
     
    204200//When argument gradient is not empty, then the function, or the
    205201//method must update it.
    206   Set equations = Copy(Empty);   
     202  Set equations = Copy(Empty);
    207203
    208204//Tolerance for the evaluation of inequality constraints to avoid 
     
    214210  Real equationTolerance = 1E-8;
    215211
    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 
    226212}}}
    227213
     
    229215=== Creación y lanzamiento de la optimización ===
    230216
    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.
     217El esqueleto del código de uso del paquete sería el siguiente
     218{{{
     219#!cpp
     220//Defines the problem and the optimization pipe-line
     221NonLinGloOpt::@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
     233Real pipe_line::optimize(?);
     234
     235//Access to optimal point
     236Matrix pipe_line::x.opt;
     237//Access to optimal value of target function
     238Real pipe_line::y.opt;
     239
     240}}}
     241
    251242
    252243[[Image(source:/tolp/OfficialTolArchiveNetwork/NonLinGloOpt/doc/opt_methods.png)]]