[Ipopt] Optimal control problem (discretize and c++ inerface)

Antonello Lobianco antonello at lobianco.org
Thu Sep 15 02:10:06 EDT 2016


For an other solution that uses IPOPT as the solver engine and the Pyomo
library (in Python) to code the model see this thread:
https://groups.google.com/forum/#!searchin/pyomo-forum/optimal$20control|sort:relevance/pyomo-forum/zLDbnrY2OJc/vYIL6u_-BwAJ



On 14 September 2016 at 19:08, Joel Andersson <j.a.e.andersson at gmail.com>
wrote:

> Hi Pablo!
>
> Since you're interested in optimal control, you might want to have a look
> at our tool CasADi (http://casadi.org
> <https://urldefense.proofpoint.com/v2/url?u=http-3A__casadi.org&d=CwMFaQ&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=8oTnxj08sd2ffhbFEprcyo6DDTVDvo_DCJ2aU6CdYWE&m=RBLqMC9Av60yHWVeArfuoN15iLaMbfnkMx7CMFP_q00&s=GdEnQA3V6aYNeNeCpVP8VG8fZPonmzcbwTV3LZDFWe4&e=>),
> which is an optimization modeling environment with focus on optimal control.
>
> Here is an example that shows how to do more or less exactly what you're
> describing:
>
> https://github.com/casadi/casadi/blob/master/docs/
> examples/cplusplus/rocket_mx_and_sx.cpp
> <https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_casadi_casadi_blob_master_docs_examples_cplusplus_rocket-5Fmx-5Fand-5Fsx.cpp&d=CwMFaQ&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=8oTnxj08sd2ffhbFEprcyo6DDTVDvo_DCJ2aU6CdYWE&m=RBLqMC9Av60yHWVeArfuoN15iLaMbfnkMx7CMFP_q00&s=NJRmnQAnjenOi-0SVR1pQ4PrxeULX8H5ZdPDeUrpOWU&e=>
>
> That is an Euler method discretization for time and then solved with IPOPT
> via the CasADi interface (which takes care of all derivative calculations).
>
> There are other more efficient ways of solving this problem, however.
> Especially if you're using IPOPT, it's better to use a "simultaneous
> approach" and include the entire state trajectory as decision variables
> instead of the "sequential approach" in the linked example. You should also
> consider replacing your Euler scheme with something of higher order - that
> will allow you to get the same accuracy with a more crude time
> discretization. I would recommend a collocation type integrator scheme (a
> type of implicit Runge-Kutta methods popular in optimal control) or if
> you're system is non-stiff, you can also consider the the classical
> (explicit) Runge-Kutta 4 scheme. Biegler's "Nonlinear Programming:
> Concepts, Algorithms, and Applications to Chemical Processes" is an
> excellent reference: http://epubs.siam.org/doi/
> book/10.1137/1.9780898719383
> <https://urldefense.proofpoint.com/v2/url?u=http-3A__epubs.siam.org_doi_book_10.1137_1.9780898719383&d=CwMFaQ&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=8oTnxj08sd2ffhbFEprcyo6DDTVDvo_DCJ2aU6CdYWE&m=RBLqMC9Av60yHWVeArfuoN15iLaMbfnkMx7CMFP_q00&s=Do-Ah-ef9vNNEu_uPTymlWeveMwSLdgFonWjpd4eAKc&e=>.
> You'll find implementations of these methods in CasADi.
>
> Also note that you don't necessarily need to do the modeling in C++ even
> if you're planning to do solve it online in an environment that only has
> C++. If you're using AMPL, you can can use the AMPL executable to simply to
> parse the problem and generate a ".nl" file. This file would then be read
> by the open-source AMPL Solver Library, which is pure C and easy to embed.
> If you're using CasADi as a modeling environment, you can do the modeling
> in Python or MATLAB and have CasADi generate C code for the function calls,
> including first and second order derivative information. It can then be run
> on an embedded system in a minimalistic CasADi-IPOPT environment.
>
> Best regards,
> Joel
>
>
> 2016-09-14 8:35 GMT-05:00 Pablo Perez <pabloperez555 at hotmail.com>:
>
>> Dear all,
>>
>> after having discovered Ipopt last month, I have thought using it in my
>> academic research for optimizing the power use of a dynamic of a point mass
>> train.
>>
>> Due to the optimal control nature of the problem, I understand that the
>> problem must be discretized (by an Euler method, pe). The problem has the
>> next structure:
>>
>> min J(x, u) = Integral[0, T](f(x, u)·dt);
>> dx/dt = y(x, u);
>> g(x, u) >= K;
>> x_min <= x <= x_max;
>> u_min <= u <= u_max;
>> x(0) = x0;
>>
>> I have test and understand the examples provided with Ipopt and other
>> users, but all of them are about continuos time problems. The only discrete
>> systems problems I have found are used throught AMPL interface mostly, but
>> I would like using Ipopt throught the C++ interface because it should be
>> embeded within a standalone application.
>>
>> Please, does anyone knows of some link where there aer an example of how
>> to use Ipopt with a discretized system using c++ interface? Might anybody
>> provide me with any source code example?
>>
>> Best regards,
>> Pablo
>>
>> _______________________________________________
>> Ipopt mailing list
>> Ipopt at list.coin-or.org
>> https://urldefense.proofpoint.com/v2/url?u=http-3A__list.coi
>> n-2Dor.org_mailman_listinfo_ipopt&d=CwICAg&c=Ngd-ta5yRYsqe
>> UsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=OtjwlDFa50ew9RXNsKUjcD
>> YXBipGc0uQDVH_0daPLFk&m=EVZY3slpC56CA2pzk9y1rGYqC9FTWeGeR0vY
>> 6pONZAA&s=19a6i0ofgIF1oDAvpq3MaUg30PUmRSLFdgJjL7B-kEw&e=
>>
>>
>
> _______________________________________________
> Ipopt mailing list
> Ipopt at list.coin-or.org
> https://urldefense.proofpoint.com/v2/url?u=http-3A__list.
> coin-2Dor.org_mailman_listinfo_ipopt&d=CwICAg&c=Ngd-
> ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=8oTnxj08sd2ffhbFEprcyo6DDTVDvo
> _DCJ2aU6CdYWE&m=RBLqMC9Av60yHWVeArfuoN15iLaMbf
> nkMx7CMFP_q00&s=5IB71TBmk-Eg-mNDJ6CrCVdf8do44GFQkwWwMwQLXbk&e=
>
>


-- 
Antonello Lobianco
AgroParisTech, Laboratoire d'Economie Forestière
14 Rue Girardet - 54000 Nancy, France
Tel: +33.383396865
Email: antonello.lobianco at nancy.inra.fr
http://antonello.lobianco.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/ipopt/attachments/20160915/9a1ce146/attachment.html>


More information about the Ipopt mailing list