<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p></p>
<div style="margin-top:0;margin-bottom:0;">Hi,</div>
<div style="margin-top:0;margin-bottom:0;"><br>
</div>
<div style="margin-top:0;margin-bottom:0;">    I would like to optimize a problem in C++ for different problem settings inside a loop. For that I need to get the primal variables outside of the NS071_NLP object (I kept the same name used in the C++ example).
 I attached a Rosenbrock problem example using the C++ ipopt interface showing the issue.<br>
</div>
<div style="margin-top:0;margin-bottom:0;"><br>
</div>
<div style="margin-top:0;margin-bottom:0;">In the C++ example there is a parent (base) class TNLP and all its functions are instantiated in the NS071_NLP using virtual functions.
<br>
</div>
<div style="margin-top:0;margin-bottom:0;"><br>
</div>
<div style="margin-top:0;margin-bottom:0;">I didn't find any functions in TNLP that give you the optimized values. Are there any? So what I tried for a test was to add a function to NS071_NLP called getvalue() {return thevalue;} that gets the first value of
 the optimized variables (x[]) and added a variable in the NS071_NLP class called double thevalue.</div>
<div style="margin-top:0;margin-bottom:0;"><br>
</div>
<div style="margin-top:0;margin-bottom:0;">Then when the finalize_solution(* x, etc) from TNLP is called, the x[] goes into it and I added the line:</div>
<div style="margin-top:0;margin-bottom:0;">thevalue = x[0];</div>
<div style="margin-top:0;margin-bottom:0;"><br>
</div>
<div style="margin-top:0;margin-bottom:0;">After the problem is optimized I try calling mynlp->getvalue() where mynlp is a smart pointer to an NS071_NLP object and I get:</div>
<div style="margin-top:0;margin-bottom:0;"> </div>
<div>ipoptexample.cpp: In function ‘int main(int, char**)’:<br>
ipoptexample.cpp:202:21: error: ‘class Ipopt::TNLP’ has no member named ‘getvalue’; did you mean ‘eval_f’?<br>
   thevalue = mynlp->getvalue();<br>
                     ^~~~~~~~</div>
<div><br>
</div>
<div>Why doesn't this work? As a last resort I could go and change TNLP and add the function there but I should be able to add functions to the child class.</div>
<div><br>
</div>
<div><br>
</div>
<div>Thank you,</div>
<div>Alex</div>
<br>
<p></p>
</div>
</body>
</html>