<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#ffffff">
    Hi,<br>
    <br>
    Thank you for asking this question. As a workaround, you may use a
    global variable:<br>
    <br>
    <span class="Apple-style-span" style="border-collapse: separate;
      color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style:
      normal; font-variant: normal; font-weight: normal; letter-spacing:
      normal; line-height: normal; orphans: 2; text-indent: 0px;
      text-transform: none; white-space: normal; widows: 2;
      word-spacing: 0px; font-size: medium;"><span
        class="Apple-style-span" style="font-family: Arial,'Lucida
        Grande',sans-serif; font-size: 15px;">
        <pre>// An example NOT to follow
function y=banana(x)
  global a
  y = 100*(x(2)-x(1)^2)^2 + (a-x(1))^2
endfunction
a = sqrt(2);
global a;
x = fminsearch ( banana , [-1.2 1] )
expected = [a a^2];
</pre>
      </span></span><br>
    As this should be described in the help page of fminsearch, I
    created the bug report :<br class="Apple-interchange-newline">
    <br>
    <a href="http://bugzilla.scilab.org/show_bug.cgi?id=8552">http://bugzilla.scilab.org/show_bug.cgi?id=8552</a><br>
    <br>
    Another solution is to use the -costfargument option in neldermead.
    <br>
    <br>
    But global variables can lead to issues, so that it is really a
    temporary workaround. A better solution is to provide the extra
    parameters as a list. This is not in the Matlab/fminsearch (but
    Matlab has anonymous functions to handle this). I created the
    following bug report to fix this issue in fminsearch :<br>
    <br>
    <a href="http://bugzilla.scilab.org/show_bug.cgi?id=8553">http://bugzilla.scilab.org/show_bug.cgi?id=8553</a><br>
    <br>
    Best regards,<br>
    <br>
    Michaël Baudin<br>
    <br>
    <br>
    Le 02/12/2010 09:44, Carrico, Paul a écrit :
    <blockquote
      cite="mid:55A12CBC06A8C9459DCE0BBEF8122FDC0498AFEE@exchsrv.AUXITROL1"
      type="cite">
      <meta content="text/html; charset=ISO-8859-1"
        http-equiv="Content-Type">
      <meta name="GENERATOR" content="MSHTML 8.00.6001.18975">
      <div><font face="Arial" size="2"><span class="494261308-02122010">dear
            all,</span></font></div>
      <div><font face="Arial" size="2"><span class="494261308-02122010"></span></font> </div>
      <div><font face="Arial" size="2"><span class="494261308-02122010">I'm
            using either fminsearch function of nmplot one following the
            scheme hereafter :</span></font></div>
      <div><font face="Arial" size="2"><span class="494261308-02122010">level
            1- call of the fminsearch function</span></font></div>
      <div><font face="Arial" size="2"><span class="494261308-02122010">level
            2 - cost function</span></font></div>
      <div><font face="Arial" size="2"><span class="494261308-02122010">level
            3 - call of sub-function</span></font></div>
      <div><font face="Arial" size="2"><span class="494261308-02122010"></span></font> </div>
      <div><font face="Arial" size="2"><span class="494261308-02122010">As
            you can see herebellow I would like to link constant
            parameters from the level 1 to the level 3 (i.e. nu1 and nu2
            values) => how can I do this ?</span></font></div>
      <div><font face="Arial" size="2"><span class="494261308-02122010"></span></font> </div>
      <div><font face="Arial" size="2"><span class="494261308-02122010">I
            had a look in optimset/optimget function but It not seems to
            be the write ones !</span></font></div>
      <div><font face="Arial" size="2"><span class="494261308-02122010"></span></font> </div>
      <div><font face="Arial" size="2"><span class="494261308-02122010"></span></font><font
          face="Arial" size="2"><span class="494261308-02122010"></span></font><font
          face="Arial" size="2"><span class="494261308-02122010"></span></font> </div>
      <div><font face="Arial" size="2"><span class="494261308-02122010">I
            hope it's clear enough</span></font></div>
      <div><font face="Arial" size="2"><span class="494261308-02122010"></span></font> </div>
      <div><font face="Arial" size="2"><span class="494261308-02122010">Regards</span></font></div>
      <div><font face="Arial" size="2"><span class="494261308-02122010"></span></font> </div>
      <div><font face="Arial" size="2"><span class="494261308-02122010">Paul</span></font></div>
      <div><font face="Arial" size="2"><span class="494261308-02122010"></span></font> </div>
      <div><font face="Arial" size="2"><span class="494261308-02122010">###
            level 1</span></font></div>
      <div><font face="Arial" size="2"><span class="494261308-02122010">optimized_parameters
            = fminsearch(optimization,initial_parameters);</span></font></div>
      <div><font face="Arial" size="2"><span class="494261308-02122010">poisson
            = 0.495;<br>
            mu1 = 0.0438055;<br>
            alpha1 = 2.86504;<br>
            mu2 = 0.061838;<br>
            alpha2 = 1.34878;<br>
            nu1 = poisson;<br>
            nu2 = poisson;<br>
            initial_parameters = [mu1 alpha1 mu2 alpha2];</span></font></div>
      <div><font face="Arial" size="2"><span class="494261308-02122010"></span></font> </div>
      <div><font face="Arial" size="2"><span class="494261308-02122010"></span></font> </div>
      <div><font face="Arial" size="2"><span class="494261308-02122010">
            <div><font face="Arial" size="2"><span
                  class="494261308-02122010">### level 2</span></font></div>
          </span></font></div>
      <div><font face="Arial" size="2">function SSE = optimization(x)</font></div>
      <div> </div>
      <div><font face="Arial" size="2">nu1 = 0.495;<br>
          nu2 = 0.495;<br>
          ADDITIONAL = [nu1 nu2];<br>
printf("#########################################################\n");<br>
          printf("            * mu1 = %g\n",x(1));<br>
          printf("            * alpha1 = %g\n",x(2));<br>
          printf("            * mu2 = %g\n",x(3));<br>
          printf("            * alpha2 = %g\n",x(4));<br>
          printf("            * nu1 = %g\n",nu1);<br>
          printf("            * nu2 = %g\n",nu2);</font></div>
      <div> </div>
      <div> </div>
      <div>
        <div><font face="Arial" size="2"><span
              class="494261308-02122010">
              <div><font face="Arial" size="2"><span
                    class="494261308-02122010">### level 3</span></font></div>
            </span></font></div>
        <div><font face="Arial" size="2">status =
            write_ccx_file(PATH_DATA,INPUT_FILE_NAME,x,ADDITIONAL);</font></div>
      </div>
      <pre>--------------------------------------------------------------------------------


Le présent mail et ses pièces jointes sont confidentiels et destinés à la personne ou aux personnes visée(s) ci-dessus. Si vous avez reçu cet e-mail par erreur, veuillez contacter immédiatement l'expéditeur et effacer le message de votre système. Toute divulgation, copie ou distribution de cet e-mail est strictement interdite.

This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error, please contact the sender and delete the email from your system. If you are not the named addressee you should not disseminate, distribute or copy this email.


</pre>
    </blockquote>
    <br>
    <br>
    <pre class="moz-signature" cols="72">-- 
Michaël Baudin
Ingénieur de développement
<a class="moz-txt-link-abbreviated" href="mailto:michael.baudin@scilab.org">michael.baudin@scilab.org</a>
-------------------------
Consortium Scilab - Digiteo
Domaine de Voluceau - Rocquencourt
B.P. 105 - 78153 Le Chesnay Cedex
Tel. : 01 39 63 56 87 - Fax : 01 39 63 55 94

</pre>
  </body>
</html>