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
corbo::SimpleOptimizationProblem::_lb
Eigen::VectorXd _lb
Definition: simple_optimization_problem.h:225
corbo::SimpleOptimizationProblem::_ub
Eigen::VectorXd _ub
Definition: simple_optimization_problem.h:226
corbo
Definition: communication/include/corbo-communication/utilities.h:37
corbo::SimpleOptimizationProblemWithCallbacks::setObjectiveFunction
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.
Definition: simple_optimization_problem.cpp:78
simple_optimization_problem.h
corbo::SimpleOptimizationProblem::getBounds
void getBounds(Eigen::Ref< Eigen::VectorXd > lb, Eigen::Ref< Eigen::VectorXd > ub) override
Get lower and upper bound vector.
Definition: simple_optimization_problem.cpp:66
corbo::SimpleOptimizationProblemWithCallbacks::_eq_fun
std::function< void(const Eigen::VectorXd &, Eigen::Ref< Eigen::VectorXd >)> _eq_fun
Definition: simple_optimization_problem.h:338
corbo::CORBO_INF_DBL
constexpr const double CORBO_INF_DBL
Representation for infinity (double version)
Definition: core/include/corbo-core/types.h:75
corbo::SimpleOptimizationProblem::restoreBackupParameters
void restoreBackupParameters(bool keep_backup) override
Discard last backup (or all)
Definition: simple_optimization_problem.cpp:59
corbo::SimpleOptimizationProblem::_x
Eigen::VectorXd _x
Definition: simple_optimization_problem.h:224
corbo::SimpleOptimizationProblemWithCallbacks::_eq_dim
int _eq_dim
Definition: simple_optimization_problem.h:333
corbo::SimpleOptimizationProblemWithCallbacks::_ineq_dim
int _ineq_dim
Definition: simple_optimization_problem.h:334
corbo::SimpleOptimizationProblem::_x_backup
std::vector< Eigen::VectorXd > _x_backup
Definition: simple_optimization_problem.h:228
corbo::SimpleOptimizationProblem::setBounds
void setBounds(const Eigen::Ref< const Eigen::VectorXd > &lb, const Eigen::Ref< const Eigen::VectorXd > &ub) override
Set lower and upper bound vector.
Definition: simple_optimization_problem.cpp:72
Eigen::Ref
A matrix or vector expression mapping an existing expression.
Definition: Ref.h:192
corbo::SimpleOptimizationProblemWithCallbacks::_obj_fun
std::function< void(const Eigen::VectorXd &, Eigen::Ref< Eigen::VectorXd >)> _obj_fun
Definition: simple_optimization_problem.h:337
corbo::SimpleOptimizationProblem::resizeParameterVector
void resizeParameterVector(int parameter_dim)
Resize the dimension of the parameter vector.
Definition: simple_optimization_problem.cpp:51
corbo::SimpleOptimizationProblemWithCallbacks::setEqualityConstraint
void setEqualityConstraint(std::function< void(const Eigen::VectorXd &, Eigen::Ref< Eigen::VectorXd >)> eq_fun, int eq_dim)
Set equality constraint callback.
Definition: simple_optimization_problem.cpp:86
corbo::SimpleOptimizationProblemWithCallbacks::_obj_dim
int _obj_dim
Definition: simple_optimization_problem.h:332
corbo::SimpleOptimizationProblemWithCallbacks::_lsq_form
bool _lsq_form
Definition: simple_optimization_problem.h:335
corbo::SimpleOptimizationProblemWithCallbacks::setInequalityConstraint
void setInequalityConstraint(std::function< void(const Eigen::VectorXd &, Eigen::Ref< Eigen::VectorXd >)> ineq_fun, int ineq_dim)
Set inequality constraint callback.
Definition: simple_optimization_problem.cpp:93
corbo::SimpleOptimizationProblemWithCallbacks::_ineq_fun
std::function< void(const Eigen::VectorXd &, Eigen::Ref< Eigen::VectorXd >)> _ineq_fun
Definition: simple_optimization_problem.h:339


control_box_rst
Author(s): Christoph Rösmann
autogenerated on Wed Mar 2 2022 00:06:12