<HTML>
<HEAD>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META content="OPENWEBMAIL" name=GENERATOR>
</HEAD>
<BODY bgColor=#ffffff>
I ran into the same problem and solved it by having a separate class for the extra member fucntions and passed a point to the extra class to the class derived from TNLP.
<br />
<br />Take a look at the specifications for solution at
<br /> http://www.coin-or.org/CppAD/Doc/ipopt_cppad_nlp.xml#solution
<br />
<br />The implementation from the users point of view is at
<br /> http://www.coin-or.org/CppAD/Doc/ipopt_cppad.cpp.xml
<br />
<br /><font size="2"><b>
<br />On Tue, 1 Jul 2008 07:02:55 -0700 (PDT), Krish Krishnan wrote</b>
<br />> Hi
All:
<br />>
<br />> I have a windows application using MFC to create an
optimized portfolio of common stock. I used the cpp example as a template
and derived my class from TNLP. The difference between my implementation
and that in the example is that I have many new members and a few more functions
(to access data in databases ) etc.
<br />>
<br />> When I try to compile this,
the compiler complains that the new data members are not part of the TNLP class.
For example some of the error messages are below:
<br />>
<br />>
rojects\bmopt\bmopt\createcase.cpp(262) : error C2039: 'm_caseFileName' : is not
a member of 'Ipopt::TNLP'
<br />> 1>
c:\optdir\iptnlp.hpp(48) : see declaration of 'Ipopt::TNLP'
<br />>
1>c:\documents and
settings\kris\my
documents\projects\bmopt\bmopt\createcase.cpp(264) : error C2039:
'm_assetBoundsDB' : is not a member of 'Ipopt::TNLP'
<br />> 1>
c:\optdir\iptnlp.hpp(48) : see declaration of
'Ipopt::TNLP'
<br />> 1>c:\documents and settings\kris\my
documents\projects\bmopt\bmopt\createcase.cpp(265) : error C2039:
'm_assetBoundsTable' : is not a member of 'Ipopt::TNLP'
<br />> 1>
c:\optdir\iptnlp.hpp(48) : see declaration of
'Ipopt::TNLP'
<br />> 1>c:\documents and settings\kris\my
documents\projects\bmopt\bmopt\createcase.cpp(267) : error C2039:
'm_assetReturnDB' : is not a member of 'Ipopt::TNLP'
<br />> 1>
c:\optdir\iptnlp.hpp(48) : see declaration of
'Ipopt::TNLP'
<br />>
<br />> <span style="font-weight: bold;">But this is not
right, and these members are present in the derived class</span>. I
declare the smart
pointer
thus:
<br />>
<br />> SmartPtr<TNLP>
p_optdata;
<br />> and instantiate it as p_optdata = new COpt() where COpt is
the derived class from TNLP.
<br />>
<br />> Is there some other way I should
treat this derived class? If any more information is needed, please let me
know?
<br />>
<br />> <span style="font-weight: bold;">I even tried
SmarPtr<COpt> p_optdata</span>. The compiler does not like this.
The complaints about the new data members are gone. but instead I get
<br />>
<br />> 1>c:\documents and settings\kris\my
documents\projects\bmopt\bmopt\bmoptdoc.cpp(105) : error C2664:
'Ipopt::IpoptApplication::OptimizeTNLP' : cannot convert parameter 1 from
'Ipopt::SmartPtr<T>' to 'const Ipopt::SmartPtr<T> &'
<br />>
1> with
<br />> 1>
[
<br />> 1>
T=COpt
<br />> 1> ]
<br />> 1>
and
<br />> 1>
[
<br />> 1>
T=Ipopt::TNLP
<br />> 1>
]
<br />> 1> Reason: cannot
convert from 'Ipopt::SmartPtr<T>' to 'const
Ipopt::SmartPtr<T>'
<br />> 1>
with
<br />> 1> [
<br />> 1>
T=COpt
<br />>
1> ]
<br />> 1>
and
<br />> 1>
[
<br />> 1>
T=Ipopt::TNLP
<br />> 1>
]
<br />> 1> No
user-defined-conversion operator available that can perform this conversion, or
the operator cannot be called
<br />>
<br />> <span style="font-weight: bold;">I guess this is because oc the const declaration.</span>
<br style="font-weight: bold;" />
<br style="font-weight: bold;" />
<br style="font-weight: bold;" /><span style="font-weight: bold;">Any way I can solve
this issue? This is the very last part of my implementation, and any help
would be appreciated.</span>
<br style="font-weight: bold;" />
<br style="font-weight: bold;" /><span style="font-weight: bold;">Thanks in
advance</span>
<br />>
<br />> Krish
<br />
<br />
<br />Brad Bell
<br />
home: <a target="_blank" href="http://www.seanet.com/~bradbell">http://www.seanet.com/~bradbell</a>
<br />
work: brad@apl.washington.edu
<br />
other:
bradbell@seanet.com
<br />
</font>
</BODY>
</HTML>