|
Optimizaci�n M�nimos Cuadrados de la Ecuaci�n Log�stica con Quasi Newton modificado y Double dogleg step | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Method Summary | |
void |
chartDoglegFile( VectorDouble& time, VectorDouble& population, VectorDouble& xc, TChart* chart )
|
bool |
checkFactorizeCholesky( int n, SquaredMatrix& A, SquaredMatrix& L )
Checa parametros: dimensiones, rangos, divisiones entre cero |
void |
checkFiniteHessianFunction( int n, VectorDouble& xc, double fc, FunctionND_1D& theFunction, VectorDouble& Sx, SquaredMatrix& H, double eta = MACHEPS )
Checa parametros: dimensiones, rangos, divisiones entre cero |
void |
checkFiniteHessianGradients( int n, VectorDouble& xc, VectorDouble& g, FunctionND& grad, VectorDouble& Sx, SquaredMatrix& H, double eta = MACHEPS )
Checa parametros: dimensiones, rangos, divisiones entre cero |
void |
checkFiniteNewtonDogLeg( int n, VectorDouble& xc, double& fc, FunctionND_1D& theFunction, VectorDouble& Sx, int iterations, double maxstep, double steptol, double& delta, double eta = MACHEPS, int logType = SHORT_LOG, int waitType = NO_LOG, string pathFile = "finiteNewtonDogleg.txt" )
Checa parametros: dimensiones, rangos. |
void |
checkForwardGradient( int n, VectorDouble& xc, double fc, FunctionND_1D& theFunction, VectorDouble& Sx, VectorDouble& g, double eta = MACHEPS )
Checa parametros: dimensiones, rangos, divisiones entre cero |
void |
checkLogisticNewtonDogLeg( int n, VectorDouble& t, VectorDouble& P, VectorDouble& xc, double& fc, VectorDouble& Sx, int iterations, double maxstep, double steptol, double& delta, double eta, int logType, int waitType, string pathFile )
Checa parametros: dimensiones, rangos. |
void |
doubleDogLegDriver( int n, VectorDouble& xc, double fc, FunctionND_1D& theFunction, VectorDouble& g, SquaredMatrix& L, VectorDouble& sN, VectorDouble& Sx, double maxstep, double steptol, double& delta, int& retcode, VectorDouble& xp, double& fp, bool& maxtaken, bool& Newttaken, int logType = SHORT_LOG, int waitType = NO_WAIT )
Busca una x+ en la curva double dogleg tal que f(x+) <= f(xc) + ag^T (x+ - xc) (se usa alfa = 10^-4) y un taman~o de paso escalado steplength = delta, iniciando con la entrada delta pero incrementando o decrementando delta si es necesario. Tambien, produce una region de confianza inicial delta para la siguiente iteracion. Se llama al algoritmo A6.4.4. y A6.4.5 A6.4.4. para el taman~o de paso. A6.4.5. Aceptar Usa logica uno.
|
void |
doubleDogLegStep( int n, VectorDouble& g, SquaredMatrix& L, VectorDouble& sN, VectorDouble& Sx, double Newtlen, double maxstep, double& delta, bool& firstdog, double& Cauchylen, double& eta, VectorDouble& sSD, VectorDouble& v, VectorDouble& s, bool& Newttaken, int logType = SHORT_LOG, int waitType = NO_WAIT )
Busca una solucion aproximada a min g^T s + 1/2 s^T L L^T s s E R^n sujeto a ||Dx s||2 <= delta mediante la seleccion de s en la curca del double dogleg descrito abajo de tal forma que ||Dx s||2 = delta, o s = SN si Newtlen <= delta. (Dx = diag ((Sx)1, ..., (sx)n). Logica uno.
|
double |
eigenPower( SquaredMatrix& A, int M, int seq )
Realiza M pasos iterativos del metodo de la potencia para obtener el eigenvalor dominante de la matriz A. |
bool |
factorizeCholesky( int n, SquaredMatrix& A, SquaredMatrix& L )
Obtiene la factorizacion de Cholesky. |
void |
finiteHessianFunction( int n, VectorDouble& xc, double fc, FunctionND_1D& theFunction, VectorDouble& Sx, SquaredMatrix& H, double eta = MACHEPS )
Calcula una aproximacion hacia adelante mediante diferencias finitas hacia la hessiana (grad^2(f(xc)) usando solo los valores de f(xc). Uso: fc = func.evaluate(xc); // debe ser parametro, modularidad libro finiteHessianFunction(xc, fc, Sx, func, H, 1e-8); H.upperTriangularToSymmetric(); // si desea matriz rellena Solo la diagonal y el triangulo superior de H fueron ocupados, debido a que estas son las unicas porciones de H que son referenciadas por el resto del sistema de algoritmos. No necesita cambios, si se desea economizar el almacenaminto. ei es el i-esimo vector unitario.
|
void |
finiteHessianFunctionCubic( int n, VectorDouble& xc, double fc, FunctionND_1D& theFunction, VectorDouble& Sx, SquaredMatrix& H, double eta = MACHEPS )
|
void |
finiteHessianFunctionSquare( int n, VectorDouble& xc, double fc, FunctionND_1D& theFunction, VectorDouble& Sx, SquaredMatrix& H, double eta = MACHEPS )
|
void |
finiteHessianGradients( int n, VectorDouble& xc, VectorDouble& g, FunctionND& grad, VectorDouble& Sx, SquaredMatrix& H, double eta = MACHEPS )
Calcula una aproximacion hacia adelante mediante diferencias finitas hacia la matriz Hessiana (grad^2(f(xc)) usando valores analiticos del gradiente (grad(f(xc)). Uso: func.evaluate(xc, g); finiteHessianGradients(n, xc, g, func, Sx, H); Solo la diagonal y el triangulo superior de H tienen valores correctos despues de regresar del algoritmo, debido a que estas son las unicas porciones de H que son referenciadas por el resto del sistema de algoritmos. De cualquier forma, le matriz completa H es usada como un paso intermedio. No necesita cambios, si se desea economizar el almacenaminto.
|
void |
finiteNewtonDogLeg( int n, VectorDouble& xc, double& fc, FunctionND_1D& theFunction, VectorDouble& Sx, int iterations, double maxstep, double steptol, double& delta, double eta = MACHEPS, int logType = SHORT_LOG, int waitType = NO_WAIT, string pathFile = "finiteNewtonDogleg.txt" )
Aproximacion por diferencias finitas por el metodo de quasi Newton Para la decision del paso elige entre elpaso de Newton o el DogLeg. |
void |
forwardGradient( int n, VectorDouble& xc, double fc, FunctionND_1D& theFunction, VectorDouble& Sx, VectorDouble& g, double eta = MACHEPS )
Calcula una aproximacion hacia adelante hacia el gradiente grad(f(xc)) usando solo los valores de f(xc). |
void |
graphDoglegFile( string pathFile, TImage* image, double xMin, double xMax, double yMin, double yMax, bool pauses, bool showEvaluation, double pixelsPerUnit )
Ejemplo: graphDoglegFile("finiteNewtonDogleg.dat", DogImage, xMin, xMax, yMin, yMax, CheckPauses->Checked, CheckShowEvaluation->Checked); |
void |
hessianEvaluate( VectorDouble& xc, SquaredMatrix& H )
|
void |
logisticMatrices( VectorDouble& t, VectorDouble& P, VectorDouble& xc, VectorDouble& ri, RectangularMatrix& J, VectorDouble& g, SquaredMatrix& H )
|
void |
logisticNewtonDogLeg( int n, VectorDouble& t, VectorDouble& P, VectorDouble& xc, double& fc, VectorDouble& Sx, int iterations, double maxstep, double steptol, double& delta, double eta, int logType, int waitType, string pathFile )
Aproximacion por diferencias finitas por el metodo de quasi Newton Para la decision del paso elige entre elpaso de Newton o el DogLeg. |
void |
updateTrustRegion( int n, VectorDouble& xc, double fc, FunctionND_1D& theFunction, VectorDouble& g, SquaredMatrix& L, VectorDouble& s, VectorDouble& Sx, bool Newttaken, double maxstep, double steptol, int steptype, SquaredMatrix& H, double& delta, int& retcode, VectorDouble& xpprev, double& fpprev, VectorDouble& xp, double& fp, bool& maxtaken, int logType = SHORT_LOG, int waitType = NO_WAIT )
Dado un paso s, encontrado por el algoritmo Hook Step o DogStep, decide cuando x+ = xc + s debe ser aceptado para la siguiente iteracion. |
Method Detail |
void chartDoglegFile( VectorDouble& time, VectorDouble& population, VectorDouble& xc, TChart* chart );
xc
- Contiene a, b, cbool checkFactorizeCholesky( int n, SquaredMatrix& A, SquaredMatrix& L ) throw( invalid_argument );
void checkFiniteHessianFunction( int n, VectorDouble& xc, double fc, FunctionND_1D& theFunction, VectorDouble& Sx, SquaredMatrix& H, double eta = MACHEPS ) throw( invalid_argument );
void checkFiniteHessianGradients( int n, VectorDouble& xc, VectorDouble& g, FunctionND& grad, VectorDouble& Sx, SquaredMatrix& H, double eta = MACHEPS ) throw( invalid_argument );
void checkFiniteNewtonDogLeg( int n, VectorDouble& xc, double& fc, FunctionND_1D& theFunction, VectorDouble& Sx, int iterations, double maxstep, double steptol, double& delta, double eta = MACHEPS, int logType = SHORT_LOG, int waitType = NO_LOG, string pathFile = "finiteNewtonDogleg.txt" ) throw( invalid_argument, runtime_error );
void checkForwardGradient( int n, VectorDouble& xc, double fc, FunctionND_1D& theFunction, VectorDouble& Sx, VectorDouble& g, double eta = MACHEPS ) throw( invalid_argument );
void checkLogisticNewtonDogLeg( int n, VectorDouble& t, VectorDouble& P, VectorDouble& xc, double& fc, VectorDouble& Sx, int iterations, double maxstep, double steptol, double& delta, double eta, int logType, int waitType, string pathFile ) throw( invalid_argument, runtime_error );
void doubleDogLegDriver( int n, VectorDouble& xc, double fc, FunctionND_1D& theFunction, VectorDouble& g, SquaredMatrix& L, VectorDouble& sN, VectorDouble& Sx, double maxstep, double steptol, double& delta, int& retcode, VectorDouble& xp, double& fp, bool& maxtaken, bool& Newttaken, int logType = SHORT_LOG, int waitType = NO_WAIT ) throw( invalid_argument );
n
- Taman~o de vectores y matrices. No se checan dimensiones.
xc
- Vector con punto de prueba inicial. De aqui se toma la dimension
fc
- Evaluacion de la funcion en xc.
theFunction
- Nombre de la funcion. F:R^n->R. FN.
g
- Gradiente
L
- Triangular inferior
sN
- = - (L L^T)^-1 g). Neton step.
Sx
- Escala. Valores usuales.
maxstep
- Maximo taman~o de paso. Dado por QuasiNewton
steptol
- Precision del paso
delta
- in/out Radio de la region de confianza.
retcode
- return
0: x+ satisfactorio encontrado
1: la rutina fallo para encontrar una x+ satisfactoria,
suficientemente distinta de xc.
xp
- return x+
fp
- return f+
maxtaken
- return
Newttaken
- return Este parametro es solo informativo,
no vienen en Dennis, se usa para escribir en archivo.
true: Se usa el paso de Newton
false: se usa el dogleg stepA6.4.3. DOGDRIVER pagina 335
void doubleDogLegStep( int n, VectorDouble& g, SquaredMatrix& L, VectorDouble& sN, VectorDouble& Sx, double Newtlen, double maxstep, double& delta, bool& firstdog, double& Cauchylen, double& eta, VectorDouble& sSD, VectorDouble& v, VectorDouble& s, bool& Newttaken, int logType = SHORT_LOG, int waitType = NO_WAIT ) throw( invalid_argument );
n
- Taman~o de vectores y matrices. No se checan dimensiones.
g
- Gradiente
L
- Triangular inferior. Se usa para construir el inverso de la Hessiana.
sN
- = - (L L^T)^-1 g)
Sx
Newtlen
- = ||Dx sN||2
maxstep
- Maximo taman~o de paso. Dado por QuasiNewton
delta
- in/out
firstdog
- in/out
false: Cauchylen, eta, sSD, v
tendran valores actuales en in/out.
true: Los parametros mencionados no se tomaran en cuenta.
Inicializa los parametros.
Cauchylen
- in/out
eta
- in/out gamma <= eta <=1
sSD
- in/out
v
- in/out
s
- return Paso escogido
Newttaken
- return
true: Se usa el paso de Newton
false: se usa el dogleg stepA6.4.4. DOGSTEP pagina 336
double eigenPower( SquaredMatrix& A, int M, int seq );
M
- numero de iteraciones
seq
- se intenta encontrar el eigenvalor numero seqbool factorizeCholesky( int n, SquaredMatrix& A, SquaredMatrix& L );
A
- Matriz cuadrada simetrica a factorizar.
No se requiere U, porque U = Lt
Matriz positiva definida. det(A) = 324
| 1 2 4 |
A = | 3 13 23 |
| 4 23 77 |
| 1 0 0 |
L = | 2 3 0 |
| 4 5 6 |
| 60 30 20 |
A = | 30 20 15 | is positive definite, non symmetric
| 20 15 12 |
| -60 30 20 |
A' = | 30 -20 15 | is not positive definite
| 20 15 -12 |
L
- return Factor en forma de matriz triangular inferior.void finiteHessianFunction( int n, VectorDouble& xc, double fc, FunctionND_1D& theFunction, VectorDouble& Sx, SquaredMatrix& H, double eta = MACHEPS ) throw( invalid_argument );
n
- Taman~o de vectores y matrices. No se checan dimensiones.
xc
- Vector con punto de prueba inicial. De aqui se toma la dimension
fc
- Evaluacion de la funcion en xc.
Sx
- Escala. Valores usuales.
theFunction
- Nombre de la funcion. F:R^n->R. FN.
H
- return. Aproximacion a la matriz hessiana simetrica
( equiv grad^2(f(xc)) ). No resize.
eta
- Precision de la maquina. Omision: mathpos::MACHEPS.A5.6.2 (FDHESSF). Dennis. Pagina 321.
Probar con ejemplo 4.1.6. pag 72.
void finiteHessianFunctionCubic( int n, VectorDouble& xc, double fc, FunctionND_1D& theFunction, VectorDouble& Sx, SquaredMatrix& H, double eta = MACHEPS ) throw( invalid_argument );
void finiteHessianFunctionSquare( int n, VectorDouble& xc, double fc, FunctionND_1D& theFunction, VectorDouble& Sx, SquaredMatrix& H, double eta = MACHEPS ) throw( invalid_argument );
void finiteHessianGradients( int n, VectorDouble& xc, VectorDouble& g, FunctionND& grad, VectorDouble& Sx, SquaredMatrix& H, double eta = MACHEPS ) throw( invalid_argument );
xc
- Vector con punto de prueba inicial. De aqui se toma la dimension
grad
- Funcion gradiente. grad(f) : R^n -> R^n
g
- grad(f(xc)) Evaluacion del gradiente.
Sx
- Escala de xc.
H
- return. Matriz hessiana simetrica ( equiv grad^2(f(xc)) )
eta
- Precision de la maquina. Omision: mathpos::MACHEPS.Pagina 320
Algoritmo A5.6.1 (FDHESSG).
Ejemplo 4.1.3 pag 72.
void finiteNewtonDogLeg( int n, VectorDouble& xc, double& fc, FunctionND_1D& theFunction, VectorDouble& Sx, int iterations, double maxstep, double steptol, double& delta, double eta = MACHEPS, int logType = SHORT_LOG, int waitType = NO_WAIT, string pathFile = "finiteNewtonDogleg.txt" ) throw( runtime_error );
n
- Entero. Natural. Dimension de las matrices y vectores.
xc
- IN/OUT
IN: Vector con punto de prueba inicial.
OUT: Solucion
fc
- IN/OUT
IN: Vector con evaluacion punto de prueba inicial.
OUT: Evaluacion de la solucion
theFunction
- Nombre de la funcion. F:R^n->R^n. FVEC.
Sx
- Escala. Valores usuales.
maxstep
- Maximo taman~o de paso. Dado por QuasiNewton
steptol
- Precision del paso
delta
- in/out Radio de la region de confianza.
xp
- return x+
fp
- return f+
eta
- Precision de la maquina. Omision: mathpos::MACHEPS.
deb
- debug. Mostrar resultados.
0: No mostrar.
1: Mostrar resumen, version corta.
2: Mostrar pasos intermedios, version larga.
logType
314-315
void forwardGradient( int n, VectorDouble& xc, double fc, FunctionND_1D& theFunction, VectorDouble& Sx, VectorDouble& g, double eta = MACHEPS );
n
- Entero. Natural. Dimension de las matrices y vectores.
xc
- Vector con punto de prueba inicial.
fc
- Evaluacion en xc (equivale a f(xc))
theFunction
- Nombre de la funcion. F:R^n->R. FN
Sx
- Escala de xc.
g
- return Aproximacion al grad(f(xc)).
eta
- Precision de la maquina. Omision: mathpos::MACHEPS.Pagina 320
Algoritmo A5.6.3 (FDGRAD).
Ejemplo 4.1.3 pag 72
void graphDoglegFile( string pathFile, TImage* image, double xMin, double xMax, double yMin, double yMax, bool pauses, bool showEvaluation, double pixelsPerUnit );
graphDoglegFile("finiteNewtonDogleg.dat", DogImage, xMin, xMax, yMin, yMax, CheckPauses->Checked, CheckShowEvaluation->Checked);
void hessianEvaluate( VectorDouble& xc, SquaredMatrix& H );
void logisticMatrices( VectorDouble& t, VectorDouble& P, VectorDouble& xc, VectorDouble& ri, RectangularMatrix& J, VectorDouble& g, SquaredMatrix& H );
t
- Tiempo. Dim: m.
P
- Poblacion. Dim: m.
x
- Coeficientes. x[1] = a, x[2] = b, x[3] = c. Dim: 3.
ri
- return Residuos. Dim: m.
g
- return Gradiente. Dim: m.
J
- return Jacobiana. Dim: mx3.
H
- return Hessiana. Dim: mxm.void logisticNewtonDogLeg( int n, VectorDouble& t, VectorDouble& P, VectorDouble& xc, double& fc, VectorDouble& Sx, int iterations, double maxstep, double steptol, double& delta, double eta, int logType, int waitType, string pathFile ) throw( runtime_error );
n
- Entero. Natural. Dimension de las matrices y vectores.
xc
- IN/OUT
IN: Vector con punto de prueba inicial.
OUT: Solucion
fc
- IN/OUT
IN: Vector con evaluacion punto de prueba inicial.
OUT: Evaluacion de la solucion
theFunction
- Nombre de la funcion. F:R^n->R^n. FVEC.
Sx
- Escala. Valores usuales.
maxstep
- Maximo taman~o de paso. Dado por QuasiNewton
steptol
- Precision del paso
delta
- in/out Radio de la region de confianza.
xp
- return x+
fp
- return f+
eta
- Precision de la maquina. Omision: mathpos::MACHEPS.
deb
- debug. Mostrar resultados.
0: No mostrar.
1: Mostrar resumen, version corta.
2: Mostrar pasos intermedios, version larga.
logType
314-315
void updateTrustRegion( int n, VectorDouble& xc, double fc, FunctionND_1D& theFunction, VectorDouble& g, SquaredMatrix& L, VectorDouble& s, VectorDouble& Sx, bool Newttaken, double maxstep, double steptol, int steptype, SquaredMatrix& H, double& delta, int& retcode, VectorDouble& xpprev, double& fpprev, VectorDouble& xp, double& fp, bool& maxtaken, int logType = SHORT_LOG, int waitType = NO_WAIT ) throw( invalid_argument );
n
- Taman~o de vectores y matrices. No se checan dimensiones.
xc
- Vector con punto de prueba inicial. De aqui se toma la dimension
fc
- Evaluacion de la funcion en xc.
theFunction
- Nombre de la funcion. F:R^n->R. FN.
g
- Gradiente
L
- Triangular inferior de la Hessiana
s
- Paso: dogleg o hook
Sx
- Escala. Valores usuales.
Newttaken
- true: Se tomo el paso de Newton
maxstep
- Maximo taman~o del paso, delta\. Dado por QuasiNewton
steptol
- Precision del paso
steptype
- 1: hookstep. Necesita a H
2: dogstep
H
- Modelo Hessiano simetrica. Usada si steptype = 1.
delta
- in/out Radio de la region de confianza.
retcode
- in/out
0: x+ aceptado como la siguiente iteracion,
delta es la region de confianza para la siguiente iteracion.
1: x+ no satisfactorio pero el paso global es terminado
debido a que el taman~o relativo de (x+ - xc)
esta dentro de la tolerancia del taman~o de paso para detener
el algoritmo de detencion, indicando en la mayoria de los casos
que no sera posible un progeso.
Ver termcode = 3 de A7.2.1. y A7.2.3.
2: f(x+) es muy grande, la iteracion actual va a continuar con una
delta reducida.
3: f(x+) suficientemente pequen~a, pero con la oportunidad de tomar
un paso exitoso mas largo, que parece ser suficientemente
bueno que el de la iteracion actual,
el cual va a continuar con una nueva delta doble.
xpprev
- in/out x+prev xpprev, fpprev tendran valores actuales en la
entrada, o nyuevos valores en la salida solo si retcode = 3, en ese punto.
Es la posicion siguiente aceptable antes de probar con una nueva x+.
fpprev
- in/out f+prev. Es el valor de la funcion aceptable antes
de probar con una nueva x+.
xp
- return x+ Siguiente paso elegido.
fp
- return f+ Valor de la funcion con el siguiente paso elegido.
maxtaken
- return
true: Si el taman~o de paso es mayor que el 99% de maxstep.
Acepta x+ como una nueva iteracion, y escoge nueva delta.A6.4.5. TRUSTREGUP pagina 338
|
Optimizaci�n M�nimos Cuadrados de la Ecuaci�n Log�stica con Quasi Newton modificado y Double dogleg step | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |