Code Monkey home page Code Monkey logo

ifopt's People

Contributors

awinkler avatar briansoe66 avatar costashatz avatar depardo avatar dlu avatar fbiemueller avatar jdlangs avatar kotochleb avatar levi-armstrong avatar marip8 avatar mpowelson avatar traversaro avatar viviansuzano avatar wxmerkt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ifopt's Issues

question

can this solve the problem without providing the gradiant

IPOPT options

Hello
I am using IFOPT to run IPOPT (defining a problem and solving it). I see that there seem to be no methods for changing the IPOPT options (max cpu time, linear solver, max iterations, convergence criteria etc.).
could you please provide guidance on how to do that
best
jac

Segmentation Fault for "finite-difference-values" option

I was running some tests with IFOPT and I found a bug that causes the program to crash with Segmentation Fault. The failure occur when setting the "jacobian_approximation" option to "finite-difference-values" (instead of "exact") and commenting all lines in the body of the FillJacobianBlock function in the ExConstraint class:

ipopt.SetOption("jacobian_approximation", "exact");

void FillJacobianBlock (std::string var_set, Jacobian& jac_block) const override

Since the solver is suppose to compute the constraint Jacobian numerically, the user doesn't need to provide the Jacobian expression and I don't see why this wouldn't work. (According to Ipopt documentation, the user is still suppose to provide the Jacobian structure, but your code takes care of it).

I compiled ifopt package in debug mode and launched the ifopt_ipopt-example with gdb and I get this:

Starting program: /home/vivian/towr_ws/build/ifopt/ifopt_ipopt/ifopt_ipopt-example 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

************************************************************
    IFOPT - Interface to Nonlinear Optimizers (v2.0)
                © Alexander W. Winkler
           https://github.com/ethz-adrl/ifopt
************************************************************
Legend:
c - number of variables, constraints or cost terms
i - indices of this set in overall problem
v - number of [violated variable- or constraint-bounds] or [cost term value]

                                          c             i             v 
variable-sets:
   var_set1                         2        0......1           1

constraint-sets:
   constraint1                      1        0......0           1

cost-terms:
   cost_term1                       1        0......0       -0.25

******************************************************************************
This program contains Ipopt, a library for large-scale nonlinear optimization.
 Ipopt is released as open source code under the Eclipse Public License (EPL).
         For more information visit http://projects.coin-or.org/Ipopt
******************************************************************************

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff68efc03 in Ipopt::TNLPAdapter::internal_eval_jac_g(bool) () from /usr/lib/libipopt.so.1

[Q] Weak solver performance

Hi,
firstly I am not sure if this is the right place to ask this type of questions, so I am sorry if it is not. I have implemented the same algorithm (KOMO motion planner for Franka Emika) in Casadi (using IPOPT) and in ifopt (using IPOPT), however the required time for solving the same problem in ifopt is over 0.8 seconds where in Casadi it is around 5ms. I have tried to set same solver options but without any luck. I do not have enough experience to know where to find errors according to the IPOPT logs so could you point me to the things that could be wrong? Thank you in advance

ifopt terminal outputs:

************************************************************
    IFOPT - Interface to Nonlinear Optimizers (v2.0)
                © Alexander W. Winkler
           https://github.com/ethz-adrl/ifopt
************************************************************
Legend:
c - number of variables, constraints or cost terms
i - indices of this set in overall problem
v - number of [violated variable- or constraint-bounds] or [cost term value]

                                   c             i             v 
variable-sets:
   x                              140        0....139          18

constraint-sets:

cost-terms:
   k_order=2                        1        0......0       35.19


******************************************************************************
This program contains Ipopt, a library for large-scale nonlinear optimization.
 Ipopt is released as open source code under the Eclipse Public License (EPL).
         For more information visit http://projects.coin-or.org/Ipopt
******************************************************************************

Starting derivative checker for first derivatives.


No errors detected by derivative checker.

Total number of variables............................:      126
                     variables with only lower bounds:        0
                variables with lower and upper bounds:      126
                     variables with only upper bounds:        0
Total number of equality constraints.................:        0
Total number of inequality constraints...............:        0
        inequality constraints with only lower bounds:        0
   inequality constraints with lower and upper bounds:        0
        inequality constraints with only upper bounds:        0


Number of Iterations....: 164

                                   (scaled)                 (unscaled)
Objective...............:   1.9920397525905261e-03    1.9920397525905261e-03
Dual infeasibility......:   7.4954637053187387e-04    7.4954637053187387e-04
Constraint violation....:   0.0000000000000000e+00    0.0000000000000000e+00
Complementarity.........:   1.0286094458408624e-11    1.0286094458408624e-11
Overall NLP error.......:   7.4954637053187387e-04    7.4954637053187387e-04


Number of objective function evaluations             = 1084
Number of objective gradient evaluations             = 165
Number of equality constraint evaluations            = 0
Number of inequality constraint evaluations          = 0
Number of equality constraint Jacobian evaluations   = 0
Number of inequality constraint Jacobian evaluations = 0
Number of Lagrangian Hessian evaluations             = 0
Total CPU secs in IPOPT (w/o function evaluations)   =      0.386
Total CPU secs in NLP function evaluations           =      0.114

EXIT: Optimal Solution Found.

casadi with ipopt terminal output

******************************************************************************
This program contains Ipopt, a library for large-scale nonlinear optimization.
 Ipopt is released as open source code under the Eclipse Public License (EPL).
         For more information visit http://projects.coin-or.org/Ipopt
******************************************************************************

This is Ipopt version 3.12.3, running with linear solver mumps.
NOTE: Other linear solvers might be more efficient (see Ipopt documentation).

Number of nonzeros in equality constraint Jacobian...:        0
Number of nonzeros in inequality constraint Jacobian.:        0
Number of nonzeros in Lagrangian Hessian.............:      357

Total number of variables............................:      126
                     variables with only lower bounds:        0
                variables with lower and upper bounds:      126
                     variables with only upper bounds:        0
Total number of equality constraints.................:        0
Total number of inequality constraints...............:        0
        inequality constraints with only lower bounds:        0
   inequality constraints with lower and upper bounds:        0
        inequality constraints with only upper bounds:        0

iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
   0  2.1253940e+02 0.00e+00 1.71e+01  -1.0 0.00e+00    -  0.00e+00 0.00e+00   0
   1  2.0206655e+01 0.00e+00 6.90e+00  -1.0 1.20e+00    -  1.14e-01 1.00e+00f  1
   2  6.5670904e+00 0.00e+00 1.37e+00  -1.0 8.16e-01    -  3.74e-01 1.00e+00f  1
   3  3.2177296e+00 0.00e+00 4.20e-01  -1.0 5.31e-01    -  5.25e-01 1.00e+00f  1
   4  1.1957934e+00 0.00e+00 1.43e-01  -1.0 5.65e-01    -  6.74e-01 1.00e+00f  1
   5  3.8116699e-01 0.00e+00 3.01e-02  -1.7 4.15e-01    -  8.03e-01 1.00e+00f  1
   6  9.8561908e-02 0.00e+00 9.94e-03  -2.5 6.37e-01    -  8.29e-01 1.00e+00f  1
   7  3.3479435e-02 0.00e+00 2.59e-03  -2.5 5.73e-01    -  8.77e-01 1.00e+00f  1
   8  7.9561309e-03 0.00e+00 1.56e-03  -3.8 5.31e-01    -  7.55e-01 1.00e+00f  1
   9  3.0230167e-03 0.00e+00 5.81e-15  -3.8 3.45e-01    -  1.00e+00 1.00e+00f  1
iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
  10  2.5830397e-03 0.00e+00 3.10e-05  -5.7 1.39e-01    -  9.45e-01 1.00e+00f  1
  11  2.5749846e-03 0.00e+00 5.29e-15  -5.7 2.25e-02    -  1.00e+00 1.00e+00f  1
  12  2.5749615e-03 0.00e+00 7.55e-15  -8.6 1.21e-03    -  1.00e+00 1.00e+00f  1

Number of Iterations....: 12

                                   (scaled)                 (unscaled)
Objective...............:   2.5749614818928864e-03    2.5749614818928864e-03
Dual infeasibility......:   7.5478594533688798e-15    7.5478594533688798e-15
Constraint violation....:   0.0000000000000000e+00    0.0000000000000000e+00
Complementarity.........:   7.6332274818848167e-09    7.6332274818848167e-09
Overall NLP error.......:   7.6332274818848167e-09    7.6332274818848167e-09


Number of objective function evaluations             = 13
Number of objective gradient evaluations             = 13
Number of equality constraint evaluations            = 0
Number of inequality constraint evaluations          = 0
Number of equality constraint Jacobian evaluations   = 0
Number of inequality constraint Jacobian evaluations = 0
Number of Lagrangian Hessian evaluations             = 12
Total CPU secs in IPOPT (w/o function evaluations)   =      0.002
Total CPU secs in NLP function evaluations           =      0.000

EXIT: Optimal Solution Found.
      solver  :   t_proc      (avg)   t_wall      (avg)    n_eval
       nlp_f  |  36.00us (  2.77us)  33.91us (  2.61us)        13
  nlp_grad_f  |  47.00us (  3.36us)  46.08us (  3.29us)        14
  nlp_hess_l  |  43.00us (  3.58us)  42.09us (  3.51us)        12
       total  |   4.08ms (  4.08ms)   4.08ms (  4.08ms)         1

Problems that contain no constraints segfault

Hi Alexander,
Thank you very much for providing this great wrapper! I am in the process of integrating it into our motion planning framework (in order to use Ipopt) and came across the following segmentation fault:

  • If an NLP contains only a cost term, no constraint terms: it segfaults.
  • If a 0-dimensional constraint is added: no segfault.

Best wishes,
Wolfgang

Example on vector CostTerm ?

Hi,
thanks for this interesting project !

I was wondering if this project allows to write CostTerms which cost is a vector ??
e.g. e = var_set1 - var_set0 a vector element-wise subtraction (e, var_set0, var_set1 in R^n).

This picture in the doc seems to indicate that it is doable but with CostTerm::GetCost return type being a double I can't get my head around this issue.

Could you please provide some more info, possibly an example ??

Cheers.

catkin_make run_tests failure

hey Alex, I can run catkin_make. but when I run catkin_make run_testsm, I got the following error:

