simple_optimization_problem.cpp
Go to the documentation of this file.
1 /*********************************************************************
2  *
3  * Software License Agreement
4  *
5  * Copyright (c) 2020,
6  * TU Dortmund - Institute of Control Theory and Systems Engineering.
7  * All rights reserved.
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <https://www.gnu.org/licenses/>.
21  *
22  * Authors: Christoph Rösmann
23  *********************************************************************/
24 
26 
27 namespace corbo {
28 
30 {
31  _x.setZero(parameter_dim);
32  _lb.setConstant(parameter_dim, -CORBO_INF_DBL);
33  _ub.setConstant(parameter_dim, CORBO_INF_DBL);
34  _x_backup.clear();
35 }
36 
38 {
39  assert(!_x_backup.empty());
40  _x = _x_backup.back();
41  if (!keep_backup) _x_backup.pop_back();
42 }
43 
45 {
46  lb = _lb;
47  ub = _ub;
48 }
49 
51 {
52  _lb = lb;
53  _ub = ub;
54 }
55 
56 void SimpleOptimizationProblemWithCallbacks::setObjectiveFunction(std::function<void(const Eigen::VectorXd&, Eigen::Ref<Eigen::VectorXd>)> obj_fun,
57  int obj_dim, bool lsq_form)
58 {
59  _obj_fun = obj_fun;
60  _obj_dim = obj_dim;
61  _lsq_form = lsq_form;
62 }
63 
64 void SimpleOptimizationProblemWithCallbacks::setEqualityConstraint(std::function<void(const Eigen::VectorXd&, Eigen::Ref<Eigen::VectorXd>)> eq_fun,
65  int eq_dim)
66 {
67  _eq_fun = eq_fun;
68  _eq_dim = eq_dim;
69 }
70 
72  std::function<void(const Eigen::VectorXd&, Eigen::Ref<Eigen::VectorXd>)> ineq_fun, int ineq_dim)
73 {
74  _ineq_fun = ineq_fun;
75  _ineq_dim = ineq_dim;
76 }
77 
78 } // namespace corbo
void setInequalityConstraint(std::function< void(const Eigen::VectorXd &, Eigen::Ref< Eigen::VectorXd >)> ineq_fun, int ineq_dim)
Set inequality constraint callback.
std::vector< Eigen::VectorXd > _x_backup
void setBounds(const Eigen::Ref< const Eigen::VectorXd > &lb, const Eigen::Ref< const Eigen::VectorXd > &ub) override
Set lower and upper bound vector.
void setObjectiveFunction(std::function< void(const Eigen::VectorXd &, Eigen::Ref< Eigen::VectorXd >)> obj_fun, int obj_dim, bool lsq_form=false)
Set objective function callback.
void resizeParameterVector(int parameter_dim)
Resize the dimension of the parameter vector.
constexpr const double CORBO_INF_DBL
Representation for infinity (double version)
void getBounds(Eigen::Ref< Eigen::VectorXd > lb, Eigen::Ref< Eigen::VectorXd > ub) override
Get lower and upper bound vector.
A matrix or vector expression mapping an existing expression.
Definition: Ref.h:192
void setEqualityConstraint(std::function< void(const Eigen::VectorXd &, Eigen::Ref< Eigen::VectorXd >)> eq_fun, int eq_dim)
Set equality constraint callback.
void restoreBackupParameters(bool keep_backup) override
Discard last backup (or all)


control_box_rst
Author(s): Christoph Rösmann
autogenerated on Mon Feb 28 2022 22:07:18