<div>Dear Pierre</div>
<div>I tried function ginv() with bonmin, using the example you mentioned in funcadd.c. The followings are two experiments I did:</div>
<div><font color="#3333ff">Experiment 1:</font></div>
<div><font color="#ff0000">ampl: function ginv(Reals);<br>ampl: display {i in -3...3} ginv(i);<br>ginv(i) [*] :=<br>-3&nbsp; -0.333333<br>-2&nbsp; -0.5<br>-1&nbsp; -1<br>&nbsp;0&nbsp;&nbsp; 0<br>;<br></font><font color="#3333ff">Experiment 2:</font></div>

<div><font color="#ff6600">ampl: reset;<br>ampl: function ginv(Reals);<br>ampl: var x;<br>ampl: minimize Z:x*x+x+1+ginv(x);<br>ampl: subject to cons:x&gt;=0.8;<br>ampl: option solver bonmin;<br>ampl: solve;<br>bonmin: <br>
Cannot load library /home/chen11q/AMPL_Learning/ampl_external_function/ASL/solvers/funclink/amplfunc.dll:<br>/home/chen11q/AMPL_Learning/ampl_external_function/ASL/solvers/funclink/amplfunc.dll: cannot open shared object file: No such file or directory
<br>function ginv not available<br>user-defined function not available<br>exit code 255<br>&lt;BREAK&gt;</font></div>
<div><font color="#ff6600"><font color="#000000">What I do not quite understand is: as you said in this example, the first and second derivatives of the function ginv() has been defined properly in C code, then why couldn&#39;t gin()still be used with Bonmin in AMPL? I am just trying to run this small example to make sure that once I can successfully write the first and second derivative of the external function, it will work properly with Bonmin as the solver in ampl.
</font></font></div>
<div>&nbsp;</div>
<div><font color="#ff6600"><font color="#000000">Thanks a lot for your time.</font></font></div>
<div>&nbsp;</div>
<div><font color="#ff6600"><font color="#000000">Roy</font></font></div>
<div><br><br>&nbsp;</div>
<div><span class="gmail_quote">On 3/2/07, <b class="gmail_sendername">Pierre Bonami</b> &lt;<a href="mailto:pierre.bonami@gmail.com">pierre.bonami@gmail.com</a>&gt; wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div style="WORD-WRAP: break-word">Dear Roy, 
<div>I am not sure that I understand your question. Maybe I was not clear enough. You have to provide the computation of first and second order derivatives of the function you are adding. All the computation actually take place in the same function.
</div>
<div>In the funclink directory there is an example:</div>
<div><br>&nbsp;</div>
<div style="MARGIN: 0px">&nbsp; 
<blockquote type="cite">
<div style="MARGIN: 0px">static real</div>
<div style="MARGIN: 0px">ginv(arglist *al)<span style="WHITE-SPACE: pre"> </span>/* generalized inverse of a single argument */</div>
<div style="MARGIN: 0px">{</div>
<div style="MARGIN: 0px"><span style="WHITE-SPACE: pre"></span>real x = al-&gt;ra[0];</div>
<div style="MARGIN: 0px"><span style="WHITE-SPACE: pre"></span>x = x ? 1./x : 0.;</div>
<div style="MARGIN: 0px"><span style="WHITE-SPACE: pre"></span>if (al-&gt;derivs) {</div>
<div style="MARGIN: 0px"><span style="WHITE-SPACE: pre"></span><span style="WHITE-SPACE: pre"></span>*al-&gt;derivs = -x*x;</div>
<div style="MARGIN: 0px"><span style="WHITE-SPACE: pre"></span><span style="WHITE-SPACE: pre"></span>if (al-&gt;hes)</div>
<div style="MARGIN: 0px"><span style="WHITE-SPACE: pre"></span><span style="WHITE-SPACE: pre"></span><span style="WHITE-SPACE: pre"></span>*al-&gt;hes = -2.*x * *al-&gt;derivs;</div>
<div style="MARGIN: 0px"><span style="WHITE-SPACE: pre"></span><span style="WHITE-SPACE: pre"></span>}</div>
<div style="MARGIN: 0px"><span style="WHITE-SPACE: pre"></span>return x;</div>
<div style="MARGIN: 0px"><span style="WHITE-SPACE: pre"></span>}</div></blockquote></div>
<div style="MARGIN: 0px"><br>&nbsp;</div>
<div style="MARGIN: 0px">you can see that first order derivative is put in al-&gt;derivs, and second order in al-&gt;hes. You should refer to the AMPL documentation to see where derivatives have to be provided.</div>
<div style="MARGIN: 0px">I used such user defined functions within Bonmin without problems, so I would think that it is possible. If you want to send me the files (ampl model and code to compile the funclink.dll), I can try to have a look and see if I can get it to work.
</div>
<div style="MARGIN: 0px">Best regards,</div><span class="sg">
<div style="MARGIN: 0px">Pierre</div></span>
<div><span class="e" id="q_111158ecea71dd10_2">
<div style="MARGIN: 0px"><br>&nbsp;</div>
<div><br>
<div>
<div>On Mar 2, 2007, at 8:22 PM, Roy Chen wrote:</div><br>
<blockquote type="cite">
<div>Dear Pierre</div>
<div>&nbsp;</div>
<div>I asked you about using Bonmin to solve my problem with the integration in objective two months ago, the following is the advice you gave to me at that time.</div>
<div><font color="#3333ff">&quot;For your problem of integration. In theory Bonmin should be able to do something with your problem if you provide functions for computing first and second order derivatives for your integral. I think that the most simple way is to import directly the function into ampl (see for example funclink subdirectory in the ASL library and the readme file here 
</font><a onclick="return top.js.OpenExtLink(window,event,this)" href="http://www.netlib.org/ampl/solvers/funclink/README" target="_blank"><font color="#3333ff">http://www.netlib.org/ampl/solvers/funclink/README</font></a>
 <font color="#3333ff">).&quot;<br></font><font color="#000000">Now what I am still wondering is: </font></div>
<div>Should I just provide functions for computing first and second orfer derivatives for my integral in AMPL user-defined external function instead of providing the AMPL external function to calculate the exact integral function value given some variables defined in AMPL as the input of integral function? 
</div>
<div>Best regards,</div>
<div>&nbsp;</div>
<div>Roy</div></blockquote></div><br>&nbsp;</div></span></div></div></blockquote></div><br>