_Exception of type: OPTION_INVALID in file "IpAlgBuilder.cpp" at line 345:
Exception message: Selected linear solver MA57 not available.
Tried to obtain MA57 from shared library "libhsl.so", but the following error occured:
libhsl.so: cannot open shared object file: No such file or directory

EXIT: Invalid option encountered.
Ipopt failed to find a solution. ReturnCode: -120.5 1.5_

I guess that is because my library for MA57 is called libcoinhsl.so which is located in /home/penglu/packages/Ipopt/ThirdParty/HSL/coinhsl/lib, could you please give me a hint how to solve this issue? Thanks.

New tagged ROS release that includes newest commits

Hi,

I found the new return code change introduced in #40 useful and our code base is currently using the master branch of this repository. However, it would be helpful if this was released through ROS. Would it be possible for you to create a new tagged version for ROS Kinetic that includes the above commit please?

Thank you very much!

ifopt- ipopt problem

I have installed ipopt in /usr/local and it can be use directly. But when i use it in ifopt, some problems occur as the following (i have changed the part of "Find IPOPT" in the CMakeList.txt)
/usr/local/lib/libipopt.so: undefined reference to dlopen' /usr/local/lib/libipopt.so: undefined reference to dlclose'
/usr/local/lib/libipopt.so: undefined reference to dlerror' /usr/local/lib/libipopt.so: undefined reference to dlsym'

i want to get some help, thank you.

How to use Eigen as solver library

Hello
I have compiled IFOPT and linked to IOPT. In the IFOPT site it is specified that it interfaces with EIGEN. Does this means that EIGEN can be used as a linear solver in IPOPT or just that EIGEN is used for the formulation of the optimization problem.
thank you for clarifying.
jacob

Get Iterations History

First, I would like to congratulate the contributors of this project. It is a great work.

I would like to ask if there is a canonical way to get the value of the optimization variables for the iterations along the optimization process.
I see that the class ifopt::Problem has a member x_prev which I think it contains the data i desire. But this member is private.
My questions are:

  1. Contains x_prev the history of the iterations?
  2. Is there a way to get its value?

I think that a const method const std::vector<VectorXd> &GetIterations() const { return x_prev; }; will be usefull. It this solves the problem I can do a pull request.

Redundant calls to FillJacobianBlock

During debugging, I noticed that FillJacobianBlock is called on each constraint/cost twice, with the second call being redundant.

I placed cout statements in each constraint/cost FillJacobianBlock statements, and ran using an IpoptSolver. The statement prints the particular FillJacobianBlock instance being called, as well as the current value of the var_set its being called on. The second call is redundant because it passes the same exact values for the var_set in.

The output shows:

FillJacobianBlock on cost_term_1 for var_set var_set1
0.82477262908425008625
0.34705019768468647889
FillJacobianBlock on cost_term_1 for var_set var_set1
0.82477262908425008625
0.34705019768468647889
FillJacobianBlock on constraint_term_1 for var_set var_set1
0.82477262908425008625
0.34705019768468647889
FillJacobianBlock on constraint_term_1 for var_set var_set1
0.82477262908425008625
0.34705019768468647889
FillJacobianBlock on cost_term_1 for var_set var_set1
0.91151018263754624016
0.20160334655763342826
FillJacobianBlock on cost_term_1 for var_set var_set1
0.91151018263754624016
0.20160334655763342826
FillJacobianBlock on constraint_term_1 for var_set var_set1
0.91151018263754624016
0.20160334655763342826
FillJacobianBlock on constraint_term_1 for var_set var_set1
0.91151018263754624016
0.20160334655763342826
FillJacobianBlock on cost_term_1 for var_set var_set1
 0.99911511172637545997
0.031011668948078191521
FillJacobianBlock on cost_term_1 for var_set var_set1
 0.99911511172637545997
0.031011668948078191521
FillJacobianBlock on constraint_term_1 for var_set var_set1
 0.99911511172637545997
0.031011668948078191521
FillJacobianBlock on constraint_term_1 for var_set var_set1
 0.99911511172637545997
0.031011668948078191521
FillJacobianBlock on cost_term_1 for var_set var_set1
   0.99999116101726370776
0.00012925427351325596836
FillJacobianBlock on cost_term_1 for var_set var_set1
   0.99999116101726370776
0.00012925427351325596836
FillJacobianBlock on constraint_term_1 for var_set var_set1
   0.99999116101726370776
0.00012925427351325596836
FillJacobianBlock on constraint_term_1 for var_set var_set1
   0.99999116101726370776
0.00012925427351325596836
FillJacobianBlock on constraint_term_1 for var_set var_set1
   0.99999718292395767261
5.6341804121589472969e-06
FillJacobianBlock on constraint_term_1 for var_set var_set1
   0.99999718292395767261
5.6341804121589472969e-06
FillJacobianBlock on cost_term_1 for var_set var_set1
   0.99999718292395767261
5.6341804121589472969e-06
FillJacobianBlock on cost_term_1 for var_set var_set1
   0.99999718292395767261
5.6341804121589472969e-06

Provide only part of derivatives to SNOPT

First of all, thanks a lot for providing us this super convenient tool!
I'm using it for constructing problems for Snopt. From the document of Snopt, I read that the user can provide part of gradients and Snopt can estimate the left gradients by finite differences. When I'm using ifopt, it seems to me that the Jacobian is first initialized as all zeros and then certain values are substituted by calculated derivates. Snopt thus considers that all the gradients are provided and will not estimate anything. I'm wondering is there's a way that I can calculate part of the derivates in my code and inform Snopt that the left derivates need estimation.

