[Ipopt] IPOpt in C++: incorporating data into MyNLB ....

Stefan Vigerske stefan at math.hu-berlin.de
Fri Nov 12 10:31:20 EST 2010


Hi,

try
  SmartPtr<MyNLP> mynlp = new MyNLP();
  mynlp->Data.Initialize(job, model);
and later when giving mynlp to Ipopt's Optimize() function, use
Optimize(GetRawPtr(mynlp)).

Stefan

Andreas Baumgart wrote:
>   Dear All,
> 
> I am employing IPOpt for larger problems and have to read data from a 
> file to be passed to IPOpt.
> However, I have not managed to do it properly yet. Here is what I would 
> like to do:
> 
> I have included a class CData in your MyNLP (see snippet c) below),
> which has an Initialize()-method (see snippet b)).
> 
> The compiler comes back with the message "no member named 'Data' (see 
> snippet a)).
> I have only found examples with explicit direct declaration of problems.
> What am I doing wrong? Is it related to the public / private part (which 
> I don't understand)?
> And then: how do I get my data into your mynlp instance?
> 
> Best regards and many thanks,
> 
> Andreas
> 
> 
> a)
> begin 
> snippet:++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> In function "int main(int, char**)":
> [...]: error: class Ipopt::SmartPtr<Ipopt::TNLP> has no member named "Data"
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++:end 
> snippet
> 
> b)
> begin 
> snippet:++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>    SmartPtr<TNLP> mynlp = new MyNLP();
>    mynlp.Data.Initialize(job, model);   // I also tried 
> mynlp->Data.Initialize(job, model);
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++:end 
> snippet
> 
> c)
> begin 
> snippet:++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> // $Id: MyNLP.hpp 949 2007-03-27 00:41:26Z andreasw $
> // Authors:  Carl Laird, Andreas Waechter     IBM    2004-11-05
>   [...]
> class MyNLP : public TNLP
> {
> public:
> 
>    /* data */
>    CData Data;
> 
>    /** default constructor */
>    MyNLP();
> 
>   [...]
> }
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++:end 
> snippet
> 
> _______________________________________________
> Ipopt mailing list
> Ipopt at list.coin-or.org
> http://list.coin-or.org/mailman/listinfo/ipopt
> 


-- 
Stefan Vigerske
Humboldt University Berlin, Numerical Mathematics
http://www.math.hu-berlin.de/~stefan



More information about the Ipopt mailing list