48 int INFO = snopt.solve(Cold, snopt.
neF, snopt.
n, snopt.
ObjAdd,
57 int EXIT = INFO - INFO%10;
60 std::string msg =
"Snopt failed to find a solution. EXIT:" + std::to_string(EXIT) +
", INFO:" + std::to_string(INFO);
61 throw std::runtime_error(msg);
72 solver.setProbName(
"snopt" );
73 solver.setIntParameter(
"Major Print level", 1 );
74 solver.setIntParameter(
"Minor Print level", 1 );
75 solver.setParameter(
"Solution");
76 solver.setIntParameter(
"Derivative option", 1 );
77 solver.setIntParameter(
"Verify level ", 3 );
78 solver.setIntParameter(
"Iterations limit", 200000);
79 solver.setRealParameter(
"Major feasibility tolerance", 1.0e-3);
80 solver.setRealParameter(
"Minor feasibility tolerance", 1.0e-3);
81 solver.setRealParameter(
"Major optimality tolerance", 1.0e-2);
111 for (uint _n=0; _n<bounds_x.size(); ++_n) {
112 xlow[_n] = bounds_x.at(_n).lower_;
113 xupp[_n] = bounds_x.at(_n).upper_;
126 for (
const auto& b : bounds_g) {
133 Eigen::Map<VectorXd>(&
x[0], x_all.rows()) = x_all;
155 for (
int var=0; var<
n; ++var) {
164 for (
int k=0; k<jac.outerSize(); ++k) {
165 for (Jacobian::InnerIterator it(jac,k); it; ++it) {
173 this->initialize(
"", 1);
182 int* needF,
int*
neF,
double F[],
183 int* needG,
int*
neG,
double G[],
184 char* cu,
int* lencu,
int iu[],
185 int* leniu,
double ru[],
int* lenru)
196 Eigen::Map<VectorXd>(F+i, g_eig.rows()) = g_eig;
207 Eigen::Map<VectorXd>(G, i) = grad;
Problem::VectorXd VectorXd
VecBound GetBoundsOnConstraints() const
static void ObjectiveAndConstraintFct(int *Status, int *n, double x[], int *needF, int *neF, double F[], int *needG, int *neG, double G[], char *cu, int *lencu, int iu[], int *leniu, double ru[], int *lenru)
double EvaluateCostFunction(const double *x)
VectorXd GetVariableValues() const
VectorXd EvaluateCostFunctionGradient(const double *x)
bool HasCostTerms() const
VecBound GetBoundsOnOptimizationVariables() const
void SetVariables(const double *x)
Jacobian GetJacobianOfConstraints() const
static void Solve(Problem &nlp)
Creates a snoptProblemA from nlp and solves it.
SnoptAdapter(Problem &nlp)
Creates an Adapter Object around the problem to conform to the Snopt interface.
void EvalNonzerosOfJacobian(const double *x, double *values)
static void SetOptions(SnoptAdapter &)
Sets solver settings for Snopt.
int GetNumberOfConstraints() const
VectorXd EvaluateConstraints(const double *x)
Solves the optimization problem with the new SNOPT 7.6 version.
int GetNumberOfOptimizationVariables() const