<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
.MsoChpDefault
{mso-style-type:export-only;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style></head><body lang=EN-US link=blue vlink="#954F72"><div class=WordSection1><p class=MsoNormal>You can also have a look at CasADi which is fast, and easy to use from python, matlab, and also usable from c++.</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Jonas</p><p class=MsoNormal><o:p> </o:p></p><div style='mso-element:para-border-div;border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal style='border:none;padding:0in'><b>From: </b><a href="mailto:stefan@math.hu-berlin.de">Stefan Vigerske</a><br><b>Sent: </b>Tuesday, April 30, 2019 5:09 AM<br><b>To: </b><a href="mailto:opc.fan.2018@gmail.com">To To</a><br><b>Cc: </b><a href="mailto:ipopt@list.coin-or.org">ipopt@list.coin-or.org</a><br><b>Subject: </b>Re: [Ipopt] Huge number of variables problem</p></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Hi,</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>if-else and for-loops are not incompatible to each other in general.</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>ADOL-C and CppAD are C++ AD tools that provide specialized interfaces to </p><p class=MsoNormal>Ipopt.</p><p class=MsoNormal>See also the list at https://urldefense.proofpoint.com/v2/url?u=https-3A__coin-2Dor.github.io_Ipopt_index.html-23HOWTOUSE&d=DwICAg&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=2rscMOYKChjkbdHadHebHWj9J-ZdIUzDBZGUV2uBLc8&m=Now9Vz83DsXDOxlV_DCpaUstibK4FssnSoR49vzG_-I&s=DM2MG9qj8LcnQgVjCowg1kDx-n8F-5m7bjVGnqGrBEw&e=</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Stefan</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>On 4/29/19 6:53 PM, To To wrote:</p><p class=MsoNormal>> Hi Stefan,</p><p class=MsoNormal>> </p><p class=MsoNormal>> Thank you for your suggestion. It was found that the evaluation of jacobian</p><p class=MsoNormal>> of constraints took too much time, and it was due to the if-else used in</p><p class=MsoNormal>> the for-loop when forming the jacobian. Another version of jacobian was</p><p class=MsoNormal>> done without any if-else, then the evaluation of jacobian becomes much much</p><p class=MsoNormal>> quicker. For now, it was shown that the searching direction calculation</p><p class=MsoNormal>> take most of the time (which is supposed to be I guess?), all function and</p><p class=MsoNormal>> derivative evaluations take very little time.</p><p class=MsoNormal>> </p><p class=MsoNormal>> May I ask is this simply due to the extra calls of if-else that costs much</p><p class=MsoNormal>> more time? Or some other mechanism related with C++ when including if-else</p><p class=MsoNormal>> in the for loop?</p><p class=MsoNormal>> </p><p class=MsoNormal>> Moreover, is that possible to use automatic differentiation tools to</p><p class=MsoNormal>> generate source transformation codes for jacobian and hessian? I tried some</p><p class=MsoNormal>> AD tools using operator overloading, but with large number of variables</p><p class=MsoNormal>> these tools crash often. If possible, could you recommend AD tools with</p><p class=MsoNormal>> source transformation to be used with IPOPT C++ interface?</p><p class=MsoNormal>> </p><p class=MsoNormal>> Thank you very much.</p><p class=MsoNormal>> </p><p class=MsoNormal>> On Mon, Apr 29, 2019 at 4:36 AM Stefan Vigerske <stefan@math.hu-berlin.de></p><p class=MsoNormal>> wrote:</p><p class=MsoNormal>> </p><p class=MsoNormal>>> Hi,</p><p class=MsoNormal>>><o:p> </o:p></p><p class=MsoNormal>>> loops are ok, as long as you use them efficiently.</p><p class=MsoNormal>>> You can run Ipopt with option print_timing_statistics set to yes to get</p><p class=MsoNormal>>> more information about where time is spend.</p><p class=MsoNormal>>><o:p> </o:p></p><p class=MsoNormal>>> Stefan</p><p class=MsoNormal>>><o:p> </o:p></p><p class=MsoNormal>>> On 4/28/19 8:15 PM, To To wrote:</p><p class=MsoNormal>>>> Dear all,</p><p class=MsoNormal>>>><o:p> </o:p></p><p class=MsoNormal>>>> I'm using IPOPT 3.12.12 with the provided C++ interface under Ubuntu</p><p class=MsoNormal>>> 18.04.</p><p class=MsoNormal>>>> I formulated a relatively simple NLP and it works.</p><p class=MsoNormal>>>><o:p> </o:p></p><p class=MsoNormal>>>> I am totally new to C++, so I form my constraint and jacobian all with</p><p class=MsoNormal>>> for</p><p class=MsoNormal>>>> loop. May I ask is it the best way to formulate constraints and jacobian</p><p class=MsoNormal>>>> using for loop? I tired to increase the number of NLP variables to around</p><p class=MsoNormal>>>> 300000, and I have around 200000 constraints (very sparse). I found that</p><p class=MsoNormal>>> it</p><p class=MsoNormal>>>> is very slow when computing.</p><p class=MsoNormal>>>><o:p> </o:p></p><p class=MsoNormal>>>> Should I be careful when forming such a big problem with provided C++</p><p class=MsoNormal>>>> interface? Or should I use some other libraries such as EIGEN to better</p><p class=MsoNormal>>>> form the jacobian?</p><p class=MsoNormal>>>><o:p> </o:p></p><p class=MsoNormal>>>> Thank you very much.</p><p class=MsoNormal>>>><o:p> </o:p></p><p class=MsoNormal>>>><o:p> </o:p></p><p class=MsoNormal>>>> _______________________________________________</p><p class=MsoNormal>>>> Ipopt mailing list</p><p class=MsoNormal>>>> Ipopt@list.coin-or.org</p><p class=MsoNormal>>>> https://urldefense.proofpoint.com/v2/url?u=https-3A__list.coin-2Dor.org_mailman_listinfo_ipopt&d=DwICAg&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=2rscMOYKChjkbdHadHebHWj9J-ZdIUzDBZGUV2uBLc8&m=Now9Vz83DsXDOxlV_DCpaUstibK4FssnSoR49vzG_-I&s=uoRQHPGXADVFfy-Ko7MHY3kmdUS7kgWU23_9wq7yPhY&e=</p><p class=MsoNormal>>>><o:p> </o:p></p><p class=MsoNormal>>><o:p> </o:p></p><p class=MsoNormal>>><o:p> </o:p></p><p class=MsoNormal>> </p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>_______________________________________________</p><p class=MsoNormal>Ipopt mailing list</p><p class=MsoNormal>Ipopt@list.coin-or.org</p><p class=MsoNormal>https://urldefense.proofpoint.com/v2/url?u=https-3A__list.coin-2Dor.org_mailman_listinfo_ipopt&d=DwICAg&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=2rscMOYKChjkbdHadHebHWj9J-ZdIUzDBZGUV2uBLc8&m=Now9Vz83DsXDOxlV_DCpaUstibK4FssnSoR49vzG_-I&s=uoRQHPGXADVFfy-Ko7MHY3kmdUS7kgWU23_9wq7yPhY&e=</p><p class=MsoNormal><o:p> </o:p></p></div></body></html>