<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" id="owaParaStyle"></style>
</head>
<body fpstyle="1" ocsi="0">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">Dear all,
<div><br>
</div>
<div>I am working on the HS071 optimization problem. I want to replace the explicit expressions for the Gradient, Hessian and Jocabian with a finite-difference approxiamation. Once I know how to do this, I will implement this on a more complex problem.</div>
<div><br>
</div>
<div>I am running Ipopt 3.9stable with the default ma27 solver and the C interface&nbsp;<span style="font-family: monospace; font-size: medium; ">IpStdCInterface.h</span>. I have no problems with setting the Hessian and the Jacobian approximation (see below). Allthough
 I was not expecting I could use the <u>Jacobian approximation</u> with the ma27 solver, especially since it is
<u>not mentioned as an IPOPT option in the online documentation</u>. (Documentation online is not clear and I can only find info on jacobian approximation at&nbsp;<a href="http://www.coin-or.org/Bonmin/option_pages/options_list_ipopt.html">http://www.coin-or.org/Bonmin/option_pages/options_list_ipopt.html</a>)</div>
<div><br>
<b>Hence 2 questions remain:</b></div>
<div>
<ol style="font-family: Tahoma; font-size: 10pt; ">
<li>How can I implement a gradient estimation using finite-differences?</li><li>How can I be sure that my jacobian estimation actually is correct? I can solve the HS071 problem with finite-differences jacobian, and get good results. Is this enough proof?</li></ol>
</div>
<div>Your help will be greatly appreciated!</div>
<div><br>
</div>
<div>Best regards,</div>
<div><br>
</div>
<div>-Martijn Disse</div>
<div><br>
</div>
<div>======================================================</div>
<div><b>Jacobian approximation (WORKS!)</b></div>
<div>
<div><i>AddIpoptStrOption(nlp, &quot;jacobian_approximation&quot;, &quot;finite-difference-values&quot;);&nbsp;
</i></div>
<div><i><br>
</i></div>
<div>
<div>Bool eval_jac_g(Index n, Number *x, Bool new_x,</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Index m, Index nele_jac,</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Index *iRow, Index *jCol, Number *values,</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; UserDataPtr user_data)</div>
<div>{</div>
<div>&nbsp; if (values == NULL) {</div>
<div>&nbsp; &nbsp; // return the structure of the Jacobian</div>
<div>&nbsp; &nbsp; // this particular Jacobian is dense</div>
<div>&nbsp; &nbsp; iRow[0] = 0; jCol[0] = 0;</div>
<div>&nbsp; &nbsp; iRow[1] = 0; jCol[1] = 1;</div>
<div>&nbsp; &nbsp; iRow[2] = 0; jCol[2] = 2;</div>
<div>&nbsp; &nbsp; iRow[3] = 0; jCol[3] = 3;</div>
<div>&nbsp; &nbsp; iRow[4] = 1; jCol[4] = 0;</div>
<div>&nbsp; &nbsp; iRow[5] = 1; jCol[5] = 1;</div>
<div>&nbsp; &nbsp; iRow[6] = 1; jCol[6] = 2;</div>
<div>&nbsp; &nbsp; iRow[7] = 1; jCol[7] = 3;</div>
<div>&nbsp; }</div>
<div>&nbsp; return FALSE;</div>
<div>}</div>
</div>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div><b>Hessian approximation (WORKS!)</b></div>
<div><i>AddIpoptStrOption(nlp, &quot;hessian_approximation&quot;, &quot;limited-memory&quot;);</i></div>
<div><i><br>
</i></div>
<div>I define the function as:</div>
<div>
<div>Bool eval_h(Index n, Number *x, Bool new_x, Number obj_factor,</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Index m, Number *lambda, Bool new_lambda,</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Index nele_hess, Index *iRow, Index *jCol,</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Number *values, UserDataPtr user_data)</div>
<div>{</div>
<div>&nbsp; return FALSE;</div>
<div>}</div>
</div>
<div><br>
</div>
<div>====================================================== </div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
</div>
</body>
</html>