<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'><div>Hi,</div><div><br></div><div>First of all, thank you very much to you all for your soon answer, they have provided me with a new focus about my problem.</div><div><br></div><div>For solving this problem I have been using until now a dynamic programming method, which always finds a global minimun and does not present convergency issues, but it is very slow and memory gready for allowing use it within an embeded device. So I wish like to migrate from "computer methods" to mathematical ones.</div><div><br></div><div>About using a third party framework, for personal reasons I would like to use as many open source software as possible, so I have discarded AMPL for being propietary code. Anyway, CasADi is an open source project with LGPL license, and the few time I have been looking it this morning makes me think it is an awesome tool, and I would like to use it for fast prototyping and test checks. Thank you Joel for your efforts developing and spreading it.</div><div><br></div>About using the Euler method (RK1 method), it is only for a first version of the program. In next development I was thinking about use higher order methods, as midpoint or RK4. About simultaneus approach, I also was thinking about using it, even I have only very limited knowledge about optimal control. I will check the Biegler's book and look to the example in "Ipopt-3.12.6\Ipopt\tutorial\CodingExercise\Cpp\3-solution" for knowing more about this subject.<div><br></div><div>About using c++, it is because is the language I better know. I would like to implement all the problem using the Ipopt c++ interface, including the hessian derivatives. In a second approach, I let Ipopt calculate them using the "hessian_approximation->limited-memory" option in code. And finally, i would like to implement the problem using Casadi an use the C source code within my own program, so I can test performance between the three options.</div><div><br></div><div>Please, Joel, may you tell me is Casadi can be used directly with "#include <casadi/casadi.hpp>" as in the example you sent to me for defining the problem in the same way as Ipopt does? It is because I am not proficiency in python neither in matlab...</div><div><br></div><div>Best regards,</div><div>Pablo<br><br><br><br><div><hr id="stopSpelling">From: antonello@lobianco.org<br>Date: Thu, 15 Sep 2016 08:10:06 +0200<br>Subject: Re: [Ipopt] Optimal control problem (discretize and c++ inerface)<br>To: j.a.e.andersson@gmail.com<br>CC: pabloperez555@hotmail.com; ipopt@list.coin-or.org<br><br><div dir="ltr">For an other solution that uses IPOPT as the solver engine and the Pyomo library (in Python) to code the model see this thread:<br><a href="https://groups.google.com/forum/#%21searchin/pyomo-forum/optimal$20control%7csort:relevance/pyomo-forum/zLDbnrY2OJc/vYIL6u_-BwAJ" target="_blank">https://groups.google.com/forum/#!searchin/pyomo-forum/optimal$20control|sort:relevance/pyomo-forum/zLDbnrY2OJc/vYIL6u_-BwAJ</a><br><br><br> </div><div class="ecxgmail_extra"><br><div class="ecxgmail_quote">On 14 September 2016 at 19:08, Joel Andersson <span dir="ltr"><<a href="mailto:j.a.e.andersson@gmail.com" target="_blank">j.a.e.andersson@gmail.com</a>></span> wrote:<br><blockquote class="ecxgmail_quote" style="border-left:1px #ccc solid;padding-left:1ex;"><div dir="ltr">Hi Pablo!<div><br></div><div>Since you're interested in optimal control, you might want to have a look at our tool CasADi (<a href="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=" target="_blank">http://casadi.org</a>), which is an optimization modeling environment with focus on optimal control.</div><div><br></div><div>Here is an example that shows how to do more or less exactly what you're describing:</div><div><br></div><div><a href="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=" target="_blank">https://github.com/casadi/<wbr>casadi/blob/master/docs/<wbr>examples/cplusplus/rocket_mx_<wbr>and_sx.cpp</a></div><div><br></div><div>That is an Euler method discretization for time and then solved with IPOPT via the CasADi interface (which takes care of all derivative calculations).</div><div><br></div><div>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: <a href="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=" target="_blank">http://epubs.siam.org/doi/<wbr>book/10.1137/1.9780898719383</a>. You'll find implementations of these methods in CasADi.</div><div><br></div><div>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.</div><div><br></div><div>Best regards,</div><div>Joel</div><div><br></div><div class="ecxgmail_extra">
<br><div class="ecxgmail_quote"><div><div class="h5">2016-09-14 8:35 GMT-05:00 Pablo Perez <span dir="ltr"><<a href="mailto:pabloperez555@hotmail.com" target="_blank">pabloperez555@hotmail.com</a>></span>:<br></div></div><blockquote class="ecxgmail_quote" style="border-left:1px #ccc solid;padding-left:1ex;"><div><div class="h5">