Using AD Libraries

Hi, I am currently using CppAD which wraps IpOpt to compute the derivatives etc using AD and also call into IpOpt to set up and solve my IpOpt problem.

I wondered whether you have an example of AD being used with ifopt? If so which AD library(s) is compatible with ifopt?
Thanks

IPOPT's maximum cpu time is not reset when violated

Hi everyone,
I noticed that, whenever IPOPT is not able to find a solution because the MAXIMUM_CPU_TIME is exceeded, this termination mode will keep on being triggered forever unless you restart IPOPT. This means that if, for example, I attempt to optimize a solution and the solver does not find a solution because of the maximum_cpu_time, then the solver won't find a solution even for the next formulations, even if I change robot, terrain or any other possible configuration. It really looks like the MAXIMUM_CPU_TIME flag of IPOPT is not properly reset and, when triggered, remains always ON.
Please notice that this is probably an IPOPT bug, not IFOPT, but I am wondering if anyone here noticed the same issue and found a fix for it.

Question about warm starting

Hello!
I appreciate your efforts in maintaining this nice repo.

I have a quick question about the warm starting of the optimizer.
Can I just set variables with the numbers I want to initialize as you do in here?
Or should I call extra method such as SetOption("warm_start_init_point", "yes"); ?

SegFault when running ifopt_ipopt-example

Hi,
When I am running ifopt_ipopt_example, it turns out "Segmentation fault (core dumped)". If gdb is used, it shows "Program received signal SIGSEGV, Segmentation fault. 0x0000000000000000 in ?? ()" . The version of ipopt I used is 3.13.3. What is the reason?

errors with Snopt 7.7

make test passes for both snopt and ipopt but when I use SnoptSolver solver and solver.Solve(nlp) in my code instead of IpoptSolver, it throws the following errors:

undefined reference to 'vtable for ifopt::SnoptSolver'
undefined reference to 'ifopt::SnoptSolver::Solve(ifopt::Problem&)

I have already followed the suggestions in #31 to make SNOPT work.

GetBounds() violation when both boundaries are negative

Hi, I need to add joint limits and one of the joint have both limits negative Bounds(-3.0718, -0.0698). I have set the initial value of the decision variable as -0.5 but the NLP is saying that the variable is violated. When I change the upper limit to 0, the number of violated variables is zero. Is it not possible to use both negative limits or the mistake is elsewhere?

int time_steps = 5;
 VecBound bounds(GetRows());
 for (int i=0; i<time_steps; i++)
 {
     bounds.at(i*7+0) = Bounds(-2.8973, 2.8973);  // joint_1
     bounds.at(i*7+1) = Bounds(-1.7628, 1.7628);  // joint_2
     bounds.at(i*7+2) = Bounds(-2.8973, 2.8973);  // joint_3

     // -------This line is problematic-----------
     bounds.at(i*7+3) = Bounds(-3.0718, -0.0698); // joint_4
     // -----------------------------------------

     bounds.at(i*7+4) = Bounds(-2.8973, 2.8973);  // joint_5
     bounds.at(i*7+5) = Bounds(-0.0175, 3.7525);  // joint_6
     bounds.at(i*7+6) = Bounds(-2.8973, 2.8973);  // joint_7
 }
 return bounds;

image

Difficulties with shared libraries and improved ifopt_snopt CMake

Hello,
We intend to use your nice wrapper for SNOPT 7.6. We've had some issues linking libraries. When compiling ifopt the following error message occurs when linking.

