Class CDOptimizeBase
java.lang.Object
gov.nih.mipav.view.renderer.WildMagic.AAM.CDOptimizeBase
- Direct Known Subclasses:
CDOptimizeBFGS,CDOptimizeCG,CDOptimizePS,CDOptimizeSA,CDOptimizeSD
This is the Java modified version of C++ active appearance model API
(AAM_API). It is modified with a subset of required functions for automatic
MRI prostate segmentation.
AAM-API LICENSE - file: license.txt
This software is freely available for non-commercial use such as
research and education. Please see the full disclaimer below.
All publications describing work using this software should cite
the reference given below.
Copyright (c) 2000-2003 Mikkel B. Stegmann, mbs@imm.dtu.dk
IMM, Informatics invalid input: '&' Mathematical Modelling
DTU, Technical University of Denmark
Richard Petersens Plads, Building 321
DK-2800 Lyngby, Denmark
http://www.imm.dtu.dk/~aam/
REFERENCES
Please use the reference below, when writing articles, reports etc. where
the AAM-API has been used. A draft version the article is available from
the homepage.
I will be happy to receive pre- or reprints of such articles.
/Mikkel
-------------
M. B. Stegmann, B. K. Ersboll, R. Larsen, "FAME -- A Flexible Appearance
Modelling Environment", IEEE Transactions on Medical Imaging, IEEE, 2003
(to appear)
-------------
3RD PART SOFTWARE
The software is partly based on the following libraries:
- The Microsoft(tm) Vision Software Developers Kit, VisSDK
- LAPACK
DISCLAIMER
This software is provided 'as-is', without any express or implied warranty.
In no event will the author be held liable for any damages arising from the
use of this software.
Permission is granted to anyone to use this software for any non-commercial
purpose, and to alter it, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim
that you wrote the original software.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
--
No guarantees of performance accompany this software, nor is any
responsibility assumed on the part of the author or IMM.
This software is provided by Mikkel B. Stegmann and IMM ``as is'' and any
express or implied warranties, including, but not limited to, the implied
warranties of merchantability and fitness for a particular purpose are
disclaimed. In no event shall IMM or Mikkel B. Stegmann be liable for any
direct, indirect, incidental, special, exemplary, or consequential damages
(including, but not limited to, procurement of substitute goods or services;
loss of use, data, or profits; or business interruption) however caused and
on any theory of liability, whether in contract, strict liability, or tort
(including negligence or otherwise) arising in any way out of the use of
this software, even if advised of the possibility of such damage.
$Revision: 1.4 $
$Date: 2003/04/23 14:49:15 $
Optimization base class. This abstract class is the base class for all
classes implementing specific optimization procedures.
author: Rune Fisker, 26/1-1999
- Author:
- Ruida Cheng
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic intintstatic intstatic intintstatic intstatic intstatic intstatic intintstatic intstatic intstatic intstatic intstatic intstatic intstatic intstatic intstatic intstatic intstatic intdoublevalue for stop criterion: abs(f - fplus) invalid input: '<' m_dDeltaFuncValdoublemachine precision.doubleA positive scalar giving the tolerance at which the scaled gradient in considered close enough to zero to terminate the algorithmdoubleMachine precisiondoubleA positive scalar giving the maximum allowable scaled steplength at any iteration. maxstep is used to prevent steps that would cause the optimazation algorithm to overflow or leave the domain of interest, as well as to detect divergence.doubleA positive scalar giving the tolerance at which the scaled distance between two successive iterated is considered close enough to zero to terminate the algorithmdoublepositive scalar estimating the magnitude of f(x) near he minimizer x-star.intmethods for estimating the gradient nummericalybooleanflag indicating if the gradient is to be calc. analyticaly or nummericalybooleanLogical variable which determines whether function parameters and corresponding return values should be stored for later analysis.intholds the stop criteria in use, e.g m_iStopCriteria = etermMaxFuncEval | etermMaxIterationsintNumber of conseccutive past steps whose scaled length was equal to maxstepintmax number of conseccutive past steps whose scaled length was equal to maxstep to terminateintA positive integer specifying the number of reliable digits returned by the objective function FN. fdigits is used to set the parameter n (eta) that is used in the code to specify the relative noise in f(x); the main use of eta is in calculation finite difference step size. eta is set to macheps if fdigits = -1.intcounter to the number of function evaluations.intcounter to the number of gradient evaluations.intcounter to the number of iterations.private intlimit for number of function evaluations.private intA positive integer specifying the maximum number of iterations that may be performed before the algorithm is halted.private CDOptimizeFuncBasepointer to the function to be minimized.private CDVectorspecial parameters used by each optimization method e.g. step size used for calc. nummerical gradient -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoublefunction and gradient evaluation methodsvoidEvalGradient(CDVector x, CDVector gc, double dFuncVal) function and gradient evaluation methodsintExactLineSearch(CDVector xc, double fc, CDVector g, CDVector p, CDVector xplus, double[] fplus, boolean[] maxtaken) Perform exact line search Input: xc: parameter fc: function value at xc g: gradient at xc p: search direction Output: xplus: new parameter fplus: function value for new parameter maxtaken: max taken in line search return termination codeget point to func eval. base.intLineSearch(CDVector xc, double fc, CDVector g, CDVector p, CDVector xplus, double[] fplus, boolean[] maxtaken) Warpper for line searchintLineSearch(CDVector xc, double fc, CDVector g, CDVector p, CDVector xplus, double[] fplus, boolean[] maxtaken, boolean fSoft) intget the number of evaluationsintget limit for the number of iterationsget numerical gradient functionabstract intMinimize(CDVector x, CDOptimizeFuncBase pFuncEvalBase) the Minimize function using analytic gradientintMinimizeNum(CDVector x, CDOptimizeFuncBase pFuncEvalBase, CDVector vMethodPar) Name()name of optimization methodevoidcalculate nummerical gradient function usingdecided gradient calculation method input: x: parameter dFuncVal: function value in x output: gradient: gradientintname of optimization methodvoidSetFuncEvalBase(CDOptimizeFuncBase pFuncEval) set point to func eval. base.void----------------------------[ MachineEps ]---------------------------- Calculate machine epsilon Algorithm A1.3.1 - p. 303 Dennis and Schnabel, Numerical Methods for Unconstrained Optimization and Nonlinear Equations 1983, Prentice-HallvoidSetMaxFuncEval(int nMaxFuncEval) set limit for the number of function evaluationsvoidSetMaxIterations(int nMaxIterations) set limit for the number of iterationsvoidSetMethodPar(CDVector vMethodPar) set numerical gradient functionintSoftLineSearch(CDVector xc, double fc, CDVector g, CDVector sn, CDVector xplus, double[] fplus, boolean[] maxtaken) Perform line search Given g'p invalid input: '<' 0 and alpha invalid input: '<' 1/2 (alpha = 1e-4 is used), find plus = xc + lambda p,lambda in [0;1], such that f(xplus) invalid input: '<'= f(xc) + alpha * lambda * g'p, using backtracking line search Algorithm A6.3.1 p. 325 Dennis and Schnabel, Numerical Methods for Unconstrained Optimization and Nonlinear Equations 1983, Prentice-Hall Input: xc: parameter fc: function value at xc g: gradient at xc sn: search direction Output: xplus: new parameter fplus: function value for new parameter maxtaken: max taken in line search return termination codeintUmStop(CDVector x, CDVector xplus, double f, double fplus, CDVector g, int retcode, boolean maxtaken) Decide wether to terminate minimization Modified version of Algorithm A7.2.1 p. 347 Dennis and Schnabel, Numerical Methods for Unconstrained Optimization and Nonlinear Equations 1983, Prentice-Hall Input: x: parameter xplus: new parameter fplus: function value for new parameter g: gradient at x retcode: return code from line search maxtaken: max taken in line search Output: return termination codeint
-
Field Details
-
ENumGrad
public int ENumGrad -
ForwardDifference
public static int ForwardDifference -
CentralDifference
public static int CentralDifference -
FitLine
public static int FitLine -
EOptMethod
public int EOptMethod -
eoptUnknown
public static int eoptUnknown -
eoptSteepestDescent
public static int eoptSteepestDescent -
eoptConjugateGradient
public static int eoptConjugateGradient -
eoptBFGS
public static int eoptBFGS -
eoptSimulatedAnnealing
public static int eoptSimulatedAnnealing -
eoptPatternSearch
public static int eoptPatternSearch -
ETermCode
public int ETermCode -
etermNoStop
public static int etermNoStop -
etermGradTol
public static int etermGradTol -
etermStepTol
public static int etermStepTol -
etermLineSearch
public static int etermLineSearch -
etermConsecMaxStepMax
public static int etermConsecMaxStepMax -
etermDeltaFuncVal
public static int etermDeltaFuncVal -
etermMaxFuncEval
public static int etermMaxFuncEval -
etermMaxIterations
public static int etermMaxIterations -
etermUnknown
public static int etermUnknown -
m_dMachEps
public double m_dMachEpsMachine precision -
m_dTypF
public double m_dTypFpositive scalar estimating the magnitude of f(x) near he minimizer x-star. It is only used in the gradient stopping condition given below. typf should be approximately |f(x*)| -
m_nFDigits
public int m_nFDigitsA positive integer specifying the number of reliable digits returned by the objective function FN. fdigits is used to set the parameter n (eta) that is used in the code to specify the relative noise in f(x); the main use of eta is in calculation finite difference step size. eta is set to macheps if fdigits = -1. If f(x) is suspected to be noisy but the approximate value of fdigits is unknown, it should be estimated be the routine of Hamming[1973] given in Gill, Murray and Wright[1981] -
m_dMaxStep
public double m_dMaxStepA positive scalar giving the maximum allowable scaled steplength at any iteration. maxstep is used to prevent steps that would cause the optimazation algorithm to overflow or leave the domain of interest, as well as to detect divergence. It should be chosen small enough to prevent the first two of these occurrences but larger than any anticipated reasonable stepsize. The algorithm will halt if it takes steps of length maxstep on m_nConsecMaxStepMax conseccutive iterations -
m_nConsecMax
public int m_nConsecMaxNumber of conseccutive past steps whose scaled length was equal to maxstep -
m_dEta
public double m_dEtamachine precision. -
m_fAnalyticGrad
public boolean m_fAnalyticGradflag indicating if the gradient is to be calc. analyticaly or nummericaly -
m_eNumGrad
public int m_eNumGradmethods for estimating the gradient nummericaly -
m_iStopCriteria
public int m_iStopCriteriaholds the stop criteria in use, e.g m_iStopCriteria = etermMaxFuncEval | etermMaxIterations -
m_dGradTol
public double m_dGradTolA positive scalar giving the tolerance at which the scaled gradient in considered close enough to zero to terminate the algorithm -
m_dStepTol
public double m_dStepTolA positive scalar giving the tolerance at which the scaled distance between two successive iterated is considered close enough to zero to terminate the algorithm -
m_nConsecMaxStepMax
public int m_nConsecMaxStepMaxmax number of conseccutive past steps whose scaled length was equal to maxstep to terminate -
m_dDeltaFuncVal
public double m_dDeltaFuncValvalue for stop criterion: abs(f - fplus) invalid input: '<' m_dDeltaFuncVal -
m_nIterations
public int m_nIterationscounter to the number of iterations. -
m_nFuncEval
public int m_nFuncEvalcounter to the number of function evaluations. -
m_nGradEval
public int m_nGradEvalcounter to the number of gradient evaluations. -
m_fLogFuncValues
public boolean m_fLogFuncValuesLogical variable which determines whether function parameters and corresponding return values should be stored for later analysis. -
m_vFuncVal
-
m_vNFuncEval
-
m_vvFuncParm
-
m_pFuncEvalBase
pointer to the function to be minimized. -
m_vMethodPar
special parameters used by each optimization method e.g. step size used for calc. nummerical gradient -
m_nMaxIterations
private int m_nMaxIterationsA positive integer specifying the maximum number of iterations that may be performed before the algorithm is halted. Appropriate values depend strongly on the dimension and difficulty of the problem, and the cost of evaluating the nonlinear function. -
m_nMaxFuncEval
private int m_nMaxFuncEvallimit for number of function evaluations.
-
-
Constructor Details
-
CDOptimizeBase
public CDOptimizeBase()Constructor
-
-
Method Details
-
Minimize
the Minimize function using analytic gradient- Parameters:
x-pFuncEvalBase-- Returns:
-
Name
name of optimization methode- Returns:
-
OptMethod
public int OptMethod()name of optimization method -
EvalFunction
function and gradient evaluation methods- Parameters:
x-- Returns:
-
EvalGradient
function and gradient evaluation methods- Parameters:
x-gc-dFuncVal-
-
MethodPar
get numerical gradient function- Returns:
-
SetMethodPar
set numerical gradient function- Parameters:
vMethodPar-
-
MaxIterations
public int MaxIterations()get limit for the number of iterations- Returns:
-
MaxFuncEval
public int MaxFuncEval()get the number of evaluations- Returns:
-
SetFuncEvalBase
set point to func eval. base.- Parameters:
pFuncEval-
-
GetFuncEvalBase
get point to func eval. base.- Returns:
-
SetMaxIterations
public void SetMaxIterations(int nMaxIterations) set limit for the number of iterations- Parameters:
nMaxIterations- max iterations
-
SetMaxFuncEval
public void SetMaxFuncEval(int nMaxFuncEval) set limit for the number of function evaluations- Parameters:
nMaxFuncEval- max number of evaluations.
-
SetMachineEps
public void SetMachineEps()----------------------------[ MachineEps ]---------------------------- Calculate machine epsilon Algorithm A1.3.1 - p. 303 Dennis and Schnabel, Numerical Methods for Unconstrained Optimization and Nonlinear Equations 1983, Prentice-Hall -
UmStop0
-
UmStop
public int UmStop(CDVector x, CDVector xplus, double f, double fplus, CDVector g, int retcode, boolean maxtaken) Decide wether to terminate minimization Modified version of Algorithm A7.2.1 p. 347 Dennis and Schnabel, Numerical Methods for Unconstrained Optimization and Nonlinear Equations 1983, Prentice-Hall Input: x: parameter xplus: new parameter fplus: function value for new parameter g: gradient at x retcode: return code from line search maxtaken: max taken in line search Output: return termination code -
LineSearch
public int LineSearch(CDVector xc, double fc, CDVector g, CDVector p, CDVector xplus, double[] fplus, boolean[] maxtaken) Warpper for line search- Parameters:
xc- parameterfc- function value at xcg- gradient at xcp- search directionxplus- new parameterfplus- function value for new parametermaxtaken- max taken in line search- Returns:
- termination code
-
LineSearch
-
ExactLineSearch
public int ExactLineSearch(CDVector xc, double fc, CDVector g, CDVector p, CDVector xplus, double[] fplus, boolean[] maxtaken) Perform exact line search Input: xc: parameter fc: function value at xc g: gradient at xc p: search direction Output: xplus: new parameter fplus: function value for new parameter maxtaken: max taken in line search return termination code -
SoftLineSearch
public int SoftLineSearch(CDVector xc, double fc, CDVector g, CDVector sn, CDVector xplus, double[] fplus, boolean[] maxtaken) Perform line search Given g'p invalid input: '<' 0 and alpha invalid input: '<' 1/2 (alpha = 1e-4 is used), find plus = xc + lambda p,lambda in [0;1], such that f(xplus) invalid input: '<'= f(xc) + alpha * lambda * g'p, using backtracking line search Algorithm A6.3.1 p. 325 Dennis and Schnabel, Numerical Methods for Unconstrained Optimization and Nonlinear Equations 1983, Prentice-Hall Input: xc: parameter fc: function value at xc g: gradient at xc sn: search direction Output: xplus: new parameter fplus: function value for new parameter maxtaken: max taken in line search return termination code -
NumGrad
calculate nummerical gradient function usingdecided gradient calculation method input: x: parameter dFuncVal: function value in x output: gradient: gradient -
MinimizeNum
-