<div><div dir="ltr">Dear all,<div><br></div><div>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.</div><div><br></div><div>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:</div><div><br></div><div>min J(x, u) = Integral[0, T](f(x, u)·dt);</div><div>dx/dt = y(x, u);</div><div>g(x, u) >= K;</div><div>x_min <= x <= x_max;</div><div>u_min <= u <= u_max;</div><div>x(0) = x0;</div><div><br></div><div>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.</div><div><br></div><div>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?</div><div><br></div><div>Best regards,</div><div>Pablo</div>                                        </div></div>
<br></div></div>______________________________<wbr>_________________<br>
Ipopt mailing list<br>
<a href="mailto:Ipopt@list.coin-or.org" target="_blank">Ipopt@list.coin-or.org</a><br>
<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__list.coin-2Dor.org_mailman_listinfo_ipopt&d=CwICAg&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=OtjwlDFa50ew9RXNsKUjcDYXBipGc0uQDVH_0daPLFk&m=EVZY3slpC56CA2pzk9y1rGYqC9FTWeGeR0vY6pONZAA&s=19a6i0ofgIF1oDAvpq3MaUg30PUmRSLFdgJjL7B-kEw&e=" rel="noreferrer" target="_blank">https://urldefense.proofpoint.<wbr>com/v2/url?u=http-3A__list.coi<wbr>n-2Dor.org_mailman_listinfo_<wbr>ipopt&d=CwICAg&c=Ngd-ta5yRYsqe<wbr>UsEDgxhcqsYYY1Xs5ogLxWPA_<wbr>2Wlc4&r=OtjwlDFa50ew9RXNsKUjcD<wbr>YXBipGc0uQDVH_0daPLFk&m=EVZY3s<wbr>lpC56CA2pzk9y1rGYqC9FTWeGeR0vY<wbr>6pONZAA&s=19a6i0ofgIF1oDAvpq3M<wbr>aUg30PUmRSLFdgJjL7B-kEw&e=</a><br>
<br></blockquote></div><br></div></div>
<br>______________________________<wbr>_________________<br>
Ipopt mailing list<br>
<a href="mailto:Ipopt@list.coin-or.org">Ipopt@list.coin-or.org</a><br>
<a href="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=RBLqMC9Av60yHWVeArfuoN15iLaMbfnkMx7CMFP_q00&s=5IB71TBmk-Eg-mNDJ6CrCVdf8do44GFQkwWwMwQLXbk&e=" rel="noreferrer" target="_blank">https://urldefense.proofpoint.<wbr>com/v2/url?u=http-3A__list.<wbr>coin-2Dor.org_mailman_<wbr>listinfo_ipopt&d=CwICAg&c=Ngd-<wbr>ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLx<wbr>WPA_2Wlc4&r=<wbr>8oTnxj08sd2ffhbFEprcyo6DDTVDvo<wbr>_DCJ2aU6CdYWE&m=<wbr>RBLqMC9Av60yHWVeArfuoN15iLaMbf<wbr>nkMx7CMFP_q00&s=5IB71TBmk-Eg-<wbr>mNDJ6CrCVdf8do44GFQkwWwMwQLXbk<wbr>&e=</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br><div class="ecxgmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Antonello Lobianco<br>AgroParisTech, Laboratoire d'Economie Forestière<br>14 Rue Girardet - 54000 Nancy, France<br>Tel: +33.383396865<br>Email: <a href="mailto:antonello.lobianco@nancy.inra.fr" target="_blank">antonello.lobianco@nancy.inra.fr</a><br><a href="http://antonello.lobianco.org/" target="_blank">http://antonello.lobianco.org</a></div></div>
</div></div></div>                                      </div></body>
</html>