ocra-recipes
Doxygen documentation for the ocra-recipes repository
FSQPSolver.cpp
Go to the documentation of this file.
2 
3 namespace ocra
4 {
6  :NamedInstance("FSQP Solver")
7  , nf(0)
8  , nfsr(0)
9  , ncsrl(0)
10  , ncsrn(0)
11  , mode(100)
12  , iprint(0)
13  , miter(100)
14  , bigbnd(1e10)
15  , eps(1e-8)
16  , epseqn(1e-8)
17  , udelta(1e-8)
18  , bl(0x0,0)
19  , bu(0x0,0)
20  , f(new double,1)
21  , g(0x0,0)
22  , lambda(0x0,0)
23  , mesh_pts(new int, 1)
24  , _buffer(100)
25  , _allObjectivesProvideAGradient(true)
26  {
27  }
28 
30  {
31  ocra_assert(obj.getDimension() == 1);
33  _objectives.push_back(&obj);
34  nf = 1;
35  _allObjectivesProvideAGradient = _allObjectivesProvideAGradient && obj.canCompute<PARTIAL_X>();
36  }
37 
39  {
40  for(size_t i = 0; i < _objectives.size(); ++i)
41  {
42  if(&_objectives[i]->getFunction() == &obj)
43  {
44  removeObjective(*_objectives[i]);
45  break;
46  }
47  }
48  }
49 
51  {
53  _objectives.erase(std::find(_objectives.begin(), _objectives.end(), &obj));
54  nf = std::min(1, (int)_objectives.size());
55  _allObjectivesProvideAGradient = true;
56  for (size_t i=0; i<_objectives.size(); ++i)
57  _allObjectivesProvideAGradient = _allObjectivesProvideAGradient && obj.canCompute<PARTIAL_X>();
58  }
59 
60 
62  {
63  internalAddConstraint(constraint);
64  _constraints.addConstraint(constraint);
65  }
66 
68  {
69  internalAddConstraint(constraint);
70  _constraints.addConstraint(constraint);
71  }
72 
74  {
75  internalRemoveConstraint(constraint);
76  _constraints.removeConstraint(constraint);
77  }
78 
80  {
81  internalRemoveConstraint(constraint);
82  _constraints.removeConstraint(constraint);
83  }
84 
85 
87  {
88  addBounds_(constraint);
89  }
90 
92  {
93  addBounds_(constraint);
94  }
95 
96  void FSQPSolver::addBounds_(DiagonalLinearConstraint& constraint)
97  {
98  ocra_assert(constraint.isInequality() && "How queer! A bound constraint that is no inequality...");
99  internalAddConstraint(constraint);
100  _bounds.push_back(&constraint);
101  }
102 
104  {
105  removeBounds_(constraint);
106  }
107 
109  {
110  removeBounds_(constraint);
111  }
112 
113  void FSQPSolver::removeBounds_(DiagonalLinearConstraint& constraint)
114  {
115  ocra_assert(constraint.isInequality() && "How queer! A bound constraint that is no inequality...");
116  internalRemoveConstraint(constraint);
117  _bounds.erase(std::find(_bounds.begin(), _bounds.end(), &constraint));
118  }
119 
121  {
122  ocra_assert(false && "non implemented yet");
123  }
124 
126  {
129  }
130 
132  {
135  }
136 
138  {
139  ocra_assert(false && "non implemented yet");
140  }
141 
143  {
144  ocra_assert(false && "non implemented yet");
145  }
146 
148  {
151  }
152 
154  {
155  ocra_assert(false && "non implemented yet");
156  }
157 
159  {
160  ocra_assert(false && "non implemented yet");
161  }
162 
164  {
165  ocra_assert(false && "non implemented yet");
166  }
167 
168  //Todo : this should be moved to Solver (or remove: same can be achieved by ref.setValue(x0) - only the checks won't be done)
169  void FSQPSolver::set_x0(const VectorXd& x0, const Variable& ref)
170  {
171  ocra_assert(x0.size()==ref.getSize());
172  const Variable& pbVar = getProblemVariable(); //this line force the evaluation of the problem variable
173  if (pbVar.getSize() != ref.getSize())
174  throw std::runtime_error("[FSQPSolver::set_x0] problem variable and reference variable don't have the same size");
175  std::vector<int> mapping;
176  pbVar.getRelativeMappingOf(ref, mapping);
177  if (mapping.size()<pbVar.getSize())
178  throw std::runtime_error("[FSQPSolver::set_x0] problem variable and reference variable don't have the same children");
179 
180  this->x0.resize(x0.size());
181  for (int i=0; i<pbVar.getSize(); ++i)
182  this->x0[mapping[i]] = x0[i];
183  }
184 
185 
187  {
188  mode = (mode/10)*10+type;
189  }
190 
192  {
193  mode -= (mode/10)%10;
194  mode += 10*type;
195  }
196 
198  {
199  mode -= (mode/100)%100;
200  mode += 100*type;
201  }
202 
204  {
205  ocra_assert(m==100 || m==101 || m==110 || m==111 || m==200 || m==201 || m==210 || m==211);
206  mode = m;
207  }
208 
210  {
211  if (m<2)
212  iprint = m;
213  else
214  iprint = (iprint/10)*10+m;
215  }
216 
218  {
219  int assert_cond = iprint%10>=2;
220  ocra_assert(assert_cond);
221  iprint = 10*N+(iprint%10);
222  }
223 
224  void FSQPSolver::setPrintOption(int option)
225  {
226  int assert_cond = option>=0 && option%10< 4;
227  ocra_assert(assert_cond);
228  iprint = option;
229  }
230 
232  {
233  ocra_assert(n>0);
234  miter = n;
235  }
236 
237  void FSQPSolver::setInfinity(double infinity)
238  {
239  ocra_assert(infinity>0);
240  bigbnd = infinity;
241  }
242 
243  void FSQPSolver::setEps(double eps)
244  {
245  ocra_assert(eps>0);
246  this->eps = eps;
247  }
248 
249  void FSQPSolver::setEqnViol(double eps)
250  {
251  ocra_assert(eps>0);
252  epseqn = eps;
253  }
254 
255  void FSQPSolver::setUDelta(double udelta)
256  {
257  ocra_assert(udelta>0);
258  this->udelta = udelta;
259  }
260 
262  {
263  return static_cast<eFsqpProblemType>(mode%10);
264  }
265 
267  {
268  return static_cast<eFsqpAlgo>((mode/10)%10);
269  }
270 
272  {
273  return static_cast<eFsqpEvaluationDomainPolicy>((mode/100)%10);
274  }
275 
277  {
278  return mode;
279  }
280 
282  {
283  return static_cast<eFsqpPrintOption>(iprint%10);
284  }
285 
287  {
288  return iprint/10;
289  }
290 
292  {
293  return iprint;
294  }
295 
297  {
298  return miter;
299  }
300 
301  double FSQPSolver::getInfinity() const
302  {
303  return bigbnd;
304  }
305 
306  double FSQPSolver::setEps() const
307  {
308  return eps;
309  }
310 
311  double FSQPSolver::setEqnViol() const
312  {
313  return epseqn;
314  }
315 
316  double FSQPSolver::setUDelta() const
317  {
318  return udelta;
319  }
320 
322  {
323  ocra_assert(false && "not implemented yet");
324  }
325 
326  std::string FSQPSolver::toString()
327  {
328  return "";
329  }
330 
331 
332  void FSQPSolver::obj(int nparam, int j, double* x, double* fj, void* cd)
333  {
334  ocra_assert(j==1 && "in this implementation we only consider a unique objective function (possibly the sum of several functions)");
335  checkNewX(nparam, x);
336  *fj = 0;
337  for (size_t i=0; i<_objectives.size(); ++i)
338  *fj += _objectives[i]->getWeight() * _objectives[i]->getValue(0);
339  }
340 
341  void FSQPSolver::constr(int nparam, int j, double* x, double* gj, void* cd)
342  {
343  checkNewX(nparam, x);
344  *gj = _constraints.getValue(j-1);
345  }
346 
347  void FSQPSolver::gradob(int nparam, int j, double* x, double* gradfj, void* cd)
348  {
349  ocra_assert(j==1 && "in this implementation we only consider a unique objective function (possibly the sum of several functions)");
350  checkNewX(nparam, x);
351  MatrixMap g(gradfj, 1, nparam);
352  g.setZero();
353  if (_allObjectivesProvideAGradient)
354  {
355  for (size_t i=0; i<_objectives.size(); ++i)
356  utils::addCompressedByCol(_objectives[i]->getJacobian(0), g, findMapping(_objectives[i]->getVariable()), _objectives[i]->getWeight());
357  }
358  else
359  OFSQPProblem::gradob(nparam, j, x, gradfj, cd);
360  }
361 
362  void FSQPSolver::gradcn(int nparam, int j, double* x, double* gradgj, void* cd)
363  {
364  MatrixMap g(gradgj, 1, nparam);
365  g.setZero();
366  checkNewX(nparam, x);
367  std::pair<GenericConstraint*, int> p = _constraints[j-1];
368  if (p.first->canCompute<PARTIAL_X>())
369  utils::uncompressByCol(_constraints.getGradient(p), g, findMapping(p.first->getVariable()));
370  else
371  OFSQPProblem::gradcn(nparam, j, x, gradgj, cd);
372  }
373 
374 
375 
377  {
378  resize();
379  updateBounds();
380  if (_result.solution.size() == x0.size())
381  _result.solution = x0;
382  else
383  _result.solution.setZero();
384  }
385 
387  {
388  solver.cfsqp(n(),
389  nf,
390  nfsr,
391  nineqn,
392  nineq,
393  neqn,
394  neq,
395  ncsrl,
396  ncsrn,
397  const_cast<int*>(mesh_pts.data()), //TODO .data should have a non const version. Check with Eigen developpers and correct
398  mode,
399  iprint,
400  miter,
401  &inform,
402  bigbnd,
403  eps,
404  epseqn,
405  udelta,
406  const_cast<double*>(bl.data()),
407  const_cast<double*>(bu.data()),
408  _result.solution.data(),
409  const_cast<double*>(f.data()),
410  const_cast<double*>(g.data()),
411  const_cast<double*>(lambda.data()),
412  *this,
413  0x0);
414  }
415 
417  {
418  _result.info = translateReturnInfo();
419  x0 = _result.solution;
420  }
421 
422  void FSQPSolver::onConstraintResize(int timestamp)
423  {
424  _constraints.invalidateMapping();
425  }
426 
427  void FSQPSolver::onObjectiveResize(int timestamp)
428  {
429  //do nothing
430  }
431 
432  void FSQPSolver::resize()
433  {
434  nparam = n();
435  nineqn = _constraints.nineqn();
436  nineq = _constraints.nineq();
437  neqn = _constraints.neqn();
438  neq = _constraints.neq();
439  const int sg = std::max(1, nineq+neq);
440  const int sl = nparam+1+sg;
441 
442  _buffer.resize(2*nparam+sg+sl);
443  new (&g) VectorMap(_buffer.allocate(sg), sg);
444  new (&lambda) VectorMap(_buffer.allocate(sl), sl);
445  new (&bl) VectorMap(_buffer.allocate(nparam), nparam);
446  new (&bu) VectorMap(_buffer.allocate(nparam), nparam);
447 
448  bl.setConstant(-bigbnd);
449  bu.setConstant(+bigbnd);
450  }
451 
452  void FSQPSolver::updateBounds()
453  {
454  for (size_t i=0; i<_bounds.size(); ++i)
455  {
456  DiagonalLinearConstraint* cstr = _bounds[i];
457  const std::vector<int>& mapping = findMapping(cstr->getVariable());
458 
459  utils::intersectBounds(*cstr, mapping, bl, bu);
460  }
461  }
462 
463  eReturnInfo FSQPSolver::translateReturnInfo() const
464  {
465  switch (inform)
466  {
467  case 0: return RETURN_SUCCESS;
468  case 1: return RETURN_INFEASIBLE_PROBLEM;
469  case 2: return RETURN_INFEASIBLE_PROBLEM;
470  case 3: return RETURN_MAX_ITER_REACHED;
471  case 4: return RETURN_NUMERICAL_ERROR;
472  case 5: return RETURN_NUMERICAL_ERROR;
473  case 6: return RETURN_NUMERICAL_ERROR;
474  case 7: return RETURN_INCONSISTENT_PROBLEM;
475  case 8: return RETURN_NUMERICAL_ERROR;
476  case 9: return RETURN_NUMERICAL_ERROR;
477  default: ocra_assert(false && "this should never happen");
478  }
479  }
480 
481  void FSQPSolver::checkNewX(int nparam, double* x)
482  {
483  if (isXNew())
484  {
485  validateX();
486  setVariableValue(Map<VectorXd>(x, nparam));
487  }
488  }
489 
490 
491 
492 
494  {
495  BaseVariable xy("xy",2);
496  BaseVariable z("z",1);
497  CompositeVariable T("T", xy, z);
498 
499  MatrixXd A1(1,1); A1 << 1;
500  VectorXd b1(1); b1 << -3;
501  LinearFunction lf1(z, A1, b1);
502  LinearConstraint c1(&lf1, true);
503 
504  MatrixXd A2(1,2); A2 << 3,1 ;
505  VectorXd b2(1); b2 << 0;
506  LinearFunction lf2(xy, A2, b2);
507  LinearConstraint c2(&lf2, true);
508 
509  MatrixXd A3(2,2); A3 << 2,1,-0.5,1 ;
510  VectorXd b3(2); b3 << 0, 1;
511  LinearFunction lf3(xy, A3, b3);
512  LinearConstraint c3(&lf3, false);
513 
514  QuadraticFunction objFunc(T, Matrix3d::Identity(), Vector3d::Zero(), 0);
515  QuadraticObjective obj(&objFunc);
516 
517  FSQPSolver solver;
518  solver.addConstraint(c1);
519  solver.addConstraint(c2);
520  solver.addConstraint(c3);
521  solver.addObjective(obj);
522 
523  std::cout << "sol = " << std::endl << solver.solve().solution << std::endl << std::endl;
524  ocra_assert(solver.getLastResult().info == 0);
525 
526 
527  solver.removeConstraint(c1);
528  IdentityFunction id(z);
529  VectorXd lz(1); lz << 1;
530  VectorXd uz(1); uz << 2;
531  IdentityConstraint bnd1(&id, lz, uz);
532  solver.addBounds(bnd1);
533  std::cout << "sol = " << std::endl << solver.solve().solution << std::endl << std::endl;
534  ocra_assert(solver.getLastResult().info == 0);
535 
536  BaseVariable t("t", 2);
537  VectorXd ut(2); ut << -4,-1;
539  BoundConstraint bnd2(&bf, false);
540  solver.addBounds(bnd2);
541 
542  QuadraticFunction objFunc2(t, Matrix2d::Identity(), Vector2d::Constant(2.71828),0);
543  QuadraticObjective obj2(&objFunc2);
544  solver.addObjective(obj2);
545  std::cout << "sol = " << std::endl << solver.solve().solution << std::endl << std::endl;
546  ocra_assert(solver.getLastResult().info == 0);
547 
548  Vector2d c3l(-1,-1);
549  c3.setL(c3l);
550  std::cout << "sol = " << std::endl << solver.solve().solution << std::endl << std::endl;
551  ocra_assert(solver.getLastResult().info == 0);
552  }
553 
554 
555 
556 
557 
558  class Pb114G5: public Function
559  {
560  public:
561  Pb114G5(Variable& x, double s, double a)
562  : NamedInstance("Pb114G5")
564  , CoupledInputOutputSize(false)
566  , s(s), a(a)
567  {
568  assert(x.getSize() == 3);
569  }
570 
572 
573  protected:
574  void updateValue() const
575  {
576  _value[0] = s*(1.12*x[0] + .13167*x[0]*x[2] - 0.00667*x[0]*x[2]*x[2]) + a*x[1] ;
577  }
578  void updateJacobian() const
579  {
580  _jacobian(0,0) = s*(1.12+.13167*x[2]-0.00667*x[2]*x[2]);
581  _jacobian(0,1) = a;
582  _jacobian(0,2) = s*(.13167*x[0]-2*0.00667*x[0]*x[2]);
583  }
584 
585  double a;
586  double s;
587  };
588 
589  class Pb114G10: public Function
590  {
591  public:
593  : NamedInstance("Pb114G10")
595  , CoupledInputOutputSize(false)
597  {
598  assert(x.getSize() == 4);
599  }
600 
602 
603  protected:
604  void updateValue() const
605  {
606  _value[0] = 98000*x[0]/(x[1]*x[3]+1000*x[0])-x[2];
607  }
608  void updateJacobian() const
609  {
610  double v = x[1]*x[3]+1000*x[0];
611  double v2=v*v;
612  _jacobian(0,0) = 98000*(v-1000*x[0])/v2;
613  _jacobian(0,1) = -98000*x[0]*x[3]/v2;
614  _jacobian(0,2) = -1;
615  _jacobian(0,3) = -98000*x[0]*x[1]/v2;
616  }
617  };
618 
619  class Pb114G11: public Function
620  {
621  public:
623  : NamedInstance("Pb114G11")
625  , CoupledInputOutputSize(false)
627  {
628  assert(x.getSize() == 4);
629  }
630 
632 
633  protected:
634  void updateValue() const
635  {
636  _value[0] = (x[1]+x[2])/x[0]-x[3];
637  }
638  void updateJacobian() const
639  {
640  double x2=x[0]*x[0];
641  _jacobian(0,0) = -(x[1]+x[2])/x2;
642  _jacobian(0,1) = _jacobian(0,2) = 1/x[0];
643  _jacobian(0,3) = -1;
644  }
645  };
646 }
647 
649 
650 namespace ocra
651 {
653  {
654  double a=0.99;
655  double b=0.9;
656 
657  BaseVariable x1("x1",1);
658  BaseVariable x2("x2",1);
659  BaseVariable x3("x3",1);
660  BaseVariable x4("x4",1);
661  BaseVariable x5("x5",1);
662  BaseVariable x6("x6",1);
663  BaseVariable x7("x7",1);
664  BaseVariable x8("x8",1);
665  BaseVariable x9("x9",1);
666  BaseVariable x0("x0",1);
667  CompositeVariable X("X");
668  X.add(x1).add(x2).add(x3).add(x4).add(x5).add(x6).add(x7).add(x8).add(x9).add(x0);
669  CompositeVariable x70("x70", x7, x0);
670  CompositeVariable x90("x90", x9, x0);
671  CompositeVariable x145("x145"); x145.add(x1).add(x4).add(x5);
672  CompositeVariable x148("x148"); x148.add(x1).add(x4).add(x8);
673  CompositeVariable x678("x678"); x678.add(x6).add(x7).add(x8);
674  CompositeVariable x1258("x1258"); x1258.add(x1).add(x2).add(x5).add(x8);
675  CompositeVariable x3469("x3469"); x3469.add(x3).add(x4).add(x6).add(x9);
676 
677  MatrixXd Pf = MatrixXd::Zero(10,10); Pf(3,6)=Pf(6,3)=-0.063;
678  VectorXd qf(10); qf << 5.04, 0.035, 10, 0, 3.36, 0, 0, 0, 0, 0;
680 
681  VectorXd b1(1); b1<<35.82;
682  GreaterThanZeroConstraintPtr<LinearFunction> g1(new LinearFunction(x90, Vector2d(-b,-.222).transpose(), b1));
683 
684  Matrix2d A24; A24(0,0)=3;A24(1,0)=-3; A24(0,1)=-a; A24(1,1)=1/a;
685  GreaterThanZeroConstraintPtr<LinearFunction> g24(new LinearFunction(x70, A24, Vector2d(-133,133)));
686 
687  VectorXd b3(1); b3<<-35.82;
688  GreaterThanZeroConstraintPtr<LinearFunction> g3(new LinearFunction(x90, Vector2d(1/b,0.222).transpose(), b3));
689 
691 
692  Matrix3d P6 = Matrix3d::Zero(); P6(2,2)=-0.076;
693  GreaterThanZeroConstraintPtr<QuadraticFunction> g6(new QuadraticFunction(x678, P6, Vector3d(.325,-a,1.098), 57.425));
694 
695  GreaterThanZeroConstraintPtr<Pb114G5> g7(new Pb114G5(x148,-1, 1/a));
696 
697  Matrix3d P8 = Matrix3d::Zero(); P8(2,2)=0.076;
698  GreaterThanZeroConstraintPtr<QuadraticFunction> g8(new QuadraticFunction(x678, P8, Vector3d(-.325,1/a,-1.098), -57.425));
699 
700  VectorXd b9(1); b9<<0;
701  EqualZeroConstraintPtr<LinearFunction> g9(new LinearFunction(x145, Vector3d(-1,1.22,-1).transpose(), b9));
702 
705 
706  VectorXd l(10); l << 1.e-5,1.e-5,1.e-5,1.e-5,1.e-5,85,90,3,1.2,145;
707  VectorXd u(10); u << 2000,16000,120,5000,2000,93,95,12,4,162;
708 
709  IdentityFunction Id(X);
710  Constraint<IdentityFunction> bounds(&Id, l, u);
711 
712  FSQPSolver solver;
713  solver.setPrintOption(1);
714  solver.setB(FSQPSolver::NL);
715  solver.setMaxIter(10000);
716  solver.addObjective(f);
717  solver.addConstraint(g1);
718  solver.addConstraint(g24);
719  solver.addConstraint(g3);
720  solver.addConstraint(g5);
721  solver.addConstraint(g6);
722  solver.addConstraint(g7);
723  solver.addConstraint(g8);
724  solver.addConstraint(g9);
725  solver.addConstraint(g10);
726  solver.addConstraint(g11);
727  solver.addBounds(bounds);
728 
729  VectorXd x_init(10); x_init << 1745,12000,110,3048,1974,89.2,92.8,8,3.6,145;
730  VectorXd sol(10); sol << 1698.096,15818.73,54.10228,3031.226,2000,90.11537,95,10.49336,1.561636,153.53535;
731  solver.set_x0(x_init, X);
732  solver.solve();
733  IOFormat fullFmt(FullPrecision, 0, ", ", "\n", "", "", "", "");
734  std::cout << solver.getLastResult().info << std::endl;
735  std::cout << solver.getLastResult().solution.transpose().format(fullFmt) << std::endl;
736  std::cout << solver.getLastResult().solution.isApprox(sol,1e-5) << std::endl;
737  std::cout << (solver.getLastResult().solution-sol).norm()/std::min(solver.getLastResult().solution.norm(), sol.norm()) << std::endl;
738  }
739 }
void clearConstraints()
Definition: FSQPSolver.cpp:125
Function functionType_t
Definition: FSQPSolver.cpp:631
void removeBounds(BoundConstraint &constraint)
Definition: FSQPSolver.cpp:103
void internalAddConstraint(const GenericConstraint &constraint)
Definition: Solver.cpp:91
Objective class.
Definition: Objective.h:44
void addConstraint(LinearConstraint &constraint)
void setVariableValue(const VectorXd &value)
Definition: Solver.h:150
eFsqpProblemType getA() const
Definition: FSQPSolver.cpp:261
void addCompressedByCol(const MatrixBase< Derived1 > &in, MatrixBase< Derived2 > const &_out, const std::vector< int > &mapping, double scale, bool reverseMapping)
void addBounds(BoundConstraint &constraint)
Definition: FSQPSolver.cpp:86
void updateJacobian() const
Definition: FSQPSolver.cpp:638
void setInfinity(double infinity)
Definition: FSQPSolver.cpp:237
void constr(int nparam, int j, double *x, double *gj, void *cd)
Definition: FSQPSolver.cpp:341
void clearLinearInequalityConstraints()
Definition: FSQPSolver.cpp:158
void internalRemoveConstraint(const GenericConstraint &constraint)
Definition: Solver.cpp:121
Pb114G11(Variable &x)
Definition: FSQPSolver.cpp:622
Declaration file of the FSQPSolver class.
void updateJacobian() const
Definition: FSQPSolver.cpp:608
virtual void gradob(int nparam, int j, double *x, double *gradfj, void *cd)
Definition: OFSQP.cpp:13
void cfsqp(int nparam, int nf, int nfsr, int nineqn, int nineq, int neqn, int neq, int ncsrl, int ncsrn, int *mesh_pts, int mode, int iprint, int miter, int *inform, double bigbnd, double eps, double epseqn, double udelta, double *bl, double *bu, double *x, double *f, double *g, double *lambda, OFSQPProblem &problem, void *cd)
Definition: OFSQP.cpp:114
void internalAddObjective(const GenericObjective &objective)
Definition: Solver.cpp:77
double setEqnViol() const
Definition: FSQPSolver.cpp:311
double setEps() const
Definition: FSQPSolver.cpp:306
void setC(eFsqpEvaluationDomainPolicy type)
Definition: FSQPSolver.cpp:197
FSQPSolver class.
Definition: FSQPSolver.h:45
void setMode(int m)
Definition: FSQPSolver.cpp:203
Pb114G5(Variable &x, double s, double a)
Definition: FSQPSolver.cpp:561
eFsqpAlgo getB() const
Definition: FSQPSolver.cpp:266
OptimizationResult _result
Definition: Solver.h:215
int getMaxIter() const
Definition: FSQPSolver.cpp:296
const OptimizationResult & solve()
Definition: Solver.cpp:37
const std::vector< int > & findMapping(Variable &var)
Definition: Solver.cpp:12
void clearInequalityConstraints()
Definition: FSQPSolver.cpp:147
void setA(eFsqpProblemType type)
Definition: FSQPSolver.cpp:186
void uncompressByCol(const MatrixBase< Derived1 > &in, MatrixBase< Derived2 > const &_out, const std::vector< int > &mapping, double scale, bool reverseMapping)
void resize(size_t size)
Definition: Buffer.h:40
void addConstraint(LinearConstraint &constraint)
Definition: FSQPSolver.cpp:61
LinearFunction class.
BoundFunction class.
Definition: BoundFunction.h:45
void setPrintOption(int option)
Definition: FSQPSolver.cpp:224
void internalRemoveObjective(const GenericObjective &objective)
Definition: Solver.cpp:106
void gradob(int nparam, int j, double *x, double *gradfj, void *cd)
Definition: FSQPSolver.cpp:347
Function functionType_t
Definition: FSQPSolver.cpp:571
void updateJacobian() const
Definition: FSQPSolver.cpp:578
Optimization-based Robot Controller namespace. a library of classes to write and solve optimization p...
Pb114G10(Variable &x)
Definition: FSQPSolver.cpp:592
Function class.
Definition: Function.h:77
int getMode() const
Definition: FSQPSolver.cpp:276
Map< VectorXd > VectorMap
Definition: FSQPSolver.h:49
void clearLinearEqualityConstraints()
Definition: FSQPSolver.cpp:142
Constraint class.
Definition: Constraint.h:100
Variable & getProblemVariable()
Definition: Solver.h:148
void removeConstraint(LinearConstraint &constraint)
Definition: FSQPSolver.cpp:73
double getInfinity() const
Definition: FSQPSolver.cpp:301
void printValuesAtSolution()
Definition: FSQPSolver.cpp:321
void clearObjectives()
Definition: FSQPSolver.cpp:120
int getSize() const
Definition: Variable.cpp:81
void obj(int nparam, int j, double *x, double *fj, void *cd)
Definition: FSQPSolver.cpp:332
eFsqpEvaluationDomainPolicy getC() const
Definition: FSQPSolver.cpp:271
void addObjective(GenericObjective &obj)
Definition: FSQPSolver.cpp:29
void testFSQPSolver01()
Definition: FSQPSolver.cpp:493
void removeConstraint(LinearConstraint &constraint)
int getPrintOption() const
Definition: FSQPSolver.cpp:291
This class represents a variable in a mathematical sense.
Definition: Variable.h:105
const ScalarMultMatrixXdRow getGradient(int i) const
virtual void gradcn(int nparam, int j, double *x, double *gradgj, void *cd)
Definition: OFSQP.cpp:41
void gradcn(int nparam, int j, double *x, double *gradgj, void *cd)
Definition: FSQPSolver.cpp:362
int getPrintStep() const
Definition: FSQPSolver.cpp:286
void setMaxIter(int n)
Definition: FSQPSolver.cpp:231
void setPrintStep(int N)
Definition: FSQPSolver.cpp:217
Map< MatrixXd > MatrixMap
Definition: FSQPSolver.h:50
void clearNonLinearInequalityConstraints()
Definition: FSQPSolver.cpp:153
const OptimizationResult & getLastResult() const
Definition: Solver.cpp:59
void clearNonLinearEqualityConstraints()
Definition: FSQPSolver.cpp:137
void intersectBounds(const DiagonalLinearConstraint &bounds, const std::vector< int > &mapping, VectorBase1 &bl, VectorBase2 &bu)
void updateValue() const
Definition: FSQPSolver.cpp:574
void setPrintMode(eFsqpPrintOption m)
Definition: FSQPSolver.cpp:209
void updateValue() const
Definition: FSQPSolver.cpp:634
void validateX()
Definition: OFSQP.cpp:74
CompositeVariable & add(Variable &child)
Attach/detach the child to/from this node.
Definition: Variable.cpp:580
void removeObjective(Function &obj)
Definition: FSQPSolver.cpp:38
double setUDelta() const
Definition: FSQPSolver.cpp:316
Function functionType_t
Definition: FSQPSolver.cpp:601
eFsqpPrintOption getPrintMode() const
Definition: FSQPSolver.cpp:281
A concatenation of base variables and other composite variables.
Definition: Variable.h:357
void set_x0(const VectorXd &x0, const Variable &ref)
Definition: FSQPSolver.cpp:169
int n()
Definition: Solver.h:146
virtual void onObjectiveResize(int timestamp)
Definition: FSQPSolver.cpp:427
void updateValue() const
Definition: FSQPSolver.cpp:604
#define ocra_assert(ocra_expression)
Definition: ocra_assert.h:45
void setB(eFsqpAlgo type)
Definition: FSQPSolver.cpp:191
QuadraticFunction class.
void testFSQPSolver02()
Definition: FSQPSolver.cpp:652
std::string toString()
Definition: FSQPSolver.cpp:326
IdentityFunction class.
Implements a basic variable.
Definition: Variable.h:304
ptr_type allocate(size_t n)
Definition: Buffer.h:68
virtual void onConstraintResize(int timestamp)
Definition: FSQPSolver.cpp:422
void clearEqualityConstraints()
Definition: FSQPSolver.cpp:131