1 #ifndef SimTK_SIMMATH_OPTIMIZER_REP_H_
2 #define SimTK_SIMMATH_OPTIMIZER_REP_H_
73 convergenceTolerance(Real(1e-3)),
74 constraintTolerance(Real(1e-4)),
76 limitedMemoryHistory(50),
81 numericalGradient(false),
82 numericalJacobian(false)
93 convergenceTolerance(Real(1e-3)),
94 constraintTolerance(Real(1e-4)),
96 limitedMemoryHistory(50),
101 numericalGradient(false),
102 numericalJacobian(false)
109 virtual Real optimize(
Vector &results ) = 0;
114 void setDiagnosticsLevel(
const int level );
115 void setConvergenceTolerance( Real accuracy );
116 void setConstraintTolerance( Real tolerance );
117 void setMaxIterations(
const int iter );
118 void setLimitedMemoryHistory(
const int history );
120 bool setAdvancedStrOption(
const std::string &option,
const std::string &value );
121 bool setAdvancedRealOption(
const std::string &option,
const Real value );
122 bool setAdvancedIntOption(
const std::string &option,
const int value );
123 bool setAdvancedBoolOption(
const std::string &option,
const bool value );
125 bool getAdvancedStrOption(
const std::string &option, std::string &value )
const;
126 bool getAdvancedRealOption(
const std::string &option, Real &value )
const;
127 bool getAdvancedIntOption(
const std::string &option,
int &value )
const;
128 bool getAdvancedBoolOption(
const std::string &option,
bool &value )
const;
134 void useNumericalGradient(
bool flag, Real objEstAccuracy);
135 void useNumericalJacobian(
bool flag, Real consEstAccuracy);
142 {
return objectiveEstimatedAccuracy; }
144 {
return constraintsEstimatedAccuracy; }
156 static int numericalGradient_static(
const OptimizerSystem&,
const Vector & parameters,
const bool new_parameters,
Vector &gradient );
158 const Vector& parameters,
const bool new_parameters,
Matrix& jacobian );
166 static int objectiveFuncWrapper (
int n,
const Real* x,
int new_x, Real* f,
void* rep);
167 static int gradientFuncWrapper (
int n,
const Real* x,
int new_x, Real* gradient,
void* rep);
168 static int constraintFuncWrapper(
int n,
const Real* x,
int new_x,
int m, Real* g,
void* rep);
169 static int constraintJacobianWrapper(
int n,
const Real* x,
int new_x,
int m,
int nele_jac,
170 int* iRow,
int* jCol, Real* values,
void* rep);
171 static int hessianWrapper(
int n,
const Real* x,
int new_x, Real obj_factor,
172 int m, Real* lambda,
int new_lambda,
173 int nele_hess,
int* iRow,
int* jCol,
174 Real* values,
void* rep);
187 bool numericalGradient;
188 bool numericalJacobian;
195 std::map<std::string, std::string> advancedStrOptions;
196 std::map<std::string, Real> advancedRealOptions;
197 std::map<std::string, int> advancedIntOptions;
198 std::map<std::string, bool> advancedBoolOptions;
206 Real optimize(
Vector &results );
213 #endif // SimTK_SIMMATH_OPTIMIZER_REP_H_
Given a function f(y), where f, y or both can be vectors, calculate the derivative (gradient...
Definition: Differentiator.h:77
Real getEstimatedAccuracyOfConstraints() const
Definition: OptimizerRep.h:143
Definition: OptimizerRep.h:36
JacobianFunction(int nf=-1, int ny=-1, Real acc=-1)
virtual int objectiveFunc(const Vector ¶meters, bool new_parameters, Real &f) const
Objective/cost function which is to be optimized; return 0 when successful.
Definition: Optimizer.h:73
void clearMyHandle()
Definition: OptimizerRep.h:132
GradientFunction(int ny=-1, Real acc=-1)
Real constraintsEstimatedAccuracy
Definition: OptimizerRep.h:183
Real constraintTolerance
Definition: OptimizerRep.h:178
API for SimTK Simmath's optimizers.
Definition: Optimizer.h:241
int f(const Vector &y, Vector &fy) const
Definition: OptimizerRep.h:56
const Optimizer & getMyHandle() const
Definition: OptimizerRep.h:131
const OptimizerSystem * sysp
Definition: OptimizerRep.h:45
Definition: OptimizerRep.h:63
Real convergenceTolerance
Definition: OptimizerRep.h:177
void setMyHandle(Optimizer &cp)
Definition: OptimizerRep.h:130
const Differentiator & getJacobianDifferentiator() const
Definition: OptimizerRep.h:151
Real getEstimatedAccuracyOfObjective() const
Definition: OptimizerRep.h:141
SysObjectiveFunc(int ny, const OptimizerSystem *sysPtr)
Definition: OptimizerRep.h:38
static bool isAvailable()
Definition: OptimizerRep.h:107
int maxIterations
Definition: OptimizerRep.h:179
Includes internal headers providing declarations for the basic SimTK Core classes, including Simmatrix.
int diagnosticsLevel
Definition: OptimizerRep.h:176
virtual OptimizerRep * clone() const
Definition: OptimizerRep.h:106
Real objectiveEstimatedAccuracy
Definition: OptimizerRep.h:182
OptimizerRep(const OptimizerSystem &sys)
Definition: OptimizerRep.h:66
int f(const Vector &y, Real &fy) const
Definition: OptimizerRep.h:42
Method
Definition: Differentiator.h:92
Definition: OptimizerRep.h:50
bool isUsingNumericalGradient() const
Definition: OptimizerRep.h:138
This is the Matrix class intended to appear in user code.
Definition: BigMatrix.h:181
const OptimizerSystem * sysp
Definition: OptimizerRep.h:59
SysConstraintFunc(int nf, int ny, const OptimizerSystem *sysPtr)
Definition: OptimizerRep.h:52
int limitedMemoryHistory
Definition: OptimizerRep.h:180
OptimizerRep()
Definition: OptimizerRep.h:86
virtual int constraintFunc(const Vector ¶meters, bool new_parameters, Vector &constraints) const
Computes the value of the constraints; return 0 when successful.
Definition: Optimizer.h:86
This is the header file that user code should include to pick up the SimTK Simmath numerical differen...
const Real SignificantReal
SignificantReal is the smallest value that we consider to be clearly distinct from roundoff error whe...
const Differentiator & getGradientDifferentiator() const
Definition: OptimizerRep.h:146
Abstract class which defines an objective/cost function which is optimized by and Optimizer object...
Definition: Optimizer.h:47
bool isUsingNumericalJacobian() const
Definition: OptimizerRep.h:139
const OptimizerSystem & getOptimizerSystem() const
Definition: OptimizerRep.h:111
Differentiator::Method getDifferentiatorMethod() const
Definition: OptimizerRep.h:140
Derive a concrete class from this one if you have a scalar function of multiple variables that you wa...
Definition: Differentiator.h:208
#define SimTK_SIMMATH_EXPORT
Definition: SimTKmath/include/simmath/internal/common.h:64
Derive a concrete class from this one if you have a set of functions (i.e., a vector-valued function)...
Definition: Differentiator.h:227
Definition: OptimizerRep.h:205
Differentiator::Method diffMethod
Definition: OptimizerRep.h:181