/usr/bin/ld: /usr/local/lib/libsnopt7_cpp.a(snoptProblem.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libsnopt7_cpp.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
make[2]: *** [/home/alex/gitprojects/untrusted_maps_planner/catkin_ws/devel/lib/libifopt_snopt.so] Error 1
make[1]: *** [ifopt/ifopt_snopt/CMakeFiles/ifopt_snopt.dir/all] Error 2 

We resolved this my modifying lines 54 and 56 of the CMakeLists file for ifopt_snopt to be as follows.


 add_library(${PROJECT_NAME} STATIC src/snopt76_adapter.cc)

else()

 add_library(${PROJECT_NAME} STATIC src/snopt_adapter.cc)

endif()

This work around is ok, but I'm wondering if we can actually use shared libraries and how.

Finally, we also modified line 15 (same file) to be in-line with the SNOPT installation instructions. I think this may help make the code a bit more modular between machines.

set(SNOPT_DIR "/home/$ENV{USER}/software/snopt_lib")

not compatible with Snopt 7.6 (Latest version)

The C++ interface of SNOPT has changed from 7.5.x to 7.6 so users buying the license since January 2017 cannot use the current IFopt interface. Should we create an alternative branch to support both interfaces?

Adding Hessians to Component

I notice that components only include values, bounds, and jacobians. Is there any reason Hessians are not stored in them as well, other than you just didn't need it?

We are considering using this library for a project, and a lot of the solvers we'd like to interface to accept hessians. I'm not entirely sure how this would look. I suppose it could actually go in CostTerm?

Noetic release

Hi,

Thanks for this library! Are you planning a Noetic release any time soon?

Unit tests are broken

It looks like the most recent PR changed a function signature but the unit tests were not updated.

ROS 2 Foxy Release?

I noticed that this package has releases on most of the ROS 1 distros, but did not see anything on the ROS 2 distros. Are there plans to release this on ROS 2 Foxy?

install process, make test error

Hi, I found an error before install.
After make, when I run make test, the issues are shown as follows:
Running tests...
Test project /home/lxh/software/ifopt-master/build
Start 1: ifopt_core-test
1/2 Test #1: ifopt_core-test .................. Passed 0.00 sec
Start 2: ifopt_ipopt-example
2/2 Test #2: ifopt_ipopt-example ..............***Exception: Other 0.09 sec

50% tests passed, 1 tests failed out of 2

Total Test time (real) = 0.09 sec

The following tests FAILED:
2 - ifopt_ipopt-example (OTHER_FAULT)
Errors while running CTest
make: *** [test] error 8

My OS:
OS: ubuntu 14.04 LTS, and gcc g++ version are 4.8.4

SNOPT 7.6 Compatibility

First of all, thanks for this great interface.

In a previous version, I was able to use SNOPT 7.6 through snopt76_adapter. However, in the current version, snopt_adapter_76.h is referenced in snopt_adapter.h but I cannot find it. Still, I can successfully install if I comment out setUserFun(&SnoptAdapter::ObjectiveAndConstraintFct); in snopt_adapter.cc which is somehow not declared. Yet, make test fails.

Also, there is a mismatch for the SNOPT version variable between ifopt/ifopt_snopt/cmake/FindSNOPT.cmake and ifopt/ifopt_snopt/CMakeList.txt, i.e., snopt_v76 vs SNOPT_v76.

Solution The following steps solved the issue for me:

  • Correcting the variable name problem
  • Adding this->initialize("print_file.out",1); (namely, initializing SNOPT) and removing setUserFun(&SnoptAdapter::ObjectiveAndConstraintFct);

I hope that helps and thanks again for sharing your work.

Help Installing Ifopt-Ipopt w/o catkin

I'm hoping to build Ifopt (with ipopt in particular) on a Mac-OSX without the use of catkin.

I have Ipopt and Eigen installed properly, but I'm not sure about which lines need to be added/changed for a standard mkdir build; cd build; cmake .. to work.

In particular, I've put in my Ipopt directory in the set(IPOPT_DIR ... ) line of CMakeLists.txt but I'm not totally sure what it means to ensure that "IPOPT headers and library are installed; somewhere in the default search paths", and I got the following error:

Could not find a package configuration file provided by "catkin" with any
of the following names:

catkinConfig.cmake
catkin-config.cmake

Apologies for the novice question but I would very much appreciate some assistance!

IPOPT finite difference result is different from exact

I did a test using the example code provided in ipopt test to compare the result of using "ipopt.SetOption("jacobian_approximation", "exact"); " and using "ipopt.SetOption("jacobian_approximation", "finite-difference-values");"

If I use the exact jacobian provided in the code, I got optimal solution be "1.00 0.00". If I change the jacobian option to finite difference. Nothing changes. I am wondering the algorithm is still using the provided jacobian. So I comment out the content of functions "FillJacobianBlock" of ExCost and ExConstraint. Now the optimal solution I got is "0.44 0.81", which has lower cost but slightly violate the constraint. If I change the initial condition to be "1.5 0.5", then the optimal solution is "0.81 0.34", still violates the constraint. I guess the finite difference method suffers from numerical problem in this case.

Could anyone help me to answer following questions:

  1. Whether I am using "finite-difference-values" correctly or not.
  2. How to improve the numerical precision of finite difference method.

Generic version of IPOPT

Hello
IPOPT comes with a number of interfaces to linear solvers (MUMPS, LAPACK, HSL) and others.
I tried to create a dll of ipopt with none of these solvers in order to focus o Eigen.
the build fails because it looks for these libs.
Is there a clean version of IPOPT ? i.e., one that does not depend on any solver a priori ?
then the build of IPOPT+EIGEN could be much cleaner and simpler.
best
jac

The EvaluateCostFunctionGradient numerical difference produces incorrect gradient when using squared cost.

I believe this is the reason IPOPT using 1e-8 due to floating-point precision when having squared cost. If you paste the code into the godbolt compiler you get the output below which causes the gradient to be zero using the current epsilon. I plan to submit a PR allowing the user to set the epsilon.

int main(int argc, char** argv)
{
    std::cout.precision(17);
    {
        double x = 3 + 1e-16;
        double x2 = x * x;
        std::cout << std::fixed << x2 << std::endl;
    }

    {
        double x = 3 + 1e-8;
        double x2 = x * x;
        std::cout << std::fixed << x2 << std::endl;
    }
}

output:

ASM generation compiler returned: 0
Execution build compiler returned: 0
Program returned: 0
9.00000000000000000
9.00000005999999964

Compiling ex_test_ipopt.cc gives error

/tmp/ccexmy3Z.o: In function main': ex_test_ipopt.cc:(.text+0x136): undefined reference to ifopt::Problem::Problem()'
ex_test_ipopt.cc:(.text+0x171): undefined reference to ifopt::Problem::AddVariableSet(std::shared_ptr<ifopt::Component>)' ex_test_ipopt.cc:(.text+0x1c1): undefined reference to ifopt::Problem::AddConstraintSet(std::shared_ptrifopt::ConstraintSet)'
ex_test_ipopt.cc:(.text+0x20e): undefined reference to ifopt::Problem::AddCostSet(std::shared_ptr<ifopt::ConstraintSet>)' ex_test_ipopt.cc:(.text+0x235): undefined reference to ifopt::Problem::PrintCurrent() const'
ex_test_ipopt.cc:(.text+0x285): undefined reference to ifopt::Ipopt::Solve(ifopt::Problem&)' ex_test_ipopt.cc:(.text+0x29b): undefined reference to ifopt::Problem::GetOptVariables() const'
/tmp/ccexmy3Z.o: In function ifopt::Component::~Component()': ex_test_ipopt.cc:(.text._ZN5ifopt9ComponentD2Ev[_ZN5ifopt9ComponentD5Ev]+0xd): undefined reference to vtable for ifopt::Component'
/tmp/ccexmy3Z.o: In function ifopt::ExVariables::ExVariables(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)': ex_test_ipopt.cc:(.text._ZN5ifopt11ExVariablesC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN5ifopt11ExVariablesC5ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x21): undefined reference to ifopt::VariableSet::VariableSet(int, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&)'
/tmp/ccexmy3Z.o: In function ifopt::ExVariables::GetBounds() const': ex_test_ipopt.cc:(.text._ZNK5ifopt11ExVariables9GetBoundsEv[_ZNK5ifopt11ExVariables9GetBoundsEv]+0x25): undefined reference to ifopt::Component::GetRows() const'
/tmp/ccexmy3Z.o: In function ifopt::ConstraintSet::~ConstraintSet()': ex_test_ipopt.cc:(.text._ZN5ifopt13ConstraintSetD2Ev[_ZN5ifopt13ConstraintSetD5Ev]+0xd): undefined reference to vtable for ifopt::ConstraintSet'
/tmp/ccexmy3Z.o: In function ifopt::ExConstraint::ExConstraint(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)': ex_test_ipopt.cc:(.text._ZN5ifopt12ExConstraintC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN5ifopt12ExConstraintC5ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x21): undefined reference to ifopt::ConstraintSet::ConstraintSet(int, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&)'
/tmp/ccexmy3Z.o: In function ifopt::ExConstraint::GetValues() const': ex_test_ipopt.cc:(.text._ZNK5ifopt12ExConstraint9GetValuesEv[_ZNK5ifopt12ExConstraint9GetValuesEv]+0x25): undefined reference to ifopt::Component::GetRows() const'
ex_test_ipopt.cc:(.text._ZNK5ifopt12ExConstraint9GetValuesEv[_ZNK5ifopt12ExConstraint9GetValuesEv]+0x97): undefined reference to ifopt::Composite::GetComponent(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) const' /tmp/ccexmy3Z.o: In function ifopt::ExConstraint::GetBounds() const':
ex_test_ipopt.cc:(.text._ZNK5ifopt12ExConstraint9GetBoundsEv[_ZNK5ifopt12ExConstraint9GetBoundsEv]+0x25): undefined reference to ifopt::Component::GetRows() const' /tmp/ccexmy3Z.o: In function ifopt::ExConstraint::FillJacobianBlock(std::__cxx11::basic_string<char, std::char_traits, std::allocator >, Eigen::SparseMatrix<double, 1, int>&) const':
ex_test_ipopt.cc:(.text._ZNK5ifopt12ExConstraint17FillJacobianBlockENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERN5Eigen12SparseMatrixIdLi1EiEE[_ZNK5ifopt12ExConstraint17FillJacobianBlockENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERN5Eigen12SparseMatrixIdLi1EiEE]+0x92): undefined reference to ifopt::Composite::GetComponent(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) const' /tmp/ccexmy3Z.o: In function ifopt::CostTerm::~CostTerm()':
ex_test_ipopt.cc:(.text._ZN5ifopt8CostTermD2Ev[_ZN5ifopt8CostTermD5Ev]+0xd): undefined reference to vtable for ifopt::CostTerm' /tmp/ccexmy3Z.o: In function ifopt::ExCost::ExCost(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&)':
ex_test_ipopt.cc:(.text._ZN5ifopt6ExCostC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN5ifopt6ExCostC5ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x1f): undefined reference to ifopt::CostTerm::CostTerm(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' /tmp/ccexmy3Z.o: In function ifopt::ExCost::GetCost() const':
ex_test_ipopt.cc:(.text._ZNK5ifopt6ExCost7GetCostEv[_ZNK5ifopt6ExCost7GetCostEv]+0x68): undefined reference to ifopt::Composite::GetComponent(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) const' /tmp/ccexmy3Z.o: In function ifopt::ExCost::FillJacobianBlock(std::__cxx11::basic_string<char, std::char_traits, std::allocator >, Eigen::SparseMatrix<double, 1, int>&) const':
ex_test_ipopt.cc:(.text._ZNK5ifopt6ExCost17FillJacobianBlockENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERN5Eigen12SparseMatrixIdLi1EiEE[_ZNK5ifopt6ExCost17FillJacobianBlockENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERN5Eigen12SparseMatrixIdLi1EiEE]+0x92): undefined reference to ifopt::Composite::GetComponent(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) const' /tmp/ccexmy3Z.o: In function ifopt::Ipopt::Ipopt()':
ex_test_ipopt.cc:(.text._ZN5ifopt5IpoptC2Ev[_ZN5ifopt5IpoptC5Ev]+0x1a): undefined reference to vtable for ifopt::Ipopt' /tmp/ccexmy3Z.o:(.rodata._ZTVN5ifopt6ExCostE[_ZTVN5ifopt6ExCostE]+0x20): undefined reference to ifopt::CostTerm::GetValues() const'
/tmp/ccexmy3Z.o:(.rodata._ZTVN5ifopt6ExCostE[_ZTVN5ifopt6ExCostE]+0x28): undefined reference to ifopt::CostTerm::GetBounds() const' /tmp/ccexmy3Z.o:(.rodata._ZTVN5ifopt6ExCostE[_ZTVN5ifopt6ExCostE]+0x38): undefined reference to ifopt::ConstraintSet::GetJacobian() const'
/tmp/ccexmy3Z.o:(.rodata._ZTVN5ifopt6ExCostE[_ZTVN5ifopt6ExCostE]+0x40): undefined reference to ifopt::Component::Print(double) const' /tmp/ccexmy3Z.o:(.rodata._ZTVN5ifopt12ExConstraintE[_ZTVN5ifopt12ExConstraintE]+0x38): undefined reference to ifopt::ConstraintSet::GetJacobian() const'
/tmp/ccexmy3Z.o:(.rodata._ZTVN5ifopt12ExConstraintE[_ZTVN5ifopt12ExConstraintE]+0x40): undefined reference to ifopt::Component::Print(double) const' /tmp/ccexmy3Z.o:(.rodata._ZTVN5ifopt11ExVariablesE[_ZTVN5ifopt11ExVariablesE]+0x40): undefined reference to ifopt::Component::Print(double) const'
/tmp/ccexmy3Z.o:(.rodata._ZTVN5ifopt11VariableSetE[_ZTVN5ifopt11VariableSetE]+0x40): undefined reference to ifopt::Component::Print(double) const' /tmp/ccexmy3Z.o:(.rodata._ZTIN5ifopt6ExCostE[_ZTIN5ifopt6ExCostE]+0x10): undefined reference to typeinfo for ifopt::CostTerm'
/tmp/ccexmy3Z.o:(.rodata._ZTIN5ifopt12ExConstraintE[_ZTIN5ifopt12ExConstraintE]+0x10): undefined reference to typeinfo for ifopt::ConstraintSet' /tmp/ccexmy3Z.o:(.rodata._ZTIN5ifopt11VariableSetE[_ZTIN5ifopt11VariableSetE]+0x10): undefined reference to typeinfo for ifopt::Component'
/tmp/ccexmy3Z.o: In function ifopt::Composite::~Composite()': ex_test_ipopt.cc:(.text._ZN5ifopt9CompositeD2Ev[_ZN5ifopt9CompositeD5Ev]+0xd): undefined reference to vtable for ifopt::Composite'
/tmp/ccexmy3Z.o: In function ifopt::Ipopt::~Ipopt()': ex_test_ipopt.cc:(.text._ZN5ifopt5IpoptD2Ev[_ZN5ifopt5IpoptD5Ev]+0xd): undefined reference to vtable for ifopt::Ipopt'
collect2: error: ld returned 1 exit status

Internal representation of optimization variables

The idea of an internal representation sounds very useful. And I pretend to use something as polynomials or a Fourier series. However, I can't see how to access this representation from the Cost class, for example. For that reason, I fail to see its overall usefulness.

Could anyone exemplify the use of the internal representation of the optimization variables?

Eliminating initialization overhead on snopt

I am solving a series of near optimal solutions (i.e. the problem is identical except the initial condition and the initial trajectory guess). I notice that ever time I use the ::Solve(*nlp) function using the snopt76 adapter, SNOPT re-initializes (i.e. checks how many derivatives were defined etc.). Is there a way to simply call "solve" again once the initial conditions have been changed without this initialization?

Convex MPC with ifopt

Hi,

I wanted to know if you have any thoughts on using ifopt to solve convex MPC problems. For example, would you be able to use this architecture to solve the MPC problem in the MIT Cheetah (and mini Cheetah), and use Gazebo as the simulation platform? I'd love to give this a shot!

Cheetah Paper
https://doi.org/10.1109/IROS.2018.8594448

Thank!

Project status

Hi there!
I'm thinking of using ifopt for

https://github.com/eike-fokken/grazer

as we now want to implement optimization.
And I must say, using Eigen types seems much nicer than the C-style pointers in the ipopt interface.
But from the issue list, the project seems to be a bit quiet since January. Do you expect that to change and if not, has anyone recommendations on whether to use ifopt regardless vs. using the ipopt interface directly?

ifopt_snopt-example throws Exception

Hi,

Although I changed the code as suggested in #31 for those who are having issues with the snopt v7.6, still make test fails:

Exception: Child aborted ...
The following tests FAILED:
2 - ifopt_snopt-example (Child aborted)
Errors while running CTest

Do you have any ideas why changing

setUserFun(&SnoptAdapter::ObjectiveAndConstraintFct);

to

// setUserFun(&SnoptAdapter::ObjectiveAndConstraintFct);
this->initialize("print_file.out",1);

and set(SNOPT_v76 TRUE) in ifopt_snopt/cmake/FindSNOPT.cmake is enough to make IFOPT compile and link correctly but not to pass the test?

As an additional information, I am linking to the compiled SNOPT libraries and adding the include directory from https://github.com/snopt/snopt-interface.

Thank you,
Barbara

Runtime error: Assertion `nele == nele_jac' failed

Ran into this problem while doing some optimisations on dynamic systems with IFOPT (not Towr, but something very similar).

When the optimisation starts I get the message:

Gambol: /fopt/ifopt_ipopt/src/ipopt_adapter.cc:139: virtual bool Ipopt::IpoptAdapter::eval_jac_g(Ipopt::Index, const double, bool, Ipopt::Index, Ipopt::Index, Ipopt::Index*, Ipopt::Index*, double*): Assertion nele == nele_jac' failed.

This for a problem with an exact constraint jacobian.

I looked at the source and saw this assertion fails when the number of assigned elements in the jacobian construction does not equal the expected number of non-zeros (nele_jac).
I also noticed that IFOPT finds nele_jac inside get_nlp_info() by executing the constraint jacobian and looking at the result. This makes it all the more strange that I should encounter this problem.

The jacobian section is case is being built by multiplying a fixed SparseMatrix with a jacobian calculated by a variable itself. (Vague, I know, but I'm a bit too embarrassed to share the entire code.)

Thank you!

Return codes for Solver

Solver interface does not provides any means to check solver exit code.

I can see two ways to solve this issue:

  1. Add solver specific methods to IpoptSolver and SnoptSolver classes. (it can be something like this
  2. Introduce a set of "common exit codes". So solver specific exit code is translated to common exit code which can be returned from Solve().

defining equaility constraints

Hello.
I use ifopt for path planning for self-driving vehicles. Make a nonlinear predictive problem with ifopt.

I'm not familiar with ifopt yet....
How can I make custom equality constraints for a discretized kinematic model?
I'm trying to modify test_vars_constr_cost.h file now.
For example, I want to define a problem with a prediction horizon for 5 steps, 4 states, and 2 control inputs, put 30 variables total for now. (In ExVariable Class, define x0_ to x24_). So if I have a discretized kinematic vehicle model as,
x_{k+1} = x_{k} + dt * v_{k} * cos(phi_{k})
y_{k+1} = y_{k} + dt * v_{k} * sin(phi_{k})
phi_{k+1} = phi_{k} + dt * v_{k} * tan(delta_{k}) / L
v_{k+1} = v{k} + dt * a{k}

then, I can define like this way.
x_{0} -> x(0), y_{0} -> x(1), ..., x_{1} -> x(6), y_{1} -> x(7),...

However, is there a way to define the time step of variables and constraints (prediction horizon in this case), not by modifying the header file in advance? I don't want to remove and add all these variables, constraints, and costs when I change the prediction horizons.

Thank you so much!

History related to the creation versus using existing Optmization Interface Libraries?

Hello,

I have been integrating TrajOpt into ROS which came with its own optimization interface library and I am looking at replacing it with one that is currently available like IFOPT. I have been researching and there are several of them available like COIN-OR, CasADI, etc.. I am interested in using this package as it replacement and I am interested to learn how this compares to others. I have no familiarity with any of the packages at the moment, but I assumed you might and any information would be helpful?

Thank you

ifopt-config.cmake error on Windows

I am getting the following error when calling 'find_package()' for ifopt:

CMake Error at C:/ws/conda-bld/tesseract-robotics-superpack_1626912746269/_h_env/opt/tesseract_robotics/share/ifopt/cmake/ifopt-config.cmake:47 (get_property):
  IMPORTED_LOCATION not set for imported target "ifopt::ifopt_core".
Call Stack (most recent call first):
  CMakeLists.txt:12 (find_package)

The offending line seems to be here:

get_property(ifopt_LIB_CORE TARGET ifopt::ifopt_core PROPERTY LOCATION)

This make be caused by changes to how newer versions of CMake generate the targets files.

Issues running catkin_make

Hi,

I have updated the CMakeList.txt file to point to the location of my Ipopt installation. Ipopt is working correctly since I have used it with other programs. When I try to run the 'catkin_make' command if get the following error:

[ 75%] Built target ifopt_core make[2]: *** No rule to make target /usr0/home/rshu/libraries/CoinIpopt/build/lib/libipopt.so, needed by /usr0/home/rshu/catkin_ws_sandbox2/devel/lib/libifopt_ipopt.so. Stop. make[1]: *** [ifopt/ifopt_ipopt/CMakeFiles/ifopt_ipopt.dir/all] Error 2 make: *** [all] Error 2

any suggestions why this could be?

Thank you,
Roberto

SNOPT Derivative option 0

How can I use ifopt to interface with snopt without assigning values to the Jacobian?

I found in ifopt/ifopt_ipopt/src/snopt_solver.cc:
snopt.setIntParameter( "Derivative option", 1)
which I can replace by snopt.setIntParameter( "Derivative option", 0).

However, if I leave the FillJacobianBlock function of the constraint class empty (as I can do when I set "jacobian_approximation" to "finite-difference-values" with ipopt), I get WARNINGs saying that the Jacobian is empty and no solution is found.
What should I do to solve this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.