<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">Hi,<br>
<br>
Thanks for the hint. <br>
<br>
I tried the following (which I found here:
<a class="moz-txt-link-freetext" href="http://list.coin-or.org/pipermail/ipopt/2010-July/002078.html">http://list.coin-or.org/pipermail/ipopt/2010-July/002078.html</a>):<br>
<br>
<small><i> OrigIpoptNLP* orignlp =
dynamic_cast<OrigIpoptNLP*>(GetRawPtr(ip_cq->GetIpoptNLP()));</i><i><br>
</i><i> TNLPAdapter* tnlp_adapter =
dynamic_cast<TNLPAdapter*>(GetRawPtr(orignlp->nlp()));</i><i><br>
</i><i><br>
</i><i> double *grad_current = new double[n];</i><i><br>
</i><i><br>
</i><i>
tnlp_adapter->ResortX(*(GetRawPtr(ip_cq->curr_grad_f())),
grad_current);</i><i><br>
</i><i><br>
</i><i> for (Index i=0;i<n;i++)</i><i><br>
</i><i> cout << grad_current[i] << endl;</i><i><br>
</i><i><br>
</i><i> delete[] grad_current;</i><i><br>
</i></small><br>
The problem is, that ResortX does the gradient sorting right but
adds the "fixed values in x", not the corresponding gradient
values.<br>
So I end up with the fixed coordinates written to grad_current. I
cannot figure out, how to access the gradient values wrt the fixed
dofs.<br>
<br>
It does not seem like there is a method which does the job (?). I
would be glad to hear that I am wrong ;).<br>
<br>
If not, I think I will just try to use the last call of
eval_grad_f in order to get the final gradient values of my NLP,
although this would not be elegant ...<br>
<br>
Best,<br>
Knut.<br>
<br>
Am 01.02.2013 16:00, schrieb Stefan Vigerske:<br>
</div>
<blockquote cite="mid:510BD870.8090404@math.hu-berlin.de"
type="cite">Hi,
<br>
<br>
note that there are two representations of the same NLP in Ipopt.
<br>
<br>
In your implementation of eval_grad_f you work on the TNLP that
you have passed to Ipopt.
<br>
<br>
Internally, Ipopt works with an NLP in standardform (the one from
the Ipopt implementation paper: no inequalities, only equations,
fixed variables removed). The vector you get in
IpoptCalculatedQuantities is w.r.t. this standardform. That is
probably one reason why it's not so trivial to actually get these
values.
<br>
<br>
There have been posts on this list on how to translate vectors
from the internal NLP representation to the TNLP form. You should
find these in the mailing lists archive, try searching for
<br>
TNLPAdapter site:<a class="moz-txt-link-freetext" href="http://list.coin-or.org/pipermail/ipopt/">http://list.coin-or.org/pipermail/ipopt/</a>
<br>
in google.
<br>
<br>
Stefan
<br>
<br>
<br>
On 02/01/2013 03:44 PM, Knut Heidemann wrote:
<br>
<blockquote type="cite">Hi,
<br>
<br>
I access the gradient values of my final objective function via
<br>
<br>
/ SmartPtr<const DenseVector> curr_grad =
dynamic_cast<const
<br>
DenseVector*>(GetRawPtr(ip_cq->curr_grad_f()));//
<br>
// const double* grad_values = curr_grad->Values();/
<br>
<br>
Unfortunately, this does not agree with the values calculated in
the
<br>
last call of "eval_grad_f".
<br>
The first few entries do agree, but then I get values that are
not
<br>
related to the actual results.
<br>
Furthermore, the values are not reproducable.
<br>
For me, this looks like I am accessing values that have not been
set?
<br>
<br>
Might there be something wrong with the code above, or even the
methods
<br>
used therein?
<br>
<br>
Kind regards,
<br>
Knut.
<br>
<br>
<br>
<br>
<br>
Am 18.01.2013 16:29, schrieb Stefan Vigerske:
<br>
<blockquote type="cite">Hi,
<br>
<br>
On 01/18/2013 12:10 PM, Knut Heidemann wrote:
<br>
<blockquote type="cite">I tried the code snippet below and get
the following error:
<br>
<br>
/In member function 'virtual void
<br>
WLCNLP::finalize_solution(Ipopt::SolverReturn, Ipopt::Index,
const
<br>
Number*, const Number*, const Number*, Ipopt::Index, const
Number*,
<br>
const Number*, Ipopt::Number, const Ipopt::IpoptData*,
<br>
Ipopt::IpoptCalculatedQuantities*)'://
<br>
//error: invalid use of incomplete type 'struct
<br>
Ipopt::IpoptCalculatedQuantities'//
<br>
//error: forward declaration of 'struct
<br>
Ipopt::IpoptCalculatedQuantities'/
<br>
<br>
Can this be due to further missing #includes or what kind of
problem do
<br>
I face here?
<br>
</blockquote>
<br>
Yes.
<br>
You need to include the header file where the
<br>
IpoptCalculatedQuantities class is defined.
<br>
<br>
Stefan
<br>
<br>
<blockquote type="cite">
<br>
Best,
<br>
Knut.
<br>
<br>
Am 17.01.2013 19:21, schrieb Hans Pirnay:
<br>
<blockquote type="cite">this should work:
<br>
<br>
SmartPtr<DenseVector> curr_grad =
dynamic_cast<const
<br>
DenseVector*>(GetRawPtr(ip_cq->curr_grad_f()));
<br>
const double* grad_values = curr_grad->Values();
<br>
<br>
You'll probably have to #include "IpDenseVector.hpp" and
maybe some
<br>
other dependencies.
<br>
<br>
Hans
<br>
<br>
On Thu, Jan 17, 2013 at 6:30 PM, Knut Heidemann
<br>
<a class="moz-txt-link-rfc2396E" href="mailto:heidemannknut@gmail.com"><heidemannknut@gmail.com></a> wrote:
<br>
<blockquote type="cite">Hi,
<br>
<br>
I am trying to access the objective function gradient
information
<br>
after my
<br>
problem has been solved.
<br>
I assume that this is done in finalize_solution(...).
<br>
Unfortunately, I do not manage to use "ip_cq" for this
purpose. Can
<br>
anybody
<br>
tell me how the appropriate line of code would look
like?
<br>
<br>
Best regards,
<br>
Knut Heidemann.
<br>
_______________________________________________
<br>
Ipopt mailing list
<br>
<a class="moz-txt-link-abbreviated" href="mailto:Ipopt@list.coin-or.org">Ipopt@list.coin-or.org</a>
<br>
<a class="moz-txt-link-freetext" href="http://list.coin-or.org/mailman/listinfo/ipopt">http://list.coin-or.org/mailman/listinfo/ipopt</a>
<br>
</blockquote>
</blockquote>
<br>
<br>
<br>
<br>
_______________________________________________
<br>
Ipopt mailing list
<br>
<a class="moz-txt-link-abbreviated" href="mailto:Ipopt@list.coin-or.org">Ipopt@list.coin-or.org</a>
<br>
<a class="moz-txt-link-freetext" href="http://list.coin-or.org/mailman/listinfo/ipopt">http://list.coin-or.org/mailman/listinfo/ipopt</a>
<br>
<br>
</blockquote>
<br>
</blockquote>
<br>
<br>
</blockquote>
<br>
</blockquote>
<br>
</body>
</html>