robotic 0.3.4__cp312-cp312-manylinux2014_x86_64.whl → 0.3.4.dev2__cp312-cp312-manylinux2014_x86_64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- robotic/_robotic.pyi +32 -14
- robotic/_robotic.so +0 -0
- robotic/include/rai/Algo/RidgeRegression.h +1 -1
- robotic/include/rai/Algo/rungeKutta.h +1 -1
- robotic/include/rai/Core/array.h +30 -22
- robotic/include/rai/Core/array.ipp +53 -60
- robotic/include/rai/Core/arrayDouble.h +29 -25
- robotic/include/rai/DataGen/shapenetGrasps.h +1 -1
- robotic/include/rai/Geo/mesh.h +2 -4
- robotic/include/rai/Geo/pairCollision.h +40 -36
- robotic/include/rai/Geo/signedDistanceFunctions.h +6 -4
- robotic/include/rai/KOMO/komo.h +1 -1
- robotic/include/rai/Kin/dof_forceExchange.h +3 -3
- robotic/include/rai/Kin/feature.h +1 -1
- robotic/include/rai/Kin/frame.h +9 -12
- robotic/include/rai/Kin/proxy.h +1 -1
- robotic/include/rai/Optim/BayesOpt.h +14 -7
- robotic/include/rai/Optim/CMA/boundary_transformation.h +73 -0
- robotic/include/rai/Optim/CMA/cmaes.h +175 -0
- robotic/include/rai/Optim/CMA/cmaes_interface.h +68 -0
- robotic/include/rai/Optim/GlobalIterativeNewton.h +7 -3
- robotic/include/rai/Optim/NLP.h +15 -1
- robotic/include/rai/Optim/NLP_Solver.h +5 -5
- robotic/include/rai/Optim/constrained.h +3 -3
- robotic/include/rai/Optim/lagrangian.h +6 -5
- robotic/include/rai/Optim/m_EvoStrategies.h +94 -0
- robotic/include/rai/Optim/{gradient.h → m_Gradient.h} +12 -13
- robotic/include/rai/Optim/m_LBFGS.h +21 -0
- robotic/include/rai/Optim/m_LeastSquaresZeroOrder.h +18 -11
- robotic/include/rai/Optim/m_LocalGreedy.h +31 -0
- robotic/include/rai/Optim/m_NelderMead.h +17 -0
- robotic/include/rai/Optim/{newton.h → m_Newton.h} +8 -5
- robotic/include/rai/Optim/options.h +6 -7
- robotic/include/rai/Optim/primalDual.h +9 -5
- robotic/include/rai/Optim/testProblems_Opt.h +5 -5
- robotic/include/rai/Optim/utils.h +9 -20
- robotic/librai.so +0 -0
- robotic/meshTool +0 -0
- robotic/version.py +1 -1
- {robotic-0.3.4.dist-info → robotic-0.3.4.dev2.dist-info}/METADATA +1 -1
- {robotic-0.3.4.dist-info → robotic-0.3.4.dev2.dist-info}/RECORD +62 -56
- robotic/include/rai/Optim/lbfgs.h +0 -18
- /robotic/include/rai/Geo/{assimpInterface.h → i_assimp.h} +0 -0
- /robotic/include/rai/Geo/{fclInterface.h → i_fcl.h} +0 -0
- /robotic/include/rai/Kin/{kin_bullet.h → i_Bullet.h} +0 -0
- /robotic/include/rai/Kin/{kin_feather.h → i_Feather.h} +0 -0
- /robotic/include/rai/Kin/{kin_ode.h → i_Ode.h} +0 -0
- /robotic/include/rai/Kin/{kin_physx.h → i_Physx.h} +0 -0
- /robotic/include/rai/Optim/{opt-ceres.h → i_Ceres.h} +0 -0
- /robotic/include/rai/Optim/{opt-ipopt.h → i_Ipopt.h} +0 -0
- /robotic/include/rai/Optim/{opt-nlopt.h → i_NLopt.h} +0 -0
- /robotic/include/rai/Optim/{liblbfgs.h → liblbfgs/liblbfgs.h} +0 -0
- /robotic/include/rai/Optim/{SlackGaussNewton.h → m_SlackGaussNewton.h} +0 -0
- {robotic-0.3.4.data → robotic-0.3.4.dev2.data}/scripts/ry-bot +0 -0
- {robotic-0.3.4.data → robotic-0.3.4.dev2.data}/scripts/ry-h5info +0 -0
- {robotic-0.3.4.data → robotic-0.3.4.dev2.data}/scripts/ry-info +0 -0
- {robotic-0.3.4.data → robotic-0.3.4.dev2.data}/scripts/ry-meshTool +0 -0
- {robotic-0.3.4.data → robotic-0.3.4.dev2.data}/scripts/ry-test +0 -0
- {robotic-0.3.4.data → robotic-0.3.4.dev2.data}/scripts/ry-urdfConvert.py +0 -0
- {robotic-0.3.4.data → robotic-0.3.4.dev2.data}/scripts/ry-view +0 -0
- {robotic-0.3.4.dist-info → robotic-0.3.4.dev2.dist-info}/WHEEL +0 -0
- {robotic-0.3.4.dist-info → robotic-0.3.4.dev2.dist-info}/licenses/LICENSE +0 -0
- {robotic-0.3.4.dist-info → robotic-0.3.4.dev2.dist-info}/top_level.txt +0 -0
|
@@ -19,17 +19,17 @@ struct ConstrainedSolver;
|
|
|
19
19
|
/** User Interface: Meta class to call several different solvers in a unified manner. */
|
|
20
20
|
struct NLP_Solver : NonCopyable {
|
|
21
21
|
arr x, dual; //owner of decision variables, which are passed by reference to lower level solvers
|
|
22
|
-
|
|
22
|
+
std::shared_ptr<OptOptions> opt; //owner of options, which are passed by reference to lower level solvers
|
|
23
23
|
std::shared_ptr<SolverReturn> ret;
|
|
24
24
|
std::shared_ptr<ConstrainedSolver> optCon;
|
|
25
25
|
std::shared_ptr<NLP_Traced> P;
|
|
26
26
|
|
|
27
27
|
NLP_Solver();
|
|
28
|
-
NLP_Solver(const shared_ptr<NLP>& _P, int verbose=-100) { setProblem(_P); if(verbose>-100) opt
|
|
28
|
+
NLP_Solver(const shared_ptr<NLP>& _P, int verbose=-100) : NLP_Solver() { setProblem(_P); if(verbose>-100) opt->verbose=verbose; }
|
|
29
29
|
|
|
30
|
-
NLP_Solver& setSolver(OptMethod _method) { opt
|
|
30
|
+
NLP_Solver& setSolver(OptMethod _method) { opt->method=_method; return *this; }
|
|
31
31
|
NLP_Solver& setProblem(const shared_ptr<NLP>& _P);
|
|
32
|
-
NLP_Solver& setOptions(const rai::OptOptions& _opt) { opt = _opt; return *this; }
|
|
32
|
+
NLP_Solver& setOptions(const rai::OptOptions& _opt) { *opt = _opt; return *this; }
|
|
33
33
|
NLP_Solver& setInitialization(const arr& _x) { x=_x; return *this; }
|
|
34
34
|
NLP_Solver& setWarmstart(const arr& _x, const arr& _dual) { x=_x; dual=_dual; return *this; }
|
|
35
35
|
NLP_Solver& setTracing(bool trace_x, bool trace_costs, bool trace_phi, bool trace_J) { P->setTracing(trace_x, trace_costs, trace_phi, trace_J); return *this; }
|
|
@@ -48,7 +48,7 @@ struct NLP_Solver : NonCopyable {
|
|
|
48
48
|
arr getTrace_evals();
|
|
49
49
|
rai::Graph reportLagrangeGradients(const StringA& featureNames);
|
|
50
50
|
void gnuplot_costs() {
|
|
51
|
-
FILE("z.opt.trace") <<getTrace_costs();
|
|
51
|
+
FILE("z.opt.trace") <<getTrace_costs().modRaw();
|
|
52
52
|
gnuplot("plot 'z.opt.trace' us 0:1 t 'f', '' us 0:2 t 'sos', '' us 0:3 t 'ineq', '' us 0:4 t 'eq'");
|
|
53
53
|
}
|
|
54
54
|
};
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
#pragma once
|
|
10
10
|
|
|
11
11
|
#include "lagrangian.h"
|
|
12
|
-
#include "
|
|
12
|
+
#include "m_Newton.h"
|
|
13
13
|
|
|
14
14
|
namespace rai {
|
|
15
15
|
|
|
@@ -24,10 +24,10 @@ struct ConstrainedSolver {
|
|
|
24
24
|
LagrangianProblem L;
|
|
25
25
|
OptNewton newton;
|
|
26
26
|
arr& dual;
|
|
27
|
-
|
|
27
|
+
shared_ptr<OptOptions> opt;
|
|
28
28
|
int outer_iters=0, numBadSteps=0;
|
|
29
29
|
|
|
30
|
-
ConstrainedSolver(arr& x, arr& dual, const shared_ptr<NLP>& P,
|
|
30
|
+
ConstrainedSolver(arr& x, arr& dual, const shared_ptr<NLP>& P, shared_ptr<OptOptions> _opt=make_shared<OptOptions>());
|
|
31
31
|
|
|
32
32
|
std::shared_ptr<SolverReturn> run();
|
|
33
33
|
bool ministep();
|
|
@@ -21,8 +21,9 @@ namespace rai {
|
|
|
21
21
|
// that can include lagrange terms, penalties, log barriers, and augmented lagrangian terms
|
|
22
22
|
//
|
|
23
23
|
|
|
24
|
-
struct LagrangianProblem :
|
|
24
|
+
struct LagrangianProblem : NLP {
|
|
25
25
|
shared_ptr<NLP> P;
|
|
26
|
+
shared_ptr<OptOptions> opt;
|
|
26
27
|
|
|
27
28
|
//-- parameters of the inner problem (Lagrangian, unconstrained problem)
|
|
28
29
|
double muLB; ///< log barrier mu
|
|
@@ -34,20 +35,20 @@ struct LagrangianProblem : ScalarFunction, NLP {
|
|
|
34
35
|
arr x; ///< point where P was last evaluated
|
|
35
36
|
arr phi_x, J_x, H_x; ///< features at x
|
|
36
37
|
|
|
37
|
-
LagrangianProblem(const shared_ptr<NLP>& P,
|
|
38
|
+
LagrangianProblem(const shared_ptr<NLP>& P, std::shared_ptr<OptOptions> _opt, double muSquaredPenalty=-1., double muLogBarrier=-1.);
|
|
38
39
|
|
|
39
40
|
virtual void evaluate(arr& phi, arr& J, const arr& x); //evaluate all features and (optionally) their Jacobians for state x
|
|
40
41
|
virtual void getFHessian(arr& H, const arr& x); //the Hessian of the sum of all f-features (or Hessian in addition to the Gauss-Newton Hessian of all other features)
|
|
41
42
|
virtual arr getInitializationSample() { return P->getInitializationSample(); }
|
|
42
43
|
virtual void report(ostream &os, int verbose, const char *msg){ P->report(os, verbose, msg); }
|
|
43
44
|
|
|
44
|
-
double
|
|
45
|
+
virtual double eval_scalar(arr& dL, arr& HL, const arr& x); ///< CORE METHOD: the unconstrained scalar function F
|
|
45
46
|
|
|
46
47
|
rai::Graph reportGradients(const StringA& featureNames);
|
|
47
48
|
void reportMatrix(std::ostream& os);
|
|
48
49
|
|
|
49
|
-
void aulaUpdate(
|
|
50
|
-
void autoUpdate(
|
|
50
|
+
void aulaUpdate(bool anyTimeVariant, double lambdaStepsize=1., double* L_x=nullptr, arr& dL_x=NoArr, arr& HL_x=NoArr);
|
|
51
|
+
void autoUpdate(double* L_x=nullptr, arr& dL_x=NoArr, arr& HL_x=NoArr);
|
|
51
52
|
|
|
52
53
|
//private: used gpenalty function
|
|
53
54
|
double gpenalty(double g);
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include "NLP.h"
|
|
4
|
+
#include "../Core/util.h"
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
|
|
8
|
+
Implement:
|
|
9
|
+
HillClimbing (with fixed exploration; with adaptive exploration)
|
|
10
|
+
DifferentialHillClimbing (with adaptive exploration distribution on delta)
|
|
11
|
+
classical model-based optim
|
|
12
|
+
|
|
13
|
+
Greedy local search (6:5) Stochastic local search (6:6) Simulated annealing (6:7)
|
|
14
|
+
Random restarts (6:10) Iterated local search (6:11) Variable neighborhood search
|
|
15
|
+
(6:13) Coordinate search (6:14) Pattern search (6:15) Nelder-Mead simplex method
|
|
16
|
+
(6:16) General stochastic search (6:20) Evolutionary algorithms (6:23) Covariance Matrix
|
|
17
|
+
Adaptation (CMAES) (6:24) Estimation of Distribution Algorithms (EDAs) (6:28)
|
|
18
|
+
Model-based optimization (6:31) Implicit filtering (6:34)
|
|
19
|
+
|
|
20
|
+
Improvement (5:24) Maximal Probability of Improvement
|
|
21
|
+
(5:24) GP-UCB (5:24)
|
|
22
|
+
|
|
23
|
+
Generic globalization: Iterated Local Optim: check when converged multiply to same local opt
|
|
24
|
+
|
|
25
|
+
Require bound constraints!
|
|
26
|
+
|
|
27
|
+
*
|
|
28
|
+
Twiddle
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
namespace rai {
|
|
32
|
+
|
|
33
|
+
//===========================================================================
|
|
34
|
+
|
|
35
|
+
struct EvolutionStrategy {
|
|
36
|
+
ScalarFunction f;
|
|
37
|
+
arr x;
|
|
38
|
+
double f_x=1e10;
|
|
39
|
+
uint steps=0, rejectedSteps=0, tinySteps=0;
|
|
40
|
+
|
|
41
|
+
EvolutionStrategy(ScalarFunction _f): f(_f) {}
|
|
42
|
+
|
|
43
|
+
virtual arr generateNewSamples() = 0;
|
|
44
|
+
virtual void update(const arr& samples, const arr& values) = 0;
|
|
45
|
+
|
|
46
|
+
bool step();
|
|
47
|
+
|
|
48
|
+
shared_ptr<SolverReturn> solve();
|
|
49
|
+
|
|
50
|
+
arr select(const arr& samples, const arr& y, uint mu);
|
|
51
|
+
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
//===========================================================================
|
|
55
|
+
|
|
56
|
+
struct CMAES : EvolutionStrategy {
|
|
57
|
+
unique_ptr<struct CMA_self> self;
|
|
58
|
+
RAI_PARAM("CMA/", int, lambda, 20)
|
|
59
|
+
RAI_PARAM("CMA/", double, sigmaInit, .1)
|
|
60
|
+
|
|
61
|
+
CMAES(ScalarFunction f, const arr& x_init={});
|
|
62
|
+
~CMAES();
|
|
63
|
+
|
|
64
|
+
virtual arr generateNewSamples();
|
|
65
|
+
virtual void update(const arr& samples, const arr& values);
|
|
66
|
+
|
|
67
|
+
arr getBestEver();
|
|
68
|
+
arr getCurrentMean();
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
//===========================================================================
|
|
72
|
+
|
|
73
|
+
struct ES_mu_plus_lambda : EvolutionStrategy {
|
|
74
|
+
arr mean;
|
|
75
|
+
RAI_PARAM("ES/", double, sigma, .1)
|
|
76
|
+
RAI_PARAM("ES/", uint, lambda, 20)
|
|
77
|
+
RAI_PARAM("ES/", uint, mu, 5)
|
|
78
|
+
|
|
79
|
+
ES_mu_plus_lambda(ScalarFunction f, const arr& x_init={}) : EvolutionStrategy(f) {}
|
|
80
|
+
|
|
81
|
+
virtual arr generateNewSamples(){
|
|
82
|
+
arr X = replicate(mean, lambda);
|
|
83
|
+
// for(uint i=0;i<X.d0;i++) X[i] = X[i] % (0.5 + 1.*rand(X.d1));
|
|
84
|
+
rndGauss(X, sigma, true);
|
|
85
|
+
return X;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
virtual void update(const arr& X, const arr& y){
|
|
89
|
+
arr Y = select(X, y, mu);
|
|
90
|
+
mean = ::mean(Y);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
} //namespace
|
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
#include "options.h"
|
|
12
12
|
#include "../Core/array.h"
|
|
13
13
|
|
|
14
|
+
namespace rai {
|
|
15
|
+
|
|
14
16
|
//===========================================================================
|
|
15
17
|
//
|
|
16
18
|
// proper (monotone) plain gradient descent with line search
|
|
@@ -18,28 +20,24 @@
|
|
|
18
20
|
|
|
19
21
|
struct OptGrad {
|
|
20
22
|
arr& x;
|
|
21
|
-
ScalarFunction
|
|
22
|
-
|
|
23
|
+
ScalarFunction f;
|
|
24
|
+
shared_ptr<OptOptions> opt;
|
|
23
25
|
|
|
24
26
|
enum StopCriterion { stopNone=0, stopCrit1, stopCrit2, stopCritLineSteps, stopCritEvals, stopStepFailed };
|
|
25
|
-
double
|
|
26
|
-
arr
|
|
27
|
+
double f_x;
|
|
28
|
+
arr g_x;
|
|
27
29
|
double alpha;
|
|
28
30
|
uint it, evals, numTinySteps;
|
|
29
31
|
StopCriterion stopCriterion;
|
|
30
32
|
ofstream fil;
|
|
31
33
|
|
|
32
|
-
OptGrad(arr& x, ScalarFunction
|
|
34
|
+
OptGrad(arr& x, ScalarFunction f, std::shared_ptr<OptOptions> _opt);
|
|
33
35
|
~OptGrad();
|
|
34
36
|
StopCriterion step();
|
|
35
37
|
StopCriterion run(uint maxIt = 1000);
|
|
36
38
|
void reinit(const arr& _x=NoArr);
|
|
37
39
|
};
|
|
38
40
|
|
|
39
|
-
inline int optGrad(arr& x, ScalarFunction& f, rai::OptOptions opt=DEFAULT_OPTIONS) {
|
|
40
|
-
return OptGrad(x, f, opt).run();
|
|
41
|
-
}
|
|
42
|
-
|
|
43
41
|
//===========================================================================
|
|
44
42
|
//
|
|
45
43
|
// Rprop
|
|
@@ -53,11 +51,12 @@ struct Rprop {
|
|
|
53
51
|
Rprop();
|
|
54
52
|
~Rprop();
|
|
55
53
|
void init(double initialStepSize=1., double minStepSize=1e-6, double stepMaxSize=50.);
|
|
56
|
-
bool step(arr& x, ScalarFunction
|
|
57
|
-
uint loop(arr& x, ScalarFunction
|
|
54
|
+
bool step(arr& x, ScalarFunction f);
|
|
55
|
+
uint loop(arr& x, ScalarFunction f, double stoppingTolerance=1e-2, double initialStepSize=1., uint maxIterations=1000, int verbose=0);
|
|
58
56
|
};
|
|
59
57
|
|
|
60
|
-
inline uint optRprop(arr& x, ScalarFunction
|
|
61
|
-
return Rprop().loop(x, f, opt
|
|
58
|
+
inline uint optRprop(arr& x, ScalarFunction f, shared_ptr<OptOptions> opt) {
|
|
59
|
+
return Rprop().loop(x, f, opt->stopTolerance, opt->stepInit, opt->stopEvals, opt->verbose);
|
|
62
60
|
}
|
|
63
61
|
|
|
62
|
+
} //namespace
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include "NLP.h"
|
|
4
|
+
#include "options.h"
|
|
5
|
+
|
|
6
|
+
namespace rai {
|
|
7
|
+
|
|
8
|
+
struct LBFGS{
|
|
9
|
+
ScalarFunction f;
|
|
10
|
+
shared_ptr<rai::OptOptions> opt;
|
|
11
|
+
arr x;
|
|
12
|
+
|
|
13
|
+
LBFGS(ScalarFunction _f, const arr& x_init, std::shared_ptr<OptOptions> _opt);
|
|
14
|
+
|
|
15
|
+
std::shared_ptr<SolverReturn> solve();
|
|
16
|
+
|
|
17
|
+
//private:
|
|
18
|
+
arr g;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
} //namespace
|
|
@@ -5,19 +5,22 @@
|
|
|
5
5
|
|
|
6
6
|
struct LeastSquaredZeroOrder{
|
|
7
7
|
shared_ptr<NLP> P;
|
|
8
|
+
bool hasLinTerms=false;
|
|
8
9
|
|
|
9
|
-
//-- parameters
|
|
10
|
-
|
|
11
|
-
double
|
|
12
|
-
|
|
10
|
+
//-- parameters
|
|
11
|
+
str method="rank1";
|
|
12
|
+
double alpha = .5;
|
|
13
|
+
RAI_PARAM("LSZO/", double, alpha_min, .001)
|
|
14
|
+
RAI_PARAM("LSZO/", double, damping, 1e-2)
|
|
13
15
|
|
|
14
|
-
//--
|
|
16
|
+
//-- state and data
|
|
15
17
|
arr x; ///< point where P was last evaluated
|
|
16
|
-
double phi2_x=-1.;
|
|
17
|
-
arr phi_x, J_x, H_x; ///< features at x
|
|
18
18
|
arr J;
|
|
19
|
-
arr
|
|
20
|
-
|
|
19
|
+
arr phi_x; //, J_x, H_x; ///< features at x
|
|
20
|
+
double phi2_x=-1.;
|
|
21
|
+
arr data_X, data_Phi;
|
|
22
|
+
|
|
23
|
+
uint steps=0, tinySteps=0, rejectedSteps=0;
|
|
21
24
|
|
|
22
25
|
LeastSquaredZeroOrder(shared_ptr<NLP> P, const arr& x_init={});
|
|
23
26
|
|
|
@@ -25,7 +28,11 @@ struct LeastSquaredZeroOrder{
|
|
|
25
28
|
while(!step()){}
|
|
26
29
|
shared_ptr<SolverReturn> ret = make_shared<SolverReturn>();
|
|
27
30
|
ret->x = x;
|
|
28
|
-
|
|
31
|
+
arr err = P->summarizeErrors(phi_x);
|
|
32
|
+
ret->f = err(OT_f);
|
|
33
|
+
ret->sos = err(OT_sos);
|
|
34
|
+
ret->eq = err(OT_eq);
|
|
35
|
+
ret->ineq = err(OT_ineq);
|
|
29
36
|
ret->feasible=true;
|
|
30
37
|
return ret;
|
|
31
38
|
}
|
|
@@ -34,5 +41,5 @@ struct LeastSquaredZeroOrder{
|
|
|
34
41
|
|
|
35
42
|
void updateJ_rank1(arr& J, const arr& x, const arr& x_last, const arr& phi, const arr& phi_last);
|
|
36
43
|
|
|
37
|
-
void updateJ_linReg(arr& J, const arr& Xraw, const arr& Y
|
|
44
|
+
void updateJ_linReg(arr& J, const arr& Xraw, const arr& Y);
|
|
38
45
|
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include "NLP.h"
|
|
4
|
+
#include "../Core/util.h"
|
|
5
|
+
|
|
6
|
+
struct LocalGreedy {
|
|
7
|
+
RAI_PARAM("LocalGreedy/", double, sigma, .1)
|
|
8
|
+
|
|
9
|
+
ScalarFunction f;
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
//-- buffers to avoid re-evaluating points
|
|
13
|
+
arr x; ///< point where P was last evaluated
|
|
14
|
+
double f_x=0.;
|
|
15
|
+
|
|
16
|
+
//-- counters
|
|
17
|
+
uint steps=0, tinySteps=0, maxSteps=300;
|
|
18
|
+
|
|
19
|
+
LocalGreedy(ScalarFunction _f, const arr& x_init={});
|
|
20
|
+
|
|
21
|
+
shared_ptr<SolverReturn> solve(){
|
|
22
|
+
while(!step()){}
|
|
23
|
+
shared_ptr<SolverReturn> ret = make_shared<SolverReturn>();
|
|
24
|
+
ret->x = x;
|
|
25
|
+
ret->f = f_x;
|
|
26
|
+
ret->feasible=true;
|
|
27
|
+
return ret;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
bool step();
|
|
31
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include "NLP.h"
|
|
4
|
+
#include "../Core/util.h"
|
|
5
|
+
|
|
6
|
+
struct NelderMead {
|
|
7
|
+
ScalarFunction f;
|
|
8
|
+
arr x;
|
|
9
|
+
double f_x=0.;
|
|
10
|
+
|
|
11
|
+
//-- counters
|
|
12
|
+
uint steps=0, tinySteps=0, maxSteps=300;
|
|
13
|
+
|
|
14
|
+
NelderMead(ScalarFunction _f, const arr& x_init={});
|
|
15
|
+
|
|
16
|
+
shared_ptr<SolverReturn> solve();
|
|
17
|
+
};
|
|
@@ -9,24 +9,25 @@
|
|
|
9
9
|
#pragma once
|
|
10
10
|
|
|
11
11
|
#include "options.h"
|
|
12
|
+
#include "NLP.h"
|
|
12
13
|
#include "../Core/array.h"
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
namespace rai {
|
|
15
16
|
|
|
16
17
|
struct OptNewton {
|
|
17
|
-
ScalarFunction
|
|
18
|
+
ScalarFunction f;
|
|
19
|
+
shared_ptr<rai::OptOptions> opt;
|
|
18
20
|
arr& x;
|
|
19
|
-
rai::OptOptions opt;
|
|
20
21
|
|
|
21
22
|
enum StopCriterion { stopNone=0, stopDeltaConverge, stopTinyFSteps, stopTinyXSteps, stopCritEvals, stopStepFailed, stopLineSearchSteps };
|
|
22
23
|
|
|
23
|
-
OptNewton(arr& _x, ScalarFunction
|
|
24
|
+
OptNewton(arr& _x, ScalarFunction _f, std::shared_ptr<OptOptions> _opt = make_shared<OptOptions>());
|
|
24
25
|
~OptNewton();
|
|
25
26
|
OptNewton& setBounds(const arr& _bounds);
|
|
26
27
|
void reinit(const arr& _x);
|
|
27
28
|
|
|
28
29
|
StopCriterion step();
|
|
29
|
-
|
|
30
|
+
shared_ptr<SolverReturn> run(uint maxIt = 1000);
|
|
30
31
|
|
|
31
32
|
public:
|
|
32
33
|
arr bounds;
|
|
@@ -38,3 +39,5 @@ struct OptNewton {
|
|
|
38
39
|
bool rootFinding=false;
|
|
39
40
|
double timeNewton=0., timeEval=0.;
|
|
40
41
|
};
|
|
42
|
+
|
|
43
|
+
} //namespace
|
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
namespace rai {
|
|
14
14
|
|
|
15
15
|
enum OptMethod { M_none=0,
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
M_GradientDescent, M_Rprop, M_LBFGS, M_Newton,
|
|
17
|
+
M_AugmentedLag, M_LogBarrier, M_slackGN_logBarrier, M_SquaredPenalty, M_singleSquaredPenalty,
|
|
18
18
|
M_slackGN,
|
|
19
19
|
M_NLopt, M_Ipopt, M_slackGN_Ipopt, M_Ceres,
|
|
20
|
-
M_LSZO};
|
|
20
|
+
M_LSZO, M_greedy, M_NelderMead, M_CMA };
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
struct OptOptions {
|
|
@@ -45,12 +45,11 @@ struct OptOptions {
|
|
|
45
45
|
RAI_PARAM("opt/", double, lambdaMax, -1.)
|
|
46
46
|
RAI_PARAM("opt/", double, interiorPadding, 1e-2)
|
|
47
47
|
RAI_PARAM("opt/", bool, boundedNewton, true)
|
|
48
|
-
RAI_PARAM_ENUM("opt/", OptMethod, method,
|
|
49
|
-
|
|
48
|
+
RAI_PARAM_ENUM("opt/", OptMethod, method, M_AugmentedLag)
|
|
49
|
+
RAI_PARAM("opt/", bool, finiteDifference, false)
|
|
50
50
|
};
|
|
51
|
-
//stdOutPipe(OptOptions)
|
|
52
51
|
|
|
53
|
-
OptOptions
|
|
52
|
+
std::shared_ptr<OptOptions> globalOptOptions();
|
|
54
53
|
|
|
55
54
|
} //namespace
|
|
56
55
|
|
|
@@ -9,10 +9,12 @@
|
|
|
9
9
|
#pragma once
|
|
10
10
|
|
|
11
11
|
#include "options.h"
|
|
12
|
-
#include "
|
|
12
|
+
#include "m_Newton.h"
|
|
13
13
|
#include "lagrangian.h"
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
namespace rai {
|
|
16
|
+
|
|
17
|
+
struct PrimalDualProblem : NLP_Scalar {
|
|
16
18
|
rai::LagrangianProblem L;
|
|
17
19
|
|
|
18
20
|
//duality gap parameter (log barrier parameter) of the primal dual equation system
|
|
@@ -23,7 +25,7 @@ struct PrimalDualProblem : ScalarFunction {
|
|
|
23
25
|
double dualityMeasure=1.;
|
|
24
26
|
bool primalFeasible=false;
|
|
25
27
|
|
|
26
|
-
PrimalDualProblem(const arr& x, const shared_ptr<NLP>& P,
|
|
28
|
+
PrimalDualProblem(const arr& x, const shared_ptr<NLP>& P, std::shared_ptr<OptOptions> opt);
|
|
27
29
|
|
|
28
30
|
double f(arr& r, arr& R, const arr& x); ///< CORE METHOD: the unconstrained scalar function F
|
|
29
31
|
|
|
@@ -39,10 +41,12 @@ struct OptPrimalDual {
|
|
|
39
41
|
arr& x;
|
|
40
42
|
PrimalDualProblem PD;
|
|
41
43
|
OptNewton newton;
|
|
42
|
-
|
|
44
|
+
std::shared_ptr<OptOptions> opt;
|
|
43
45
|
uint its=0;
|
|
44
46
|
|
|
45
|
-
OptPrimalDual(arr& x, arr& dual, const shared_ptr<NLP>& P,
|
|
47
|
+
OptPrimalDual(arr& x, arr& dual, const shared_ptr<NLP>& P, std::shared_ptr<OptOptions> _opt);
|
|
46
48
|
~OptPrimalDual();
|
|
47
49
|
uint run(uint maxIt=1000);
|
|
48
50
|
};
|
|
51
|
+
|
|
52
|
+
} //namespace
|
|
@@ -127,15 +127,15 @@ struct NLP_RastriginSOS : NLP {
|
|
|
127
127
|
|
|
128
128
|
//===========================================================================
|
|
129
129
|
|
|
130
|
-
struct NLP_Rastrigin :
|
|
131
|
-
NLP_Rastrigin(uint _dim) {
|
|
130
|
+
struct NLP_Rastrigin : NLP_Scalar {
|
|
131
|
+
NLP_Rastrigin(uint _dim) { dimension=_dim; }
|
|
132
132
|
virtual double f(arr& g, arr& H, const arr& x);
|
|
133
133
|
};
|
|
134
134
|
|
|
135
135
|
//===========================================================================
|
|
136
136
|
|
|
137
|
-
struct NLP_Rosenbrock :
|
|
138
|
-
NLP_Rosenbrock(uint _dim) {
|
|
137
|
+
struct NLP_Rosenbrock : NLP_Scalar {
|
|
138
|
+
NLP_Rosenbrock(uint _dim) { dimension=_dim; }
|
|
139
139
|
virtual double f(arr& g, arr& H, const arr& x);
|
|
140
140
|
};
|
|
141
141
|
|
|
@@ -216,7 +216,7 @@ struct ChoiceConstraintFunction : NLP {
|
|
|
216
216
|
enum WhichConstraint { none=0, wedge2D=1, halfcircle2D, randomLinear, circleLine2D, boundConstrained, boundConstrainedIneq } which;
|
|
217
217
|
uint n;
|
|
218
218
|
arr randomG;
|
|
219
|
-
|
|
219
|
+
ScalarFunction f_uc;
|
|
220
220
|
ChoiceConstraintFunction();
|
|
221
221
|
|
|
222
222
|
void evaluate(arr& phi, arr& J, const arr& x);
|
|
@@ -11,27 +11,16 @@
|
|
|
11
11
|
#include "NLP.h"
|
|
12
12
|
#include "../Core/util.h"
|
|
13
13
|
|
|
14
|
-
struct
|
|
15
|
-
shared_ptr<ScalarFunction> f;
|
|
16
|
-
Conv_ScalarFunction2NLP(shared_ptr<ScalarFunction> f);
|
|
17
|
-
virtual void evaluate(arr& phi, arr& J, const arr& x);
|
|
18
|
-
virtual void getFHessian(arr& H, const arr& x);
|
|
19
|
-
virtual void report(ostream& os, int verbose, const char *msg=0){
|
|
20
|
-
os <<"ScalarFunction of type '" <<rai::niceTypeidName(typeid(*this)) <<"'";
|
|
21
|
-
if(msg) os <<' ' <<msg;
|
|
22
|
-
os <<" dimension:" <<f->dim;
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
struct Conv_NLP2ScalarProblem : ScalarFunction {
|
|
14
|
+
struct NLP_FiniteDifference : NLP {
|
|
27
15
|
std::shared_ptr<NLP> P;
|
|
28
|
-
|
|
29
|
-
virtual
|
|
16
|
+
NLP_FiniteDifference(std::shared_ptr<NLP> _P) : P(_P) { copySignature(*P); }
|
|
17
|
+
virtual void evaluate(arr& phi, arr& J, const arr& x0);
|
|
18
|
+
virtual void report(ostream& os, int verbose, const char *msg=0){ os <<"FiniteDifference version of: "; P->report(os, verbose, msg); }
|
|
30
19
|
};
|
|
31
20
|
|
|
32
|
-
struct
|
|
21
|
+
struct NLP_SlackLeastSquares : NLP {
|
|
33
22
|
std::shared_ptr<NLP> P;
|
|
34
|
-
|
|
23
|
+
NLP_SlackLeastSquares(std::shared_ptr<NLP> _P);
|
|
35
24
|
virtual void evaluate(arr& phi, arr& J, const arr& x);
|
|
36
25
|
virtual void report(ostream& os, int verbose, const char *msg=0){ os <<"SlackLeastSquares of: "; P->report(os, verbose, msg); }
|
|
37
26
|
private:
|
|
@@ -54,8 +43,8 @@ struct NLP_LinTransformed : NLP {
|
|
|
54
43
|
// checks, evaluation
|
|
55
44
|
//
|
|
56
45
|
|
|
57
|
-
bool checkDirectionalGradient(
|
|
58
|
-
bool checkDirectionalJacobian(
|
|
46
|
+
bool checkDirectionalGradient(ScalarFunction f, const arr& x, const arr& delta, double tolerance);
|
|
47
|
+
bool checkDirectionalJacobian(VectorFunction f, const arr& x, const arr& delta, double tolerance);
|
|
59
48
|
|
|
60
49
|
//===========================================================================
|
|
61
50
|
//
|
|
@@ -63,5 +52,5 @@ bool checkDirectionalJacobian(const VectorFunction& f, const arr& x, const arr&
|
|
|
63
52
|
//
|
|
64
53
|
|
|
65
54
|
void accumulateInequalities(arr& y, arr& J, const arr& yAll, const arr& JAll);
|
|
66
|
-
void displayFunction(ScalarFunction
|
|
55
|
+
void displayFunction(ScalarFunction f, bool wait=false, double lo=-1.2, double hi=1.2);
|
|
67
56
|
|
robotic/librai.so
CHANGED
|
Binary file
|
robotic/meshTool
CHANGED
|
Binary file
|
robotic/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = '0.3.4'
|
|
1
|
+
__version__ = '0.3.4.dev2'
|