<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
This suggestion makes sense to me, although it may cause additional overhead in case IPOPT wants to e.g. evaluate the Jacobian only. This could however be indicated by IPOPT using some flag.
<div class=""><br class="">
</div>
<div class="">Another option would be to set up your functions such that they internally cache the computed common variables and communicate them to each other, somehow.. But that sounds cumbersome.</div>
<div class=""><br class="">
</div>
<div class="">Filip<br class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">Op 27 nov. 2018, om 22:39 heeft R zu <<a href="mailto:rzu512@gmail.com" class="">rzu512@gmail.com</a>> het volgende geschreven:</div>
<br class="Apple-interchange-newline">
<div class="">
<div dir="ltr" class="">
<div class="">Sorry, I typed that in haste (~ 1 minute). I was doing derivative over products. Product rule means terms repeated.<br class="">
</div>
<div class=""><br class="">
</div>
<div class="">I wish Ipopt allow me to provide a function that provides the hessian, objective, and gradient in the same function.</div>
<div class="">That means I only need to calculate the common term for once, and plug it into formula of all three (hessian...).</div>
<div class=""><br class="">
</div>
<div class="">However, currently I need to provide a function for each of the hessian, objective, and gradient.
<br class="">
</div>
<div class="">Within each of the 3 functions, I need to calculate the common term for once.</div>
<div class=""><br class="">
</div>
<div class="">That means the common term is probably calculated for 3 times. I worry that compiler optimization might not be that good and floating point operations are not exactly commutative.</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
</div>
<br class="">
<div class="gmail_quote">
<div dir="ltr" class="">On Tue, Nov 27, 2018 at 2:15 PM R zu <<a href="mailto:rzu512@gmail.com" class="">rzu512@gmail.com</a>> wrote:<br class="">
</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr" class="">
<div class="">The difficulty is in programming. But here is an example.<br class="">
</div>
<div class=""><br class="">
</div>
<div class="">Example objective function f:<br class="">
</div>
<div class=""><br class="">
</div>
<div class=""><span style="font-family:monospace,monospace" class="">f(vector x) = g(vector x)h(vector x)</span></div>
<div class=""><span style="font-family:monospace,monospace" class=""><br class="">
</span></div>
<div class=""><span style="font-family:monospace,monospace" class="">where:<br class="">
</span></div>
<div class=""><span style="font-family:monospace,monospace" class=""> N N</span></div>
<div class=""><span style="font-family:monospace,monospace" class="">g(vector x) = Sum sum c_n c_m x_n</span></div>
<div class=""><span style="font-family:monospace,monospace" class=""> n=1 m=1</span></div>
<div class=""><span style="font-family:monospace,monospace" class=""><span style="font-family:monospace,monospace" class=""> N</span></span></div>
<div class=""><span style="font-family:monospace,monospace" class="">h(vetor x)<span style="font-family:monospace,monospace" class=""> =
<span style="font-family:monospace,monospace" class="">Sum<span style="font-family:monospace,monospace" class=""> c_n c_m x_n</span></span></span></span></div>
<div class=""><span style="font-family:monospace,monospace" class=""><span style="font-family:monospace,monospace" class=""><span style="font-family:monospace,monospace" class=""><span style="font-family:monospace,monospace" class=""> n=1</span></span></span></span></div>
<div class=""><span style="font-family:monospace,monospace" class=""><span style="font-family:monospace,monospace" class=""><span style="font-family:monospace,monospace" class=""><span style="font-family:monospace,monospace" class=""><br class="">
</span></span></span></span></div>
<div class="">Gradient calculated by product rule:</div>
<div class=""><br class="">
</div>
<div class="">f ' (x) = g ' (x) h(x) + g(x) + h' (x)</div>
<div class=""><br class="">
</div>
<div class="">The function g(x) and h(x) are common between f and f '.<br class="">
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
</div>
<br class="">
<div class="gmail_quote">
<div dir="ltr" class="">On Tue, Nov 27, 2018 at 1:59 PM Chintan Pathak <<a href="mailto:cp84@uw.edu" target="_blank" class="">cp84@uw.edu</a>> wrote:<br class="">
</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr" class="">
<div class="">Dear R Zu, <br class="">
</div>
<div class=""><br class="">
</div>
<div class="">Might be helpful if you give a small example demonstrating your usecase. For example, are the common terms dependent on 'x', etc.
<br class="">
</div>
<div class=""><br class="">
</div>
<div class="">Thanks <br class="">
</div>
<div class=""><br class="">
</div>
<div class="">
<div class="">
<div dir="ltr" class="m_-1610771480438513076m_5754590950814498276gmail_signature" data-smartmail="gmail_signature">
<div dir="ltr" class=""><a href="https://about.me/chintanpathak" target="_blank" class="">https://about.me/chintanpathak</a></div>
</div>
</div>
<br class="">
</div>
</div>
<br class="">
<div class="gmail_quote">
<div dir="ltr" class="">On Tue, Nov 27, 2018 at 9:55 AM R zu <<a href="mailto:rzu512@gmail.com" target="_blank" class="">rzu512@gmail.com</a>> wrote:<br class="">
</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr" class="">
<div class="">Hi.</div>
<div class=""><br class="">
</div>
<div class="">- The hessian, gradient, and objective function have some common terms.</div>
<div class="">- The common terms depends on the variables of the objective function.</div>
<div class=""><br class="">
</div>
<div class="">I calculate each common terms for three times because I need the term for Hessian, gradient, and objective function.</div>
<div class=""><br class="">
</div>
<div class="">Is it possible to only calculate each common term for only once in each step of optimization?</div>
<div class=""><br class="">
</div>
<div class="">Thank you.</div>
</div>
_______________________________________________<br class="">
Ipopt mailing list<br class="">
<a href="mailto:Ipopt@list.coin-or.org" target="_blank" class="">Ipopt@list.coin-or.org</a><br class="">
<a href="https://list.coin-or.org/mailman/listinfo/ipopt" rel="noreferrer" target="_blank" class="">https://list.coin-or.org/mailman/listinfo/ipopt</a><br class="">
</blockquote>
</div>
</blockquote>
</div>
</blockquote>
</div>
_______________________________________________<br class="">
Ipopt mailing list<br class="">
<a href="mailto:Ipopt@list.coin-or.org" class="">Ipopt@list.coin-or.org</a><br class="">
https://list.coin-or.org/mailman/listinfo/ipopt<br class="">
</div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>