[Ipopt] Trying to run IPOPT C++ example

Stefan Vigerske stefan at math.hu-berlin.de
Fri Aug 25 08:15:29 EDT 2017


Hi,

On 08/24/2017 04:50 AM, Wendel Melo wrote:
>> Do I need AMPL for the example?
> 
> No.
> 
>> Am I linking the files correctly?
> 
> No. I think the best way to do it is using the Makefile in the directory
> ${your_ipopt_build_path}/Ipopt/examples/hs071_cpp/.
> 
> You just have to do simple changes (e.g. the EXE and OBJS definitions).
> You can take advantage this Makefile to build all your applications using
> C++ interface.
> 
>> Is there a 'bare bones' C++ example that doesn't use smart pointers or
> the IpoptApplicationFactory?
> 
> I am not sure, but I think IpoptApplicationFactory is really necessary in
> the C++ interface. I believe it is possible adopt no smart pointers.

IpoptApplicationFactory() just calls "new Ipopt::IpoptApplication", so 
you can also call that directly.

The smart pointers are essential, though.
You can use the C-interface wrapper if you don't want to see them.

Stefan



> 
> 
> Regards
> 
> Wendel
> 
> 
> 
> 
> 
> 2017-08-23 23:26 GMT-03:00 Alexander Martinez-Marchese <
> alex.martinezmarchese at outlook.com>:
> 
>> Hi,
>>
>>
>>        I'm trying to run the C++ example described here:
>>
>>
>> https://urldefense.proofpoint.com/v2/url?u=https-3A__www.coin-2Dor.org_Ipopt_documentation_node23.html&d=DwIFaQ&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=BRcuJnQr5NAzU29t80hk2rsLc4vrlRySBDabuq0O1ZI&m=lMw4bh0b5GmfjEdi_56b6J05tnUVIpMEFuDjBMDeXbg&s=p9G0iegcD8TY33BZ5PhyovzALz9lVAmd4BF6zBWG_lo&e=
>> <https://urldefense.proofpoint.com/v2/url?u=https-3A__www.coin-2Dor.org_Ipopt_documentation_node23.html&d=DwMFAw&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=AEWIZiNSSlppb_jyQKA8GtHkg2N4WiI7Ya5btonYBgA&m=ZQeH40ZHG9NwfMsxzGOm9crFiwZNdbp1D-HraEXQENU&s=VQRxhgqUJI4BKSd1gNC312YC5Bio3XpnudRchOg1kaY&e=>
>>
>>
>>
>> So I copied the files myexample.cpp, hs071_nlp.cpp and hs071_nlp.cpp and I
>> run the following in the terminal (within Ubuntu linux):
>>
>>
>> c++ -std=c++11 myexample.cpp hs071_nlp.cpp -o myexample -I
>> /home/alex/Ipopt-3.12.8/include/coin
>>
>>
>> And I get the following error:
>>
>>
>> /tmp/ccIUQtXB.o: In function `main':
>> myexample.cpp:(.text+0x52): undefined reference to
>> `IpoptApplicationFactory'
>> collect2: error: ld returned 1 exit status
>>
>>
>>
>> I tested my IPOPT installation using 'make test' and I get this:
>>
>>
>> Running unitTests...
>> Testing AMPL Solver Executable...
>>      no AMPL solver executable found, skipping test...
>> Testing C++ Example...
>>      Test passed!
>> Testing C Example...
>>      Test passed!
>> Testing Fortran Example...
>>      Test passed!
>> make[2]: Leaving directory '/home/alex/Ipopt-3.12.8/Ipopt/test'
>> make[1]: Leaving directory '/home/alex/Ipopt-3.12.8/Ipopt'
>>
>> Do I need AMPL for the example? Am I linking the files correctly? Is there
>> a 'bare bones' C++ example that doesn't use smart pointers or the
>> IpoptApplicationFactory?
>>
>>
>> I am able to use IPOPT from pyipopt to solve l-bfgs-b problems. The IPOPT
>> installation was installed with the HSL files:
>> https://urldefense.proofpoint.com/v2/url?u=http-3A__www.hsl.rl.ac.uk_ipopt_&d=DwIFaQ&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=BRcuJnQr5NAzU29t80hk2rsLc4vrlRySBDabuq0O1ZI&m=lMw4bh0b5GmfjEdi_56b6J05tnUVIpMEFuDjBMDeXbg&s=x9HPEd8KCnnVFdkPHKkf4vklNkRjtx_-ppVQU5MheTU&e=
>> <https://urldefense.proofpoint.com/v2/url?u=http-3A__www.hsl.rl.ac.uk_ipopt_&d=DwMFAw&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=AEWIZiNSSlppb_jyQKA8GtHkg2N4WiI7Ya5btonYBgA&m=ZQeH40ZHG9NwfMsxzGOm9crFiwZNdbp1D-HraEXQENU&s=qADmP8Rclh0Q6kTBikgNgeak4Pg5HZyeAGKJt2-o_M0&e=>
>>
>>
>>
>> Thank you,
>>
>> Alex
>>
>>
>>
>>
>>
>> _______________________________________________
>> Ipopt mailing list
>> Ipopt at list.coin-or.org
>> https://urldefense.proofpoint.com/v2/url?u=https-3A__list.
>> coin-2Dor.org_mailman_listinfo_ipopt&d=DwICAg&c=Ngd-
>> ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=AEWIZiNSSlppb_
>> jyQKA8GtHkg2N4WiI7Ya5btonYBgA&m=ZQeH40ZHG9NwfMsxzGOm9crFiwZNdb
>> p1D-HraEXQENU&s=zTRKLH_Pb24IsUPAeBx1kZh0vYqZA9sfNBMwStyYqlA&e=
>>
>>
> 
> 
> 
> 
> _______________________________________________
> Ipopt mailing list
> Ipopt at list.coin-or.org
> https://urldefense.proofpoint.com/v2/url?u=https-3A__list.coin-2Dor.org_mailman_listinfo_ipopt&d=DwICAg&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=BRcuJnQr5NAzU29t80hk2rsLc4vrlRySBDabuq0O1ZI&m=lMw4bh0b5GmfjEdi_56b6J05tnUVIpMEFuDjBMDeXbg&s=UMyu-H7P0tzJZvLkiM2bOH7N7OUT6kQZS_FsBxXNCHQ&e=
> 


-- 
http://www.gams.com/~stefan


More information about the Ipopt mailing list