25 #ifndef SRC_OPTIMIZATION_INCLUDE_CORBO_OPTIMIZATION_SIMPLE_OPTIMIZATION_PROBLEM_H_ 26 #define SRC_OPTIMIZATION_INCLUDE_CORBO_OPTIMIZATION_SIMPLE_OPTIMIZATION_PROBLEM_H_ 109 const Eigen::VectorXd&
getX()
const {
return _x; }
232 void setObjectiveFunction(std::function<
void(
const Eigen::VectorXd&,
Eigen::Ref<Eigen::VectorXd>)> obj_fun,
int obj_dim,
bool lsq_form =
false);
285 if (!_obj_fun || _lsq_form)
return 0;
287 _obj_fun(
getX(), values);
294 if (_obj_fun) _obj_fun(
getX(), values);
300 if (_eq_fun) _eq_fun(
getX(), values);
306 if (_ineq_fun) _ineq_fun(
getX(), values);
313 bool _lsq_form =
false;
315 std::function<void(const Eigen::VectorXd&, Eigen::Ref<Eigen::VectorXd>)> _obj_fun;
316 std::function<void(const Eigen::VectorXd&, Eigen::Ref<Eigen::VectorXd>)> _eq_fun;
317 std::function<void(const Eigen::VectorXd&, Eigen::Ref<Eigen::VectorXd>)> _ineq_fun;
322 #endif // SRC_OPTIMIZATION_INCLUDE_CORBO_OPTIMIZATION_SIMPLE_OPTIMIZATION_PROBLEM_H_ Simple optimization problem formulation.
void setX(const Eigen::Ref< const Eigen::VectorXd > &x)
void getParameterVector(Eigen::Ref< Eigen::VectorXd > x) override
Same as getX() but less efficient (overrides interface method, but here x must not be pre-allocated) ...
void setParameterVector(const Eigen::Ref< const Eigen::VectorXd > &x) override
Same as setX() (overrides interface method)
int getEqualityDimension() override
Total dimension of equality constraints.
void computeValuesLsqObjective(Eigen::Ref< Eigen::VectorXd > values) override=0
Compute the objective function values f(x) for the current parameter set.
int getLsqObjectiveDimension() override=0
Total dimension of least-squares objective function terms.
void setParameterValue(int idx, double x) override
Set specific value of the parameter vector.
std::vector< Eigen::VectorXd > _x_backup
void computeValuesEquality(Eigen::Ref< Eigen::VectorXd > values) override=0
Compute the equality constraint values ceq(x) for the current parameter set.
bool _warn_if_not_specialized
double getUpperBound(int idx) override
Return specific upper bound of a parameter.
Eigen::VectorXd & getLowerBoundsRef()
int getNonLsqObjectiveDimension() override
Total dimension of objective function terms.
bool isLeastSquaresProblem() const override
Check if the underlying problem is defined in the least squares form.
void setBounds(const Eigen::Ref< const Eigen::VectorXd > &lb, const Eigen::Ref< const Eigen::VectorXd > &ub) override
Set lower and upper bound vector.
int getNonLsqObjectiveDimension() override=0
Total dimension of objective function terms.
void applyIncrement(const Eigen::Ref< const Eigen::VectorXd > &increment) override
Apply increment to the current parameter set.
Simple optimization problem formulation (callback based configuration)
void discardBackupParameters(bool all=false) override
void computeValuesLsqObjective(Eigen::Ref< Eigen::VectorXd > values) override
Compute the objective function values f(x) for the current parameter set.
void resizeParameterVector(int parameter_dim)
Resize the dimension of the parameter vector.
void backupParameters() override
Restore parameter set from the last backup and keep backup if desired.
int getObjectiveDimension() override
Get dimension of the objective (should be zero or one, includes Lsq objectives if present) ...
SimpleOptimizationProblem()
int getInequalityDimension() override
Total dimension of general inequality constraints.
int getLsqObjectiveDimension() override
Total dimension of least-squares objective function terms.
void computeValuesInequality(Eigen::Ref< Eigen::VectorXd > values) override=0
Compute the inequality constraint values c(x) for the current parameter set.
double getParameterValue(int idx) override
Return specific value of the parameter vector.
Generic interface for optimization problem definitions.
double computeValueNonLsqObjective() override
int getEqualityDimension() override=0
Total dimension of equality constraints.
int getInequalityDimension() override=0
Total dimension of general inequality constraints.
void getBounds(Eigen::Ref< Eigen::VectorXd > lb, Eigen::Ref< Eigen::VectorXd > ub) override
Get lower and upper bound vector.
const Eigen::VectorXd & getLowerBounds() const
A matrix or vector expression mapping an existing expression.
void computeValuesEquality(Eigen::Ref< Eigen::VectorXd > values) override
Compute the equality constraint values ceq(x) for the current parameter set.
bool isLeastSquaresProblem() const override=0
Check if the underlying problem is defined in the least squares form.
void setLowerBound(int idx, double lb) override
Set specific lower bound of a parameter.
SimpleOptimizationProblem(int parameter_dim)
int getObjectiveDimension() override=0
Get dimension of the objective (should be zero or one, includes Lsq objectives if present) ...
const Eigen::VectorXd & getUpperBounds() const
double computeValueNonLsqObjective() override=0
Eigen::VectorXd & getXRef()
void setUpperBounds(const Eigen::Ref< const Eigen::VectorXd > &ub)
SimpleOptimizationProblemWithCallbacks(int param_dim)
Construct Optimization Problem with a given parameter vector dimension.
SimpleOptimizationProblemWithCallbacks()
Default constructor (do not forget to initialize the parameter vector dimension manually) ...
void restoreBackupParameters(bool keep_backup) override
Discard last backup (or all)
double getLowerBound(int idx) override
Return specific lower bound value of a parameter.
void setLowerBounds(const Eigen::Ref< const Eigen::VectorXd > &lb)
const Eigen::VectorXd & getX() const
Eigen::VectorXd & getUpperBoundsRef()
void setUpperBound(int idx, double ub) override
Set specific upper bound of a parameter.
void computeValuesInequality(Eigen::Ref< Eigen::VectorXd > values) override
Compute the inequality constraint values c(x) for the current parameter set.
int getParameterDimension() override
Effictive dimension of the optimization parameter set (changeable, non-fixed part) ...
void applyIncrement(int idx, double increment) override
Apply increment to the current parameter set (single element